[LUAU] pthreads signaling question

Charles Lockhart lockhart at IfA.Hawaii.Edu
Thu Mar 10 23:05:28 PST 2005


Jim Thompson wrote:

> pthread_cond_broadcast() will (attempt) to waken *ALL* threads waiting 
> on that condition variable.   If there is more than one, they'll
> race, and the first one that gets past the mutex 'wins'.   
> pthread_cond_signal() will attempt to waken *one* thread (typically 
> the first
> thread waiting on the condition variable.)

What do you mean 'wins'?  Maybe I don't understand correctly, but if I 
have three threads waiting on a conditional, and I do a broadcast on 
that conditional, they should ALL wake up, right?  I mean, I don't see 
anything to indicate that there's any particular order, but they should 
all wake up.  right?  Wait, uh, yeah, that's even what it says in the 
man page.  Whereas pthread_cond_signal wakes up one thread, but if there 
are multiple threads waiting, there's no provision for determining which 
one.

> Perhaps you're just running into side-effects of the scheduler.  It 
> seems to work here (gentoo, 2.6.10 kernel).  See the code and output 
> below.
> (I'm not bragging on the code, it was quick-n-dirty.)

Ah, man, you're code worked on my machine too.  So I must be doing 
something screwy.  I guess I should be happy, because that means I can 
fix the bug.  On the other hand, that means I have to fix the bug.

> The Fedora Project officially ended support for Fedora Core 1 (FC1) on 
> September 20th, 2004.  FC3 was released November 8, 2004.
> Maybe you should run FC3 (which is current) .vs a release that is now 
> known as "Fedora Legacy".  (http://fedora.redhat.com/)

Yeah, that would be nice.  But some of the hardware we have in "the 
machine" currently only has drivers for the 2.4 kernel, and it's kind of 
late in the game to start porting and testing, and I am way too busy 
(and LAZY).  Probably on the next instrument.

Jim, you The Man, thank you very much for your time and feedback.

-Charles



More information about the LUAU mailing list