Simple POSIX Semaphore Library for Windows

dandenongs 1889

I had a recent need to control access of one of my programs to a hardware device – basically the hardware can only handle a certain number of simultaneous connections before it starts returning garbage. POSIX semaphores are a really elegant way of handling this as you just create a semaphore and then put a semi_wait call before every critical code section and a sem_post call at the end of the critical code. This way you can control the number of simultaneous calls of the critical code no matter how many parallel processes or threads are running.

The only problem with POSIX semaphores is they are not natively supported on Windows (Windows has a entirely different semaphore system). Since my program is cross-platform I wanted a simple Windows-compatible POSIX semaphore library I could just drop in on my Windows builds and avoid a whole series of #ifdef #else conditionals. I managed to find a full Windows POSIX thread library (libpthread), but it was way more complex than what I needed and it does not build on Windows XP (I unfortunately still need to support Windows XP/2003). I was able to use the library as a starting point for making a very simple POSIX semaphore library. My cut-down library provides a simple drop in replacement for all the POSIX semaphore functions on Windows and just requires the inclusion of the header file in any project you might want to use it in. It is not identical to semaphores on linux, but it does the job.

You can download the simple windows semaphore library from my github repository. I hope it is of help for someone else.

La Boheme Act Four Syrah Gamay 2014

I am always a sucker for new things and wine is no exceptions. If I see an unusual bottle, grape variety, or blend then I am more likely than not to take the risk and buy it. I noticed the La Boheme Act Four Syrah Gamay 2014 on one of the bottom shelves at Dan Murphys and I thought to myself that I had never seen such a blend before (Gamay is the grape variety used in Beaujolais). I stopped to think what this would actually taste like and wondered if it was going to be some sort of strange lolly water. Since the bottle was only around $15 I thought I would take the chance and see what it was like and I am glad I did. It is a rather good blend that brings out the best of both grapes with the strengths of each variety complement the weaknesses of the other. The end result is certainly unusual, but it fills the role of a good food pinot at a price point much lower. I would say it was worth the try.

act4

Price. $15
Value. $25

Edit. I see the price has gone up quite a lot (must be getting some attention) and is now selling for $22 a bottle at Dan Murphys.