Maestro Audio Framework  v 1.0
NXP Semiconductors
osa_sem.h File Reference

Contains semaphore function prototypes for Impresario libosa. More...

Functions

int osa_sem_create (OsaSem *semaphore, uint32_t initial_value)
 Create a semaphore. More...
 
int osa_sem_destroy (OsaSem *semaphore)
 Destroy a semaphore. More...
 
int osa_sem_post (OsaSem *semaphore)
 Post a semaphore. More...
 
int osa_sem_wait (OsaSem *semaphore, uint32_t timeout)
 Wait a semaphore. More...
 
int osa_sem_poll (OsaSem *semaphore)
 

Function Documentation

◆ osa_sem_create()

int osa_sem_create ( OsaSem *  semaphore,
uint32_t  initial_value 
)

Create a semaphore object and return to the caller. A value must be specified as the initial value for the semaphore.

Parameters
semaphoreA semaphore object that will be created and returned to the caller
initial_valueUnsigned int value specifying the initial value for this semaphore
Return values
ERRCODE_NO_ERRORFunction succeeded
ERRCODE_OUT_OF_MEMORYOut of memory
ERRCODE_INVALID_ARGUMENTInvalid semaphore object passed in
ERRCODE_TRY_AGAINSystem limits reached (Linux only)
ERRCODE_PERMISSION_DENIEDCaller does not have sufficient privilege (Linux only)
ERRCODE_GENERAL_ERRORUnexpected system error

◆ osa_sem_destroy()

int osa_sem_destroy ( OsaSem *  semaphore)

Free the resources associated with a semaphore object. On MQX, all blocking threads are put in ready status. On linux, these blocking threads produces undefined behavior.

Parameters
semaphoreA valid semaphore object
Return values
ERRCODE_NO_ERRORFunction succeeded
ERRCODE_INVALID_ARGUMENTInvalid semaphore object passed in

◆ osa_sem_post()

int osa_sem_post ( OsaSem *  semaphore)

Increase the semaphore object or unblock it. If the semaphore is value becomes greater than or equal zero, then another thread blocked on this semaphore will be woken up and lock the semaphore.

Parameters
semaphoreA valid semaphore object
Return values
ERRCODE_NO_ERRORFunction succeeded
ERRCODE_INVALID_ARGUMENTInvalid semaphore object passed in
ERRCODE_OVERFLOWThe semaphore be posted more that its number (linux only)

◆ osa_sem_wait()

int osa_sem_wait ( OsaSem *  semaphore,
uint32_t  timeout 
)

Decrease the semaphore object or lock it. If the semaphore's value is greater than zero, the decrement proceeds, and the function returns immediately. If the semaphore value is zero, the call blocks until another task posts the semaphore or the timeout shoots.

Parameters
semaphoreA valid semaphore object
timeoutA number of milliseconds to wait for a semaphore. If the value is 0, then the timeout will be infinite.
Return values
ERRCODE_NO_ERRORFunction succeeded
ERRCODE_INVALID_ARGUMENTInvalid semaphore object passed in or thread does not own the semaphore
ERRCODE_TIMED_OUTThe call timed out before the semaphore could be got.
ERRCODE_INTERNALSystem gets a error in creating timer for timeout (linux only)