Files | |
file | semaphore.h |
Semaphores. | |
Macros | |
#define | SEM_FAILED ((sem_t *) 0) |
Value returned if ‘sem_open’ failed. | |
Typedefs | |
typedef sema_t | sem_t |
POSIX-specific semaphore type. | |
Functions | |
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 name with open flags oflag . More... | |
static int | sem_close (sem_t *sem) |
Close descriptor for named semaphore sem . More... | |
static int | sem_unlink (const char *name) |
Remove named semaphore name . More... | |
int | sem_timedwait (sem_t *sem, const struct timespec *abstime) |
Similar to ‘sem_wait’ but wait only until abstime . More... | |
static int | sem_trywait (sem_t *sem) |
Test whether sem is posted. More... | |
static int | sem_getvalue (sem_t *sem, int *sval) |
Get current value of sem and store it in sval . More... | |
|
inlinestatic |
Close descriptor for named semaphore sem
.
[in] | sem | Semaphore to close. |
Definition at line 198 of file semaphore.h.
|
inlinestatic |
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.
sem | A semaphore. |
Definition at line 96 of file semaphore.h.
|
inlinestatic |
Get current value of sem
and store it in sval
.
[in] | sem | Semaphore to get the value from. |
[out] | sval | Place where value goes to. |
Definition at line 283 of file semaphore.h.
|
inlinestatic |
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. |
Definition at line 68 of file semaphore.h.
|
inlinestatic |
Open a named semaphore name
with open flags oflag
.
[in] | name | Name to set. |
[in] | oflag | Flags to set. |
Definition at line 177 of file semaphore.h.
|
inlinestatic |
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().
sem | A semaphore |
Definition at line 124 of file semaphore.h.
int sem_timedwait | ( | sem_t * | sem, |
const struct timespec * | abstime | ||
) |
Similar to ‘sem_wait’ but wait only until abstime
.
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. |
|
inlinestatic |
Test whether sem
is posted.
[in] | sem | Semaphore to try to wait on |
Definition at line 259 of file semaphore.h.
|
inlinestatic |
Remove named semaphore name
.
[in] | name | Name to unlink. |
Definition at line 218 of file semaphore.h.
|
inlinestatic |
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.
sem | A semaphore. |
Definition at line 152 of file semaphore.h.