[fpc-pascal] Semaphore problems

Burkhard Carstens fpc at bcsoft.de
Mon Jul 24 16:57:14 CEST 2006


Am Montag, 24. Juli 2006 16:19 schrieb Vinzent Hoefler:
> On Monday 24 July 2006 14:09, Michael Van Canneyt wrote:
> > On Mon, 24 Jul 2006, Vinzent Hoefler wrote:
> > > On Monday 24 July 2006 13:34, Marco van de Voort wrote:
> > >>> When I run the Unit Tests and create a single Lock and the
> > >>> Unlock it, all works fine.  If I then iterrate that test by
> > >>> creating 10 locks and then call unlock 10 times, the Unit Tests
> > >>> freeze on the following line with the second iteration:
> > >>
> > >> Sounds like some recursion property is not set.
> > >
> > > I don't think, semaphores have recursion properties.
> >
> > They do, in some implementations.
>
> Ok, granted. :) But not in POSIX, AFAICS.
>
> And they were never designed that way. I think, that's why someone
> invented the mutex. ;)

hmm, so a mutex can be recursive, if the type is set correctly, which is 
not supportet on all platforms implementing pthread (man-pages of 
pthread). 

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.

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
- same goes for rtlbasicevent (cthreads)
- the rtlEvent works even with timeout (with my patch posted on mantis), 
but this one clears the signaled state, when wait is called. IOW. if I 
call waitfor on the allready signalled event, it won't return before 
timeout. Also it doesn't inform the caller, wheter it returnt due to 
signalled or to timeout ..

regards
 Burkhard




More information about the fpc-pascal mailing list