An interface to a binary semaphore mechanisms provided by the OS. The implementation of the OSSem depends on the OS used.
OSSem OSSEM_Create |
( |
void |
| ) |
|
Creates a new binary semaphore instance. The semaphore implementation depends on the actual OS.
- Returns
- a newly created binary semaphore
void OSSEM_Destroy |
( |
OSSem |
sem | ) |
|
Destroys a binary semaphore
- Parameters
-
sem | binary semaphore to destroy |
bool OSSEM_IsValid |
( |
OSSem |
sem | ) |
|
Checks if a semaphore handle represents a valid semaphore. Can be used to test if OSSEM_Create produced a valid semaphore. Beware, that checking handle of a semaphore, that has been destroyed (OSSEM_Destroy) yields undefined behavior. On some ports such handle may still be reported as valid.
- Parameters
-
sem | binary semaphore to check |
- Returns
- true if semaphore is valid or false if not
void OSSEM_Give |
( |
OSSem |
sem | ) |
|
Gives the binary semaphore.
- Parameters
-
sem | binary semaphore to give |
int OSSEM_Take |
( |
OSSem |
sem, |
|
|
OSTime |
timeout |
|
) |
| |
Takes the binary semaphore. If the semaphore is not immediately available, the task from which the call was made is blocked. The maximum time spent waiting for the semaphore is specified by the timeout parameter.
- Parameters
-
sem | binary semaphore to take |
timeout | maximum time spent waiting for the semaphore in miliseconds |
- Returns
- 0 if the semaphore was taken !0 if timeout or error occurred