[fpc-devel] Threads and alot of crap

Micha Nelissen micha at neli.hopto.org
Tue Oct 17 12:03:42 CEST 2006


Jonas Maebe wrote:
>> By implication this means you need a mutex to protect against race 
>> conditions.
> 
> Not necessarily, it is at least possible to implement an atomic linked 
> list without requiring a mutex-style lock.

That's irrelevant. If thread 1 lets thread 2 do something, and thread 2 
would signal thread 1 after completion, then thread 1 might not have 
started to wait yet (descheduled just before cond_wait). Could happen 
for example with TThread.Synchronize.

Windows events do not have this problem since they are stateful. In 
hindsight, a semaphore might have been a better emulation of an 'Event' 
(although I've not thought this through completely), but at the time 
condition variables seemed to be the logical way to go.

Micha



More information about the fpc-devel mailing list