Hello you all, I want to give for this discussion my 2 cents for it too.
2015-03-14 23:34 GMT+01:00 K. Frank <[email protected]>: > Historically, I think the following considerations entered into mingw-w64's > choices for implementing std::thread: > > 1) Support for pre-Vista rules out using windows CONDITION_VARIABLES. > > 2) Although not part of standard C++ (nor C), and not part of windows, > pthreads is the posix standard, and therefore important to support. It > therefore makes sense to build std::thread on top of pthreads (avoiding > duplicative effort and easing mixing of pthreads code with std::thread code), > although this is not a firm requirement. > > 3) Licensing concerns and the the fact that an integral value is the de > facto standard (but not part of the posix requirement) for a pthreads handle > led to the development of winpthreads. All three points are as I recall them. I want to give just some words about using semaphores instead of criticial-sections. While implementing winpthread, we had initially tried to use critical-sections (cs) for mutexes in general. This doesn't work pretty well, as the only POSIX-mutex variant compatible to the cs are the recursive-mutexes. Another disadvantage of cs are that foreign threads can't release a cs for a different thread. So it is hard to implement the asynchrone termination based on critical-sections, and doing proper cleanup after that. That we had choosen semaphores over system-mutexes is that under the hood system-mutexes are semaphores, so we tried to avoid additional overhead. It might be possible that we can special-case for recursive-mutexes in some cases via cs, but general implementation would still need to fallback in cases for conditional-variables, and barriers back to use of semaphores AFAICS. Kai ------------------------------------------------------------------------------ Dive into the World of Parallel Programming The Go Parallel Website, sponsored by Intel and developed in partnership with Slashdot Media, is your hub for all things parallel software development, from weekly thought leadership blogs to news, videos, case studies, tutorials and more. Take a look and join the conversation now. http://goparallel.sourceforge.net/ _______________________________________________ Mingw-w64-public mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/mingw-w64-public
