@web-font-path: "roboto-debian.css";
v2.2.0 (RP2040)
Loading...
Searching...
No Matches
sem.h
Go to the documentation of this file.
/*
* Copyright (c) 2020 Raspberry Pi (Trading) Ltd.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#ifndef _PICO_SEM_H
#define _PICO_SEM_H
#include "pico/lock_core.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef struct semaphore {
struct lock_core core;
int16_t permits;
int16_t max_permits;
} semaphore_t;
void sem_init(semaphore_t *sem, int16_t initial_permits, int16_t max_permits);
int sem_available(semaphore_t *sem);
bool sem_release(semaphore_t *sem);
void sem_reset(semaphore_t *sem, int16_t permits);
void sem_acquire_blocking(semaphore_t *sem);
bool sem_acquire_timeout_ms(semaphore_t *sem, uint32_t timeout_ms);
bool sem_acquire_timeout_us(semaphore_t *sem, uint32_t timeout_us);
bool sem_acquire_block_until(semaphore_t *sem, absolute_time_t until);
bool sem_try_acquire(semaphore_t *sem);
#ifdef __cplusplus
}
#endif
#endif
sem_acquire_timeout_us
bool sem_acquire_timeout_us(semaphore_t *sem, uint32_t timeout_us)
Acquire a permit from a semaphore, with timeout.
sem_try_acquire
bool sem_try_acquire(semaphore_t *sem)
Attempt to acquire a permit from a semaphore without blocking.
sem_acquire_timeout_ms
bool sem_acquire_timeout_ms(semaphore_t *sem, uint32_t timeout_ms)
Acquire a permit from a semaphore, with timeout.
sem_acquire_block_until
bool sem_acquire_block_until(semaphore_t *sem, absolute_time_t until)
Wait to acquire a permit from a semaphore until a specific time.
sem_init
void sem_init(semaphore_t *sem, int16_t initial_permits, int16_t max_permits)
Initialise a semaphore structure.
Definition sem.c:10
sem_reset
void sem_reset(semaphore_t *sem, int16_t permits)
Reset semaphore to a specific number of available permits.
sem_available
int sem_available(semaphore_t *sem)
Return number of available permits on the semaphore.
sem_release
bool sem_release(semaphore_t *sem)
Release a permit on a semaphore.
sem_acquire_blocking
void sem_acquire_blocking(semaphore_t *sem)
Acquire a permit from the semaphore.
absolute_time_t
uint64_t absolute_time_t
An opaque 64 bit timestamp in microseconds.
Definition types.h:43
lock_core.h
lock_core
Definition lock_core.h:53
semaphore
Definition sem.h:31