Docs

You are here:
OSSem interface

Functions

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)
 

Detailed Description

An interface to a binary semaphore mechanisms provided by the OS. The implementation of the OSSem depends on the OS used.

Function Documentation

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
sembinary semaphore to destroy
void OSSEM_Give ( OSSem  sem)

Gives the binary semaphore.

Parameters
sembinary semaphore to give
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
sembinary semaphore to check
Returns
true if semaphore is valid or false if not
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
sembinary semaphore to take
timeoutmaximum time spent waiting for the semaphore in miliseconds
Returns
0 if the semaphore was taken !0 if timeout or error occurred
Go to Top