Semaphore

RTOS semaphore functions. More...

Functions

gos_result_t gos_rtos_semaphore_init (gos_semaphore_t *semaphore)
 Initializes a semaphore. More...
 
gos_result_t gos_rtos_semaphore_deinit (gos_semaphore_t *semaphore)
 De-initialise a semaphore. More...
 
gos_result_t gos_rtos_semaphore_set (gos_semaphore_t *semaphore)
 Set (post/put/increment) a semaphore. More...
 
gos_result_t gos_rtos_semaphore_get (gos_semaphore_t *semaphore, uint32_t timeout_ms)
 Get (wait/decrement) a semaphore. More...
 
void gos_rtos_semaphore_reset (gos_semaphore_t *semaphore)
 Set counting semaphore to zero. More...
 
gos_result_t gos_rtos_semaphore_get_count (const gos_semaphore_t *semaphore, int32_t *count_ptr)
 Get the current count of a semaphore. More...
 

Detailed Description

RTOS semaphore functions.

Function Documentation

◆ gos_rtos_semaphore_deinit()

gos_result_t gos_rtos_semaphore_deinit ( gos_semaphore_t *  semaphore)

De-initialise a semaphore.

Deletes a semaphore created with gos_rtos_semaphore_init()

Parameters
semaphore: Pointer to the semaphore handle
Returns
GOS_SUCCESS : on success.
GOS_ERROR : if an error occurred

◆ gos_rtos_semaphore_get()

gos_result_t gos_rtos_semaphore_get ( gos_semaphore_t *  semaphore,
uint32_t  timeout_ms 
)

Get (wait/decrement) a semaphore.

Attempts to get (wait/decrement) a semaphore. If semaphore is at zero already, then the calling thread will be suspended until another thread sets the semaphore with gos_rtos_semaphore_set()

Note
The provided semaphore should have been previously initialized with gos_rtos_semaphore_init().
Parameters
[in]semaphore: Pointer to the semaphore handle
[in]timeout_ms: Number of milliseconds to wait before returning
Returns
Result of API call, gos_result_t
Examples:
demo/uart_blaster/uart_blaster.c.

◆ gos_rtos_semaphore_get_count()

gos_result_t gos_rtos_semaphore_get_count ( const gos_semaphore_t *  semaphore,
int32_t *  count_ptr 
)

Get the current count of a semaphore.

This returns the current 'count' of the given semaphore. The count has the following meanings:

Note
The provided semaphore should have been previously initialized with gos_rtos_semaphore_init().
Parameters
[in]semaphore: Pointer to the semaphore handle
[out]count_ptr: Pointer to hold the semaphore's current count
Returns
Result of API call, gos_result_t

◆ gos_rtos_semaphore_init()

gos_result_t gos_rtos_semaphore_init ( gos_semaphore_t *  semaphore)

Initializes a semaphore.

Initializes a counting semaphore

When this semaphore is no longer needed, gos_rtos_semaphore_deinit() should be called to clean it up.

Parameters
[in]semaphore: Pointer to the semaphore handle to be initialised
Returns
Result of API call, gos_result_t
Examples:
demo/uart_blaster/uart_blaster.c.

◆ gos_rtos_semaphore_reset()

void gos_rtos_semaphore_reset ( gos_semaphore_t *  semaphore)

Set counting semaphore to zero.

Reset the semaphore's counter to zero. Any tasks blocking on the semaphore will automatically be unblocked.

Note
The provided semaphore should have been previously initialized with gos_rtos_semaphore_init().
Parameters
[in]semaphore: Pointer to the semaphore handle
Returns
Result of API call, gos_result_t
Examples:
demo/uart_blaster/uart_blaster.c.

◆ gos_rtos_semaphore_set()

gos_result_t gos_rtos_semaphore_set ( gos_semaphore_t *  semaphore)

Set (post/put/increment) a semaphore.

Set (post/put/increment) a semaphore

Note
The provided semaphore should have been previously initialized with gos_rtos_semaphore_init().
Parameters
[in]semaphore: Pointer to the semaphore handle to be set
Returns
Result of API call, gos_result_t
Examples:
demo/uart_blaster/uart_blaster.c.