[En-Nut-Discussion] Handling of condition variables broken?

Ole Reinhardt ole.reinhardt at embedded-it.de
Tue Jan 1 21:51:39 CET 2013


Hi Philipp,

A happy new year!

> today I needed to do some thread synchronization, which I'd liked to do 
> using a condition variable. But there are a few problems with this. 
> First, have a look at the implementation of the init function:
> [...]
> this will not work. NutHeapAlloc() may happily allocate memory and store 
> it into cond, but there is no way to find out where the memory region is 
> located. Either it should be returned as a pointer or the function must 
> take a double pointer as argument.

Yes! Thanks! Looks like we got in this bug in r2648.

> Then there's NutConditionTimedWait() which advertises its return value 
> as "0 on success, -1 on error or timeout". But:
> [...]
> A timeout will never cause the function to return -1. Additionally, this 
> function is missing in the header file <sys/condition.h>. The example in 
> the doxygen doc is also extremely outdated.
> [...]
> Could it be that there has been the idea to restructure some of this 
> module but it was never finished?

Yes, I implemented the condition variables long time ago, but I think
that not many developers ever used it, but some modifications had been
implemented but not well tested as it seems.

> Anyway, I'll change my code to use bare event queues instead. But this 
> code should either be corrected or removed.

I will correct it the next days!

Thanks for reporting!

Best regards,

Ole





More information about the En-Nut-Discussion mailing list