Ah, right. I missed that we provide here semaphore-API, too. I wouldn't call that API posix ... but yes, this is a bare-layer to be used carefully ... we implement in winpthread nearly all more complex stuff based on the sem-API.
2013/11/4 Edscott Wilson <[email protected]>: > 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_". Well, on Windows there is even a third API, CreateSemaphore, WaitForSingleObject, etc ... > 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. That is not 100% correct. pthread-stuff can be used within none-pthread-created threads, too. Of course those none-pthread threads are treated like detached ones by default. > 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. Sure. > HTH > Thanks, 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 [email protected] https://lists.sourceforge.net/lists/listinfo/mingw-w64-public
