HALFRED  0.4.0
OSSem interface

Detailed Description

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)
void OSSEM_Destroy (OSSem sem)
bool OSSEM_IsValid (OSSem sem)
void OSSEM_Give (OSSem sem)
int OSSEM_Take (OSSem sem, OSTime timeout)

Function Documentation

OSSem OSSEM_Create ( void  )

Creates a new binary semaphore instance. The semaphore implementation depends on the actual OS.

a newly created binary semaphore
void OSSEM_Destroy ( OSSem  sem)

Destroys a binary semaphore

sembinary 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.

sembinary semaphore to check
true if semaphore is valid or false if not
void OSSEM_Give ( OSSem  sem)

Gives the binary semaphore.

sembinary 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.

sembinary semaphore to take
timeoutmaximum time spent waiting for the semaphore in miliseconds
0 if the semaphore was taken !0 if timeout or error occurred