Subj : Re: Futexes are wrong! (Are they?) To : comp.programming.threads From : Jomu Date : Mon Jun 06 2005 01:08 pm Marcin 'Qrczak' Kowalczyk wrote: > "Jomu" writes: > > > As consumer-producer message queues are (for me, probably elsewhere > > also) most frequent sync devices, and their problem with preemptive > > signaling happens mostly (maybe only) when one thread signals while > > holding mutex (same one waiting thread will try to reacquire when > > signaled) then why don't rearrange signaling so that it happens > > after mutex is freed? > > I guess it will work in this case. > > Unfortunately in the case I have pthread_cond_{broadcast,signal} > is followed by pthread_cond_wait, so I can't move signalling after > unlocking and additional context switches are pointless. You have code sample of this? > > BTW, is it better to use pthread_cond_broadcast or pthread_cond_signal > when I know that only one thread is waiting? As preempting happens in any case, I see no reason for difference. Only reason for broadcast would be if more than one thread fullfils can-work after event whose completion you signal. > > -- > __("< Marcin Kowalczyk > \__/ qrczak@knm.org.pl > ^^ http://qrnik.knm.org.pl/~qrczak/ .