I’ve been using FreeRTOS to implement a project that would be significantly easier to complete with conditional variables. Has anyone implemented this with FreeRTOS or is there already support for it that I missed?
The reply can be the same as the last unanswered reply, expect we can
add direct to task notifications and event groups to the previous
mentions of semaphores and mutexes. Really though, can’t answer the
question unless somebody says what they are trying to achieve - the last
time this was asked was six years ago.
I took a stab at an implementation, posted here based on this paper from MS Research. (It won’t run yet, lets call it a reference for now : ) ), it is bascially the C# code from the WIN32 section at the end of the paper ported to c++. According to the MS paper, this method can work however, on OS that do not provide an atomic “unlock this primative while locking this other primative”.
For me at least, I would like to provide a mostly C++11 compliant thread primatives implemented on FreeRTOS. I find the CV style useful when writing certain kinds of code, and would like to keep using it. I have also wanted to implement pthreads for freertos, which also needs a CV primative.
The paper was very interesting. If there was a way to atomically unlock & lock two objects, or unlock an object & suspend a task, or unlock a lock and enqueue built into the kernal/task API this would be a lot easier (and higher performance). Unlock mutex / suspend task might be easiest.
There are some issues using a waiter-LIFO, like I implemented, in an RTOS setting. Perhaps sorting by priority on enqueue would be required, otherwise there could be a priority inversion.