by admin

Strategies for Implementing POSIX Condition Variables on Win32

January 12, 2015 in C, Linux, Programming, Source Code, Tips & Tricks, Windows by admin

c++In case one’s interested in cross-platform development, here is a nice article about various strategies of implementing POSIX condition variables on Win32. Quoting from the article:

The threading API provided by the Microsoft Win32 [Richter] family of operating systems (i.e., Windows NT, Windows ’95, and Windows CE) provides some of the same concurrency constructs defined by the POSIX Pthreads specification [Pthreads]. For instance, they both support mutexes, which serialize access to shared state. However, Win32 lacks full-fledged condition variables, which are a synchronization mechanism used by threads to wait until a condition expression involving shared data attains a particular state.

The lack of condition variables in Win32 makes it harder to implement certain concurrency abstractions, such as thread-safe message queues and thread pools. This article explores various techniques and patterns for implementing POSIX condition variables correctly and/or fairly on Win32. Section 2 explains what condition variables are and shows how to use them. Secion 3 explains alternative strategies for implementing POSIX condition variables using Win32 synchronization primitives. A subsequent article will describe how the Wrapper Facade pattern and various C++ language features can help reduce common mistakes that occur when programming condition variables.

For the entire article, follow this link.

by admin

Pre-defined Compiler Macros

September 20, 2014 in C, C++, Programming, Source Code, Tips & Tricks by admin

c++C and C++ compilers automatically define certain macros that can be used to check for compiler or operating system features. This is useful when writing portable software.

This link goes to a wiki page where subpages pagesĀ  list various pre-defined compiler macros that can be used to identify standards, compilers, operating systems, hardware architectures, and even basic run-time libraries at compile-time.


Skip to toolbar