Semaphore for managing shared resources.
More...
Semaphore for managing shared resources.
int ua_sem_create |
( |
ua_sem_t * |
sem, |
|
|
int |
shared, |
|
|
unsigned int |
value, |
|
|
const char * |
name |
|
) |
| |
Initialize a semaphore.
- Parameters
-
sem | Semaphore to initialize. |
shared | 1 if the semaphore should be shared. |
value | Initial value of the semaphore. |
name | Unique name for the semaphore |
- Returns
- Zero on success or errorcode on failure.
Clear a semaphore.
The semaphore shall no longer be used.
- Parameters
-
- Returns
- Zero on success or errorcode on failure.
Post (increment/unlock) a semaphore.
- Parameters
-
- Returns
- Zero on success or errorcode on failure.
int ua_sem_timedwait |
( |
ua_sem_t * |
sem, |
|
|
int |
ms_timeout |
|
) |
| |
Decrement/lock a semaphore.
If the value of the semaphore is zero the function waits (blocks) for the given timeout. If the value could not be decremented in the given time the errorcode UA_EBADOPTIMEOUT is returned.
- Parameters
-
sem | Semaphore to decrement. |
timeout | Time in milliseconds to wait. |
- Returns
- Zero on success or errorcode on failure.
Decrement/lock a semaphore.
If the value of the semaphore is zero the function returns with the errorcode UA_EBADAGAIN instead of waiting.
- Parameters
-
sem | Semaphore to decrement. |
- Returns
- Zero on success or errorcode on failure.
Decrement/lock a semaphore.
If the value of the semaphore is zero the function waits (blocks) until the value becomes greater than zero.
- Parameters
-
sem | Semaphore to decrement/wait. |
- Returns
- Zero on success or errorcode on failure.