|#define||SEM_FAILED ((sem_t *) 0)|
|Value returned if `sem_open' failed. |
|POSIX-specific semaphore type. |
|static int||sem_init (sem_t *sem, int pshared, unsigned value)|
|Initialize an unnamed semaphore. More...|
|static int||sem_destroy (sem_t *sem)|
|destroy an unnamed semaphore More...|
|static int||sem_post (sem_t *sem)|
|Unlock a semaphore. More...|
|static int||sem_wait (sem_t *sem)|
|Lock a semaphore. More...|
|static sem_t *||sem_open (const char *name, int oflag,...)|
|Open a named semaphore |
|static int||sem_close (sem_t *sem)|
|Close descriptor for named semaphore |
|static int||sem_unlink (const char *name)|
|Remove named semaphore |
|int||sem_timedwait (sem_t *sem, const struct timespec *abstime)|
|Similar to `sem_wait' but wait only until |
|static int||sem_trywait (sem_t *sem)|
|Test whether |
|static int||sem_getvalue (sem_t *sem, int *sval)|
|Get current value of |
Close descriptor for named semaphore
|[in]||sem||Semaphore to close.|
destroy an unnamed semaphore
The sem_destroy() function shall destroy the unnamed semaphore indicated by
sem. Only a semaphore that was created using sem_init() may be destroyed using sem_destroy(); the effect of calling sem_destroy() with a named semaphore is undefined. The effect of subsequent use of the semaphore
sem is undefined until sem is reinitialized by another call to sem_init().
It is safe to destroy an initialized semaphore upon which no threads are currently blocked. The effect of destroying a semaphore upon which other threads are currently blocked is undefined.
Get current value of
sem and store it in
|[in]||sem||Semaphore to get the value from.|
|[out]||sval||Place where value goes to.|
Initialize an unnamed semaphore.
The sem_init() function shall initialize the unnamed semaphore referred to by
sem. The value of the initialized semaphore shall be
value. Following a successful call to sem_init(), the semaphore may be used in subsequent calls to sem_wait(), sem_timedwait(), sem_trywait(), sem_post(), and sem_destroy(). This semaphore shall remain usable until the semaphore is destroyed.
|[out]||sem||Semaphore to initialize.|
|[in]||pshared||**(unused, since RIOT only has threads)** Semaphore is shared between processes not threads.|
|[in]||value||Value to set.|
Open a named semaphore
name with open flags
|[in]||name||Name to set.|
|[in]||oflag||Flags to set.|
Unlock a semaphore.
The sem_post() function shall unlock the semaphore referenced by
sem by performing a semaphore unlock operation on that semaphore.
If the semaphore value resulting from this operation is positive, then no threads were blocked waiting for the semaphore to become unlocked; the semaphore value is simply incremented.
If the value of the semaphore resulting from this operation is zero, then one of the threads blocked waiting for the semaphore shall be allowed to return successfully from its call to sem_wait().
|int sem_timedwait||(||sem_t *||sem,|
|const struct timespec *||abstime|
Similar to `sem_wait' but wait only until
The sem_timedwait() function shall lock the semaphore referenced by
sem as in the sem_wait() function. However, if the semaphore cannot be locked without waiting for another process or thread to unlock the semaphore by performing a sem_post() function, this wait shall be terminated when the specified timeout expires.
|[in]||sem||Semaphore to wait on.|
|[in]||abstime||Absolute time (that is when the clock on which temouts are based equals this value) the timeout for the wait shall expire. If the value specified has already passed the timeout expires immediately.|
sem is posted.
|[in]||sem||Semaphore to try to wait on|
Remove named semaphore
|[in]||name||Name to unlink.|
Lock a semaphore.
The sem_wait() function shall lock the semaphore referenced by
sem by performing a semaphore lock operation on that semaphore. If the semaphore value is currently zero, then the calling thread shall not return from the call to sem_wait() until it either locks the semaphore or the call is interrupted by a signal.