SYNOPSIS
#include <sys/sem.h>
int semget(key_t key, int nsems, int semflg);
DESCRIPTION
The
Upon creation, the internal attributes associated with the new semaphore identifier are initialized as follows:
- sem_perm.cuid, sem_perm.uid, sem_perm.cgid and sem_perm.gid are set equal to the effective user ID and effective group ID, respectively, of the calling process.
- The access permission bits of sem_perm.mode are set equal to the access permission bits of semflg.
- sem_nsems is set equal to the value of nsems.
- sem_otime is set equal to 0 and sem_ctime is set equal to the current time.
You must explicitly remove semaphore identifiers after the last reference to them has been removed.
The
PARAMETERS
- key
-
Specifies either IPC_PRIVATE or a system-wide unique key.
- nsems
-
Is the number of semaphores in the set associated with the semaphore ID.
- semflg
-
Is a flag indicating specific semaphore conditions and options to implement.
RETURN VALUES
If successful,
- EACCES
-
A semaphore identifier exists for key, but operation permission as specified by permission bits of semflg would not be granted.
- EEXIST
-
A semaphore identifier exists for key but (semflg & IPC_CREAT) and (semflg & IPC_EXCL) are both non-zero.
- EINVAL
-
A semaphore identifier exists for key, but the number of semaphores in the set associated with it is less than nsems, and nsems is not equal to zero.
- EINVAL
-
nsems is either less than or equal to zero or greater than the system imposed limit.
- ENOENT
-
A semaphore identifier does not exist for key and (semflg & IPC_CREAT) is zero.
- ENOSPC
-
A semaphore identifier is to be created but the system-imposed limit on the maximum number of allowed semaphore identifiers system wide would be exceeded.
CONFORMANCE
UNIX 98.
MULTITHREAD SAFETY LEVEL
MT-Safe.
PORTING ISSUES
NuTCRACKER Platform semaphores are not implemented in terms of Win32 semaphores; therefore, they cannot be shared with Win32 applications.
AVAILABILITY
PTC MKS Toolkit for Professional Developers
PTC MKS Toolkit for Professional Developers 64-Bit Edition
PTC MKS Toolkit for Enterprise Developers
PTC MKS Toolkit for Enterprise Developers 64-Bit Edition
SEE ALSO
PTC MKS Toolkit 10.4 Documentation Build 39.