[fpc-pascal] Semaphore problems

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


Hi,

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

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

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?

Regards,
  Graeme.

-- 
There's no place like 127.0.0.1



More information about the fpc-pascal mailing list