As I understand it, all it takes to get a POSIX semaphore in windows is to
include <semaphore.h> and link with -lpthread.  Windows semaphores are
defined in <windows.h>. Since POSIX semaphores are in libpthread, they
would be "pthread" semaphores. Nonetheless, I think they have a different
flavor. The bulk of pthread functionality is namespaced with a "pthread_",
while semaphore functions are namespaced with "sem_".
.
Pthread_ stuff applies only to threads, created with pthread_create. While
semaphores may apply to independent processes.  As far as I recall,
semaphores require interaction with the kernel, while pthread stuff is
contained within the running program. Thus, semaphores are slower.

Back in the stone age, semaphores were *not* a part of the pthread library,
and each vendor provided his own library. This was before the days when
Linux took over the supercomputers and each vendor prepared a proprietary
BSD based OS for his hardware. This takes us back to the point where
semaphores have to talk to the kernel. The windows kernel, IMHO, is not a
trustworthy kernel, so pthread conditions are a better option.

HTH



2013/11/4 Kai Tietz <ktiet...@googlemail.com>

> Hi Edscott,
>
> thanks for testing this.  I just have one small question about one
> paragraph.
>
> 2013/11/4 Edscott Wilson <edscott.wilson.gar...@gmail.com>:
> > 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.
>
> What is a Posix semaphore in Windows?  And what is its difference to
> pthread's semaphore?
> I might confused myself, but this paragraph puzzles me.  Thanks for
> more detailed description.
>
> Regards,
> Kai
>
>
> ------------------------------------------------------------------------------
> Android is increasing in popularity, but the open development platform that
> developers love is also attractive to malware creators. Download this white
> paper to learn more about secure code signing practices that can help keep
> Android apps secure.
> http://pubads.g.doubleclick.net/gampad/clk?id=65839951&iu=/4140/ostg.clktrk
> _______________________________________________
> Mingw-w64-public mailing list
> Mingw-w64-public@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/mingw-w64-public
>



-- 
------------------------------------------------------------------------------------
Dr. Edscott Wilson Garcia
Applied Mathematics and Computing
Mexican Petroleum Institute
------------------------------------------------------------------------------
Android is increasing in popularity, but the open development platform that
developers love is also attractive to malware creators. Download this white
paper to learn more about secure code signing practices that can help keep
Android apps secure.
http://pubads.g.doubleclick.net/gampad/clk?id=65839951&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