[fpc-pascal] Semaphore problems

Graeme Geldenhuys graemeg.lists at gmail.com
Mon Jul 24 12:05:25 CEST 2006


I am having troubles with porting Semaphores in a project under Linux.
 Under Windows everything works fine, but under Linux my app keeps

The project is tiOPF v2 (TechInsite Object Persistent Framework).
There is a class called TtiPool, that handles a pool of database

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:

  if sem_wait(FSemaphore) <> 0 then
    raise EtiOPFInternalException.Create(cErrorTimedOutWaitingForSemaphore);

* Under Linux, I am using the "pthreads" unit.  What is the difference
between the cthreads and pthreads unit?
* The calls I am using from pthreads are:
  * sem_init() to create a semaphore
  * sem_wait() to lock the semaphore
  * sem_post() to unlock the semaphore
  All the above with a variable of type TSemaphore.

Now, I have to admit, I don't know much about Semaphore's... Anybody
know of some good documentation or tutorial on the net?
Anything obvious I could be doing wrong?


There's no place like

More information about the fpc-pascal mailing list