[riot-devel] Condition Variables

Martin martin.landsmann at haw-hamburg.de
Wed Aug 17 19:03:01 CEST 2016


Hi Sam,


in its core RIOT only provides a small and efficient mutex implementation.

Condition variables are provided within the POSIX wrapper [1], 
specifically in the the pthread part [2].

To get an idea how use the provided condition variables you can have a 
look in our tests for it [3].

But as Simon stated you should consider if using the Message passing 
possibilities of RIOT could have the desired effect,

since using the POSIX condition variables in RIOT also comes with a 
certain overhead.


Best regards,

Martin

[1] http://riot-os.org/api/group__posix.html
[2] http://riot-os.org/api/group__pthread.html
[3] 
https://github.com/RIOT-OS/RIOT/tree/master/tests/pthread_condition_variable

Am 08/17/2016 um 11:21 AM schrieb Simon Brummer:
> Dear fellow TCP implementor,
>
> The common way implement something like this in RIOT is Message
> passing. Your thread simply blocks by calling msg_receive() until it
> received a message from another thread. As soon as you receive a
> Packet, send a message to the via msg_send() function to wake the
> blocked thread.
>
> Cheers
>     Simon Brummer
>
> Am Dienstag, den 16.08.2016, 12:49 -0700 schrieb Sam Kumar:
>> Hello,
>> I was looking at the synchronization primitives in RIOT OS. I noticed
>> that there is a mutex implementation, but I was unable to find a
>> condition variable.
>>
>> I am currently porting the TCP logic from the FreeBSD operating
>> system to RIOT as part of the research work I am doing. I am
>> implementing the "conn" API for TCP, and I need to be able to block
>> the current thread until a packet is received, to implement some of
>> the functions.
>>
>> I read the IPC implementation (msg.c), which also has a blocking API,
>> and saw that it interacts with the scheduler manually in order to
>> block and resume threads. Before I did the same thing for the conn
>> API (or perhaps implement/contribute my own condition variable), I
>> wanted to ask whether there are condition variables for RIOT, in case
>> I was just looking in the wrong place. If not, I want to learn if
>> there is another structured way to block a thread until an event,
>> that I should use instead.
>>
>> Thanks,
>> Sam Kumar
>> _______________________________________________
>> devel mailing list
>> devel at riot-os.org
>> https://lists.riot-os.org/mailman/listinfo/devel
> _______________________________________________
> devel mailing list
> devel at riot-os.org
> https://lists.riot-os.org/mailman/listinfo/devel



More information about the devel mailing list