Programming with Hyper-Threading Technology: How to Write Multithreaded Software for Intel IA-32 Processors

This chapter presents in greater detail the two primary threading API sets examined in the previous chapters: the Windows API and the Pthreads library. Chapter 6 presents a similarly in-depth discussion of OpenMP, the portable threading specification that relies on the use of pragmas and environment variables.
Before entering into these APIs, they should be contrasted with OpenMP. The APIs provide fine-level control of threading operations on the Windows, UNIX, and Linux platforms. They are low-level functions and as such require considerable management to perform even simple tasks. In addition, they make the code base in which they appear more difficult to port. They have an additional detrimental effect on the code: it cannot be recompiled to run serially, that is, without threads, unless every function call is carefully wrapped in extensive conditional compilation directives. OpenMP suffers from none of these drawbacks: the code is inherently portable. And because it relies on pragmas, any program can be made single-threaded by simply disabling the OpenMP directives. As a result, we strongly encourage readers to evaluate OpenMP as their primary threading solution. The principal drawback of Open MP is that the Microsoft C/C++ compiler does not currently support it. You should use one of the threading APIs discussed here only if Open MP cannot fulfill the specific needs of the program.
The Windows threading APIs have grown with each release of Windows. As Microsoft operating systems have found a larger role in the server side of the enterprise computing...