| Maestro Audio Framework v 1.0 NXP Semiconductors

Functions
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

  semaphore | A semaphore object that will be created and returned to the caller
  initial_value | Unsigned int value specifying the initial value for this semaphore

Return values

  ERRCODE_NO_ERROR | Function succeeded
  ERRCODE_OUT_OF_MEMORY | Out of memory
  ERRCODE_INVALID_ARGUMENT | Invalid semaphore object passed in
  ERRCODE_TRY_AGAIN | System limits reached (Linux only)
  ERRCODE_PERMISSION_DENIED | Caller does not have sufficient privilege (Linux only)
  ERRCODE_GENERAL_ERROR | Unexpected 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

  semaphore | A valid semaphore object

Return values

  ERRCODE_NO_ERROR | Function succeeded
  ERRCODE_INVALID_ARGUMENT | Invalid 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

  semaphore | A valid semaphore object

Return values

  ERRCODE_NO_ERROR | Function succeeded
  ERRCODE_INVALID_ARGUMENT | Invalid semaphore object passed in
  ERRCODE_OVERFLOW | The 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

  semaphore | A valid semaphore object
  timeout | A number of milliseconds to wait for a semaphore. If the value is 0, then the timeout will be infinite.

Return values

  ERRCODE_NO_ERROR | Function succeeded
  ERRCODE_INVALID_ARGUMENT | Invalid semaphore object passed in or thread does not own the semaphore
  ERRCODE_TIMED_OUT | The call timed out before the semaphore could be got.
  ERRCODE_INTERNAL | System gets a error in creating timer for timeout (linux only)