Strategies for Implementing POSIX Condition Variables on Win32


This article illustrates why developing condition variables on Win32 platforms is tricky and error-prone. There are several subtle design forces that must be addressed by developers. In general, the different implementations we've examined vary according to their correctness, efficiency, fairness, and portability. No one solution provides all these qualities optimally.

The SignalObjectsAndWait solution in Section 3.4 is a good approach if fairness is paramount. However, this approach is not as efficient as other solutions, nor is it as portable. Therefore, if efficiency or portability are more important than fairness, the SetEvent approach described in Section 3.2 may be more suitable. Naturally, the easiest solution would be for Microsoft to simply provide condition variables in the Win32 API.

The C++ source code for POSIX condition variable on Win32 described in this article is freely available with the ACE framework at //www.cs.wustl.edu/~schmidt/ACE.html.

http://www.cse.wustl.edu/~schmidt/win32-cv-1.html
http://stackoverflow.com/questions/1218716/implementing-condition-variables-for-critical-sections-for-winthreads-for-xp
http://msdn.microsoft.com/en-us/library/windows/desktop/ms686211%28v=vs.85%29.aspx
http://msdn.microsoft.com/en-us/library/windows/desktop/ms682052%28v=vs.85%29.aspx
http://en.cppreference.com/w/cpp/thread/condition_variable

Introducing the USB Stick of Death

One of the obvious steps that we took to test the reliability of the file system management implemented in ntfs.sys was running a trivial bit-flipping fuzzer to see if we could reproduce any interesting behavior (such as a system crash) with such simple techniques. The first indicator of a possibly serious bug – a Blue Screen of Death – was encountered after roughly 17 hours of fuzzing time on a single laptop, and looked like the following...

http://gynvael.coldwind.pl/?id=489

 
Tomasz Kulig