sem.h File Reference
#include "pico/lock_core.h"
Include dependency graph for sem.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  semaphore
 

Typedefs

typedef struct __packed_aligned semaphore semaphore_t
 

Functions

void sem_init (semaphore_t *sem, int16_t initial_permits, int16_t max_permits)
 Initialise a semaphore structure. More...
 
int sem_available (semaphore_t *sem)
 Return number of available permits on the semaphore. More...
 
bool sem_release (semaphore_t *sem)
 Release a permit on a semaphoreIncreases the number of permits by one (unless the number of permits is already at the maximum). A blocked sem_acquire will be released if the number of permits is increased. More...
 
void sem_reset (semaphore_t *sem, int16_t permits)
 Reset semaphore to a specific number of available permitsReset value should be from 0 to the max_permits specified in the init function. More...
 
void sem_acquire_blocking (semaphore_t *sem)
 Acquire a permit from the semaphoreThis function will block and wait if no permits are available. More...
 
bool sem_acquire_timeout_ms (semaphore_t *sem, uint32_t timeout_ms)
 Acquire a permit from a semaphore, with timeoutThis function will block and wait if no permits are available, until the defined timeout has been reached. If the timeout is reached the function will return false, otherwise it will return true. More...
 
bool sem_acquire_timeout_us (semaphore_t *sem, uint32_t timeout_us)
 Acquire a permit from a semaphore, with timeoutThis function will block and wait if no permits are available, until the defined timeout has been reached. If the timeout is reached the function will return false, otherwise it will return true. More...
 
bool sem_acquire_block_until (semaphore_t *sem, absolute_time_t until)
 Wait to acquire a permit from a semaphore until a specific timeThis function will block and wait if no permits are available, until the specified timeout time. If the timeout is reached the function will return false, otherwise it will return true. More...
 
bool sem_try_acquire (semaphore_t *sem)
 Attempt to acquire a permit from a semaphore without blockingThis function will return false without blocking if no permits are available, otherwise it will acquire a permit and return true. More...