[fpc-pascal] Semaphore problems
JeLlyFish.software at gmx.net
Mon Jul 24 17:27:03 CEST 2006
On Monday 24 July 2006 14:57, Burkhard Carstens wrote:
> I vote for more pascal based versions of TMutex, TSemaphore and
> TEvent, that behaves just like the ones in Delphi and use the system
> specific functions (like pthread stuff) only internally in their
> simplest/most portable form.
I'd vote for a more abstract version. :) The more or less basic things
needed in multi-threaded programing are
- persistent signal
- transient signal ("pulse")
There's some more higher level stuff (like broadcasts, for example), but
that's about all you usually need. Currently we have the semaphore
(more or less as SyncObjs.tCriticalSection), the persistent and the
transient signal (SyncObjs.tEvent), although without timeouts (at least
when trying to be portable), the event is somewhat implemented, but
IIRC it misses a "Toggle" property, which can be used for simple
intertask communication ("Now I'm blocking, you're on.").
> Currently, I have the problem to get a working TEvent:
> - The one in syncobjs returns wrError, when it's waitfor is called
> with anything else tah infinite timeout
Yes, that's not implemented, although it should be easily added by using
condition variables of pthreads.
> - the rtlEvent works even with timeout (with my patch posted on
> mantis), but this one clears the signaled state, when wait is called.
*oh* Before the wait? That's not good. This cries for race conditions
and subtle deadlock situations.
More information about the fpc-pascal