Multi-Core Programming: Increasing Performance through Software Multithreading

When implemented properly, threading can enhance performance by making better use of hardware resources. However, the improper use of threading can lead to degraded performance, unpredictable behavior, and error conditions that are difficult to resolve. Fortunately, if you are equipped with a proper understanding of how threads operate, you can avoid most problems and derive the full performance benefits that threads offer. This chapter presents the concepts of threading starting from hardware and works its way up through the operating system and to the application level.
To understand threading for your application you need to understand the following items:
The design approach and structure of your application
The threading application programming interface (API)
The compiler or runtime environment for your application
The target platforms on which your application will run
From these elements, a threading strategy can be formulated for use in specific parts of your application.
Since the introduction of instruction-level parallelism, continuous advances in the development of microprocessors have resulted in processors with multiple cores. To take advantage of these multi-core processors you must understand the details of the software threading model as well as the capabilities of the platform hardware.
You might be concerned that threading is difficult and that you might have to learn specialized concepts. While it's true in general, in reality threading can be simple, once you grasp the basic principles.
A thread is a discrete sequence of related instructions that is executed independently of other instruction sequences. Every program...