ChibiOS/RT
5.1.0
|
Binary semaphores structures and macros. More...
Go to the source code of this file.
Data Structures | |
struct | ch_binary_semaphore |
Binary semaphore type. More... | |
Macros | |
#define | _BSEMAPHORE_DATA(name, taken) {_SEMAPHORE_DATA(name.sem, ((taken) ? 0 : 1))} |
Data part of a static semaphore initializer. More... | |
#define | BSEMAPHORE_DECL(name, taken) binary_semaphore_t name = _BSEMAPHORE_DATA(name, taken) |
Static semaphore initializer. More... | |
Typedefs | |
typedef struct ch_binary_semaphore | binary_semaphore_t |
Binary semaphore type. More... | |
Functions | |
static void | chBSemObjectInit (binary_semaphore_t *bsp, bool taken) |
Initializes a binary semaphore. More... | |
static msg_t | chBSemWait (binary_semaphore_t *bsp) |
Wait operation on the binary semaphore. More... | |
static msg_t | chBSemWaitS (binary_semaphore_t *bsp) |
Wait operation on the binary semaphore. More... | |
static msg_t | chBSemWaitTimeoutS (binary_semaphore_t *bsp, sysinterval_t timeout) |
Wait operation on the binary semaphore. More... | |
static msg_t | chBSemWaitTimeout (binary_semaphore_t *bsp, sysinterval_t timeout) |
Wait operation on the binary semaphore. More... | |
static void | chBSemResetI (binary_semaphore_t *bsp, bool taken) |
Reset operation on the binary semaphore. More... | |
static void | chBSemReset (binary_semaphore_t *bsp, bool taken) |
Reset operation on the binary semaphore. More... | |
static void | chBSemSignalI (binary_semaphore_t *bsp) |
Performs a signal operation on a binary semaphore. More... | |
static void | chBSemSignal (binary_semaphore_t *bsp) |
Performs a signal operation on a binary semaphore. More... | |
static bool | chBSemGetStateI (const binary_semaphore_t *bsp) |
Returns the binary semaphore current state. More... | |
Binary semaphores structures and macros.
Binary semaphores related APIs and services.
Binary semaphores are implemented as a set of inline functions that use the existing counting semaphores primitives. The difference between counting and binary semaphores is that the counter of binary semaphores is not allowed to grow above the value 1. Repeated signal operation are ignored. A binary semaphore can thus have only two defined states:
Binary semaphores are different from mutexes because there is no concept of ownership, a binary semaphore can be taken by a thread and signaled by another thread or an interrupt handler, mutexes can only be taken and released by the same thread. Another difference is that binary semaphores, unlike mutexes, do not implement the priority inheritance protocol.
In order to use the binary semaphores APIs the CH_CFG_USE_SEMAPHORES
option must be enabled in chconf.h
.
Definition in file chbsem.h.