-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 04.11.2013 20:19, Edscott Wilson wrote:
> Well I did my testing of semaphores to release a windows version
> of libtubo (http://xffm.org/libtubo.html) and these are my two
> cents.
> 
> 1- Shared semaphores (shared between heavy weight processes). In 
> Linux, a shared semaphore must be placed in shared memory. This is 
> easy, since the shm_ family of functions allow you to map any type 
> of pointer to shared memory. Windows, on the other hand, 
> CreateFileMapping for shared memory gives you a file descriptor 
> which is no good for mapping a POSIX semaphore. In any case, 
> Windows has its own CreateSemaphore function, which most probably 
> uses CreateFileMapping internally.
What CreateSemaphore() uses internally is anyone's guess. It might be
CreateFileMapping(), it might be not. If it goes into kernel side,
then it may as well use something more efficient there.
libwinpthreads uses CreateSemaphore() internally, so if you'd use the
semaphore API that winpthreads provides you with, it might just work.
This is basically a recap of my original message.
If winpthreads shared semaphores didn't work for you (i.e. they
weren't shared as you hoped they would be), that's another matter
(maybe worth fixing, maybe not). From the paragraph above it's not
clear whether you tested them at all.

> 
> 2- Local semaphores (shared only between threads). Posix
> semaphores in Mingw seem to be subject to race conditions not
> present in Linux or FreeBSD. When I tried to use them in Windows,
> libtubo would crash. So I replaced these  semaphores with pthread
> conditions and things worked just fine.
Do you have any good backtraces? Testcases? If 'Posix semaphores in
Mingw' means 'winpthreads', then ktietz will be interested in
eliminating that race condition, i bet.

- -- 
O< ascii ribbon - stop html email! - www.asciiribbon.org
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (MingW32)

iQEcBAEBAgAGBQJSeHzyAAoJEOs4Jb6SI2Cw13oH/RAjp9epzf5pqB01fjcI62Wg
hi/KU/HDn82Orf6pr1+pF72lVqOdgxrZwPkjLNQVuJ2Hg/rESH1IOmtV+9C11o9Y
Ko5dsMNHvJbZzSCo22r1wncShk4u6i4ixwblzOx29zPw4L2oi4lVmBVPdfxbxE4v
9Yz05bTjW5mwV2V3yJ3/DBNtYwXnS9b+0Pe6mO7a0D36YtT2p73jRfx67+c9Qpja
MMaF4Kr1DQIE2UVD7j2naogOiQKsbLBngVjw/jEhC68Vr1IUzOo8cItX8HRoSaXZ
xNhX620tgdJNugKbizFUkW4dskhDHjohZgFl2HuNk0OW0fVZmV34bJ1viREA/Bs=
=kRNy
-----END PGP SIGNATURE-----

------------------------------------------------------------------------------
November Webinars for C, C++, Fortran Developers
Accelerate application performance with scalable programming models. Explore
techniques for threading, error checking, porting, and tuning. Get the most 
from the latest Intel processors and coprocessors. See abstracts and register
http://pubads.g.doubleclick.net/gampad/clk?id=60136231&iu=/4140/ostg.clktrk
_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to