Conditional Variables in FreeRTOS

Hello, 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?

Conditional Variables in FreeRTOS

Can you say what you want to achieve with the CV? It might be that you could use a binary semaphore or mutex to do the same
thing.

Conditional Variables in FreeRTOS

Any update on this? I’m looking to update an open source project that requires direct access to CV’s to be compatible with my FreeRTOS system.

Conditional Variables in FreeRTOS

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.

Conditional Variables in FreeRTOS

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.

Conditional Variables in FreeRTOS

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.