pico]OS  1.0.4
Typedefs | Functions
Semaphore Functions
Abstracted Functions

Typedefs

typedef POSSEMA_t NOSSEMA_t

Functions

NANOEXT NOSSEMA_t POSCALL nosSemaCreate (INT_t initcount, UVAR_t options, const char *name)
NANOEXT void POSCALL nosSemaDestroy (NOSSEMA_t sema)
NANOEXT VAR_t POSCALL nosSemaSignal (NOSSEMA_t sema)
NANOEXT VAR_t POSCALL nosSemaGet (NOSSEMA_t sema)
NANOEXT VAR_t POSCALL nosSemaWait (NOSSEMA_t sema, UINT_t timeoutticks)

Detailed Description

For detailed information about using semaphores please see detailed description of semaphores


Typedef Documentation

Handle to a nano layer semaphore object.


Function Documentation

NANOEXT NOSSEMA_t POSCALL nosSemaCreate ( INT_t  initcount,
UVAR_t  options,
const char *  name 
)

Semaphore function. Allocates a new semaphore object.

Parameters:
initcountInitial semaphore count (see detailed semaphore description in pico laye documentation).
optionsCurrently unused. Please set this parameter to 0 (zero).
nameName of the new semaphore object to create. If the last character in the name is an asteriks (*), the operating system automatically assigns the semaphore a unique name (the registry feature must be enabled for this automatism). This parameter can be NULL if the nano layer registry feature is not used and will not be used in future.
Returns:
the pointer to the new semaphore object. NULL is returned on error.
Note:
NOSCFG_FEATURE_SEMAPHORES must be defined to 1 to have semaphore support compiled in.
You must use nosSemaDestroy to destroy the semaphore again.
Even if the function posSemaDestroy would work also, it is required to call nosSemaDestroy. Only this function removes the semaphore from the registry.
Dependent of your configuration, this function can be defined as macro to decrease code size.
See also:
nosSemaDestroy, nosSemaGet, nosSemaWait, nosSemaSignal
NANOEXT void POSCALL nosSemaDestroy ( NOSSEMA_t  sema)

Semaphore function. Frees a no more needed semaphore object.

Parameters:
semahandle to the semaphore object.
Note:
NOSCFG_FEATURE_SEMAPHORES must be defined to 1 to have semaphore support compiled in.
POSCFG_FEATURE_SEMADESTROY must be defined to 1 to have this function compiled in.
Dependent of your configuration, this function can be defined as macro to decrease code size.
See also:
nosSemaCreate
NANOEXT VAR_t POSCALL nosSemaGet ( NOSSEMA_t  sema)

Semaphore function. This function tries to get the semaphore object. If the semaphore is in nonsignalized state (that means its counter is zero or less), this function blocks the task execution until the semaphore gets signaled.

Parameters:
semahandle to the semaphore object.
Returns:
zero on success.
Note:
NOSCFG_FEATURE_SEMAPHORES must be defined to 1 to have semaphore support compiled in.
Dependent of your configuration, this function can be defined as macro to decrease code size.
See also:
nosSemaWait, nosSemaSignal, nosSemaCreate
NANOEXT VAR_t POSCALL nosSemaSignal ( NOSSEMA_t  sema)

Semaphore function. This function signalizes a semaphore object, that means it increments the semaphore counter and sets tasks pending on the semaphore to running state, when the counter reaches a positive, nonzero value.

Parameters:
semahandle to the semaphore object.
Returns:
zero on success.
Note:
NOSCFG_FEATURE_SEMAPHORES must be defined to 1 to have semaphore support compiled in.
Dependent of your configuration, this function can be defined as macro to decrease code size.
See also:
nosSemaGet, nosSemaWait, nosSemaCreate
NANOEXT VAR_t POSCALL nosSemaWait ( NOSSEMA_t  sema,
UINT_t  timeoutticks 
)

Semaphore function. This function tries to get the semaphore object. If the semaphore is in nonsignalized state (that means its counter is zero or less), this function blocks the task execution until the semaphore gets signaled or a timeout happens.

Parameters:
semahandle to the semaphore object.
timeouttickstimeout in timer ticks (see HZ define and MS macro). If this parameter is set to zero, the function immediately returns. If this parameter is set to INFINITE, the function will never time out.
Returns:
zero on success. A positive value (1 or TRUE) is returned when the timeout was reached.
Note:
NOSCFG_FEATURE_SEMAPHORES must be defined to 1 to have semaphore support compiled in.
POSCFG_FEATURE_SEMAWAIT must be defined to 1 to have this function compiled in.
Dependent of your configuration, this function can be defined as macro to decrease code size.
See also:
nosSemaGet, nosSemaSignal, nosSemaCreate, HZ, MS