The ChorusOS operating system provides the following services to support multithreaded programming:
SEM feature provides semaphore synchronization objects. A semaphore is an integer counter and an associated thread wait queue. When initialized, the semaphore counter receives a user-defined positive or null value.
Two main atomic operations are available on semaphores: P (or pass) and V (or free).
The counter is decremented when a thread performs a P on a semaphore. If the counter reaches a negative value, the thread is blocked and put in the semaphore's queue, otherwise, the thread continues its execution normally.
The counter is incremented when a thread performs a V on a semaphore. If the counter is still lower than or equal to zero, one of the threads queued in the semaphore queue is picked up and awakened.
Semaphores are data structures allocated in the actors' address spaces. No kernel data structure is allocated for these objects. They are simply designated by the address of the structures. The number of these types of objects that threads may use is therefore unlimited.
For more details, see SEM(5FEA).
EVENT feature provides the management of event flag sets.
An event flag set is a set of bits in memory that is associated with a thread wait queue. Each bit is associated with one event. Event flag sets are data structures allocated in the actors' address spaces. No kernel data structure is allocated for these objects. They are simply designated by the address of the structures. The number of these types of objects that threads may use is therefore unlimited.
When a flag is set, it is said to be posted, and the associated event is considered to have occurred. Otherwise the associated event has not yet occurred. Both threads and interrupt handlers can use event flag sets for signaling purposes.
A thread can wait on a conjunctive (and) or disjunctive (or) subset of the events in one event flags set. Several threads may be pending on the same event. In that case, each of the threads will be made eligible to run when the event occurs.
For more details, see EVENT(5FEA).
RTMUTEX feature provides mutual exclusion locks, using a priority inheritance protocol, in order to avoid thread priority inversion problems.
For more details, see RTMUTEX(5FEA).