Attached you will find code to make semaphores (as defined in <semaphore.h>
work in a way that is compatible with Linux/FreeBSD. This code includes
both named and unnamed semaphores and a working sem_getvalue function (read
Linux man page before using sem_getvalue()).

To use the code, do not include <semaphore.h> in your code, instead "sem.h".

I have prepared it so that with a small patch it can replace the semaphore
code in libwinpthread-1.dll, but don't do this just yet. The code in
barrier.c should be fixed first. The size of sem_t must be available to
programs which include <semaphore.h> since sem_init() should *not*
malloc(). If there is any interest in switching semaphore code to a
compatible usage with Linux/BSD I could work up a patch for barrier.c.

Example usage for semaphores can be found at
https://sourceforge.net/p/xffm/tubo/ci/master/tree/ and will be included in
release 5.0.13.

sem.h:
https://sourceforge.net/p/xffm/tubo/ci/master/tree/src/sem.h

sem.c:
https://sourceforge.net/p/xffm/tubo/ci/master/tree/src/sem.c

In order to debug concurrent threads, trace and error printing is available
with a couple macros defined in this file:
debug.h:
https://sourceforge.net/p/xffm/tubo/ci/master/tree/debug.h

Enjoy.


-- 
------------------------------------------------------------------------------------
Dr. Edscott Wilson Garcia
Applied Mathematics and Computing
Mexican Petroleum Institute
------------------------------------------------------------------------------
Rapidly troubleshoot problems before they affect your business. Most IT 
organizations don't have a clear picture of how application performance 
affects their revenue. With AppDynamics, you get 100% visibility into your 
Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!
http://pubads.g.doubleclick.net/gampad/clk?id=84349351&iu=/4140/ostg.clktrk
_______________________________________________
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to