Hi,

I found another problem with Semaphores between FreeBSD and Linux.

Attached is my test project. Again, it is similar code used in tiOPF.

For some reason under FreeBSD, it *always* zeros the variable that holds
the Max Pool Size value passed in to sem_init()'s third parameter. This
means that if I try and us that variable anywhere after the sem_init()
call, like when I want to destroy the semaphore, I can't because the
variable now holds the value 0.

Here is an example of the test program's output. Not the value of
FMaxPoolSize before and after sem_init() call. Also note the value of i
- no destruction code (sem_post) is executed.

---------[ output under Linux ]---------------
$ ./project1
FMaxPoolSize before = 2
FMaxPoolSize after = 0
c = 2
Now create a lock
c = 1
Now create a lock
c = 0
i = 0
-----------------------------------------------

And here is that exact same test project under Linux. Note the
FMaxPoolSize variable still has the original value after the sem_init()
call - as expected. Also the i variable increments as we unlock the
semaphore.


---------[ output under Linux ]---------------
$ ./project1
FMaxPoolSize before = 2
FMaxPoolSize after = 2
c = 2
Now create a lock
c = 1
Now create a lock
c = 0
i = 0
unlock a semaphore
i = 1
unlock a semaphore
i = 2
-----------------------------------------------


Any idea why FreeBSD does this? A bug in FPC+FreeBSD?


Regards,
  - Graeme -

-- 
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/

Attachment: semp_test.tar.gz
Description: GNU Zip compressed data

_______________________________________________
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel

Reply via email to