Semaphore implementation
c#, c++, implementation, semaphore
Solution
Are there any libraries out there that already implement this? For C++ there are multiple multithreading libraries, which provide Semaphore implementations:
- Posix
- Poco Thread
- Tiny Threads
Also, You can also implement Semaphores using Boost. Check this out.
Problem
I was wondering if there was a way to implement semaphore in C++ (or C#), any libraries that'd help. I tried using OpenMP but I had no way of actually blocking threads, instead I had to busy wait on 'em which lead to deadlocks if/when I hadn't enough number of threads. So First I'm looking for a some library that would let me block/spawn/kill my threads. Secondly, are there any libraries out there that already implement semaphores? And finally, when I was introduced to the context of semaphores I found it very useful (maybe I'm wrong?) but I don't see many libraries (if at all) implementing it. I'm familiar with OpenMP, looked around Intel's TBB, C# threads. But in none of these I don't see semaphores explicitly. So are semaphores not as practical as I think? Or is it that they're hard to implement? Or is it me not being aware? P.S. Can semaphores be implemented cross-platform? Since they're probably related to OS.