Docs

You are here:
OSCntSem interface

Functions

OSCntSem OSCNTSEM_Create (int init, int max)
 
void OSCNTSEM_Destroy (OSCntSem sem)
 
bool OSCNTSEM_IsValid (OSCntSem sem)
 
void OSCNTSEM_Give (OSCntSem sem)
 
int OSCNTSEM_Take (OSCntSem sem, OSTime timeout)
 

Detailed Description

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

Function Documentation

OSCntSem OSCNTSEM_Create ( int  init,
int  max 
)

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

Parameters
initinitial value of the counting semaphore
maxmaximum value of the counting semaphore
Returns
a newly created binary semaphore
void OSCNTSEM_Destroy ( OSCntSem  sem)

Destroys a counting semaphore

Parameters
semcounting semaphore to destroy
void OSCNTSEM_Give ( OSCntSem  sem)

Increments the value of a counting semaphore.

Parameters
semcounting semaphore to give
bool OSCNTSEM_IsValid ( OSCntSem  sem)

Checks if a counting semaphore handle represents a valid semaphore. Can be used to test if OSCNTSEM_Create produced a valid semaphore. Beware, that checking handle of a semaphore, that has been destroyed (OSCNRSEM_Destroy) yields undefined behavior. On some ports such handle may still be reported as valid.

Parameters
semcounting semaphore to check
Returns
true if semaphore is valid or false if not
int OSCNTSEM_Take ( OSCntSem  sem,
OSTime  timeout 
)

Takes the counting 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
semcounting 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