Users of real-time operating systems (RTOS) are familiar with the various kinds of semaphores they offer. Depending on which RTOS you choose, these may include counting semaphores, binary semaphores and mutex semaphores.
As the embedded software world transitions into the era of multi-core processing, these 3 “traditional” kinds of semaphores are being joined in a number of multi-core oriented operating systems by a fourth kind of semaphore: the multiple reader – writer lock. In this article, we will see how these new semaphores work, and which multi-core application problems are best solved using this special kind of semaphore.
The multiple readers-writers problem
A software design problem that is encountered more and more often when using multi-core processors, is the so-called “Multiple Readers – Writers” problem. This is a situation in which a large data area must be shared among multiple tasks. Clearly, when one task is writing into the data area, no other task should be writing into it at the same time.
And no other task should be reading from it at that time. This discipline could also be enforced by a “traditional” semaphore. But in the “Multiple Readers – Writers” problem, we would like to allow many tasks to read from the data area at the same time – at those times when no task is writing into it.
Traditional semaphores do not offer this flexibility, as they instead limit access to the data area to only one single reader task when there is no task writing. Thus, traditional semaphores are a less-than-optimal solution for the multiple readers – writer problem.
To read the full article, click here.