#include <stdint.h>
Go to the source code of this file.
|
#define | __SIZEOF_SEM_T 12 /* sizeof(struct semaphore) */ |
|
◆ sem_destroy()
int sem_destroy |
( |
sem_t * |
sem | ) |
|
Destroy the semaphore.
- Parameters
-
sem | Pointer to the semaphore. |
- Return values
-
int | 0 on success and nonzero error number on error. |
◆ sem_getvalue()
int sem_getvalue |
( |
sem_t * |
sem, |
|
|
int * |
sval |
|
) |
| |
Get the value of the semaphore.
- Parameters
-
sem | The semaphore object to provide. |
sval | For returning current value of the semaphore. |
- Return values
-
int | 0 on success and nonzero error number on error. |
◆ sem_init()
int sem_init |
( |
sem_t * |
sem, |
|
|
int |
pshared, |
|
|
unsigned int |
value |
|
) |
| |
Initialize the semaphore.
- Parameters
-
sem | Pointer to the semaphore. |
pshared | Not used. |
value | The initial value of the semaphore. |
- Return values
-
int | 0 on success and nonzero error number on error. |
◆ sem_post()
int sem_post |
( |
sem_t * |
sem | ) |
|
Increase the value of the semaphore.
- Parameters
-
sem | Pointer to the semaphore. |
- Return values
-
int | 0 on success and nonzero error number on error. |
◆ sem_trywait()
int sem_trywait |
( |
sem_t * |
sem | ) |
|
The same as sem_wait(), except that if the decrement cannot be immediately performed, then the function returns an error instead of blocking.
- Parameters
-
sem | Pointer to the semaphore. |
- Return values
-
int | 0 on success and nonzero error number on error. |
◆ sem_wait()
int sem_wait |
( |
sem_t * |
sem | ) |
|
Decrement the value of the semaphore. If the semaphore currently has the value zero, then the function blocks until it becomes possible to perform the decrement.
- Parameters
-
sem | Pointer to the semaphore. |
- Return values
-
int | 0 on success and nonzero error number on error. |