µOS++ IIIe Reference  v6.3.15
“Perfekt ist nicht gut genug”
The third edition of µOS++, a POSIX inspired open source system, written in C++.

C++ API semaphores definitions. More...


class  os::rtos::semaphore::attributes
 Semaphore attributes. More...
class  os::rtos::semaphore::attributes_binary
 Binary semaphore attributes. More...
class  os::rtos::semaphore::attributes_counting
 Counting semaphore attributes. More...
class  os::rtos::semaphore
 POSIX compliant semaphore. More...
class  os::rtos::semaphore_binary
 POSIX compliant binary semaphore. More...
class  os::rtos::semaphore_counting
 POSIX compliant counting semaphore. More...


using os::rtos::semaphore::count_t = int16_t
 Type of semaphore counter storage. More...


static const attributes_binary os::rtos::semaphore::initializer_binary { 0 }
 Default binary semaphore initialiser. More...
static constexpr count_t os::rtos::semaphore::max_count_value = 0x7FFF
 Maximum semaphore value. More...

Detailed Description

C++ API semaphores definitions.

os_main (int argc, char* argv[])
// Binary semaphore.
semaphore_binary sp1;
sp1.post ();
// Named binary semaphore.
semaphore_binary sp2
{ "sp2" };
sp2.post ();
sp2.wait ();
sp2.post ();
sp2.try_wait ();
sp2.post ();
sp2.timed_wait (1);
sp2.post ();
sp2.timed_wait (0xFFFFFFFF);
// Named counting semaphore.
semaphore_counting sp3
{ "sp3", 7 };
sp3.post ();
// Named counting semaphore with custom initial value.
semaphore_counting sp4
{ "sp4", 7, 7 };
sp4.post ();


◆ count_t

Type of semaphore counter storage.

A numeric value enough to hold the semaphore counter, usually a 16-bits signed value.

Definition at line 64 of file os-semaphore.h.

Variable Documentation

◆ initializer_binary

const semaphore::attributes_binary os::rtos::semaphore::initializer_binary { 0 }

Default binary semaphore initialiser.

This variable is used by the default constructor.

Definition at line 202 of file os-semaphore.h.

◆ max_count_value

constexpr count_t os::rtos::semaphore::max_count_value = 0x7FFF

Maximum semaphore value.

Used to validate the semaphore initial count and max count.

Definition at line 72 of file os-semaphore.h.