RTOS: Multiple Readers / Exclusive Writer implementation/API

Tool/software: TI-RTOS

Does the SysBios have any functionality that provides Read/Write Semaphores (or mutual exclusion), where there are multiple readers, but only one writer permitted ? 

Sample behavior


When a task takes a read/write semaphore in read mode, the behavior is different

from other semaphores. It does not provide exclusive access to a resource (does not

protect critical sections), and the semaphore may be concurrently held in read

mode by more than one task.


2 Replies

  • I'm not sure I'm getting the question. It sounds more like a broadcast. If that's the case, you could create a counting semaphore. Say there are N readers and 1 writer. The writer would post the semaphore N times to allow all the readers to unblock. Of course, there are some edge cases to worry about. For example what if one of the readers does not call pend? So the count would not go to zero (zero = not signaled).

    You could use an Event. Each reader would be assigned a bit in the Event. The writer would post an Event with N bits set (N = # of readers). Each reader would pend on it's unique bit in the mask. I like this approach more than the counting semaphore one since it avoids the case of a reader never pending.

    If these did not help, can you give a more concrete use case?

  • In reply to ToddMullanix:

    Did this get resolved?