SYNOPSIS
#include <semaphore.h>
int sem_init(sem_t *sem, int pshared, unsigned int value);
DESCRIPTION
The
If you attempt to initialize a semaphore that has already been initialized, the original semaphore is overwritten by the newly initialized one.
You can only use sem itself to perform synchronization.
Referring to copies of sem in calls to
the
Semaphores created with
PARAMETERS
- sem
-
Specifies the semaphore to be initialized.
- pshared
-
Is ignored. In other implementations, this argument specifies whether or not the newly initialized semaphore is shared between processes or between threads. A non-zero value means the semaphore is shared between processes; a value of zero means it is shared between threads. On the NuTCRACKER Platform, semaphores are always shared.
- value
-
Specifies the value to assign to the newly initialized semaphore.
RETURN VALUES
When successful, the
- EACCES
-
The process lacks the appropriate privileges to initialize the semaphore.
- EEXIST
-
The specified semaphore already exists.
- EINVAL
-
The value argument exceeds SEM_VALUE_MAX.
- ENFILE
-
Too many semaphores are currently open in the system.
- ENOSPC
-
A resource required to initialize the semaphore has been exhausted, or the limit on semaphores (SEM_NSEMS_MAX) has been reached.
EXAMPLES
None.
CONFORMANCE
UNIX 03. Derived from the POSIX Realtime Extension (1003.1b-1993/1003.1i-1995)
MULTITHREAD SAFETY LEVEL
MT-Safe.
PORTING ISSUES
None.
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
- Functions:
sem_destroy() ,sem_post() ,sem_trywait() ,sem_wait()
- Miscellaneous:
- semaphores
PTC MKS Toolkit 10.4 Documentation Build 39.