Understanding key RTOS features and challenges
Several standard capabilities are included in most of the RTOS implementations that are in wide use today. Some of these features enable efficient communication among tasks in a manner consistent with real-time operation. While common, not all of the following features are universally available in all RTOSes.
Mutexes
A mutex, which stands for mutual exclusion, is a mechanism for managing access to a shared resource among tasks. A mutex is conceptually identical to a global variable that can be read and written by all tasks. The variable has the value 1
when the shared resource is free, and 0
when it is in use by a task. When a task needs to gain access to the resource, it reads the variable and, if it is free, with the value 1
, sets it to 0
to indicate the mutex is owned by a task. The task is then free to interact with the resource. When the interaction is complete, the task sets the mutex to 1
, thereby releasing ownership.
If...