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

Recap

This chapter has presented an overview of the various mechanisms available for thread synchronization. Table 3.1 offers a recap of these synchronization mechanisms.

Table 3.1: A Summary Cross-reference of Different Building Blocks for Thread Interaction

Objective

Windows

Comments

Pthreads

Comments

Mutual exclusion

Mutex

Much slower than critical sections

Mutex

Critical Section

More frequently used and faster than mutexes

N/A

Interlocked Function

High-speed integer manipulation

N/A

Synchronization

Spin wait

Fast but wasteful

Same as Windows

Events

Cue threads off the actions of other threads

Condition variables

Suited to multiple threads

Semaphore

Very rarely used

Semaphore

Commonly used. Best at controlling single threads

We hasten to add that these discussions are just an introduction. Many complexities are intentionally not discussed because they're not germane to our overall goal. Entire books have been written on thread local storage, and the system cleanup of killed threads, among many other topics. For the most part, these issues arise only in complex parallel code. If you come to the point where you need this information, our recommendations for titles and resources that can guide you are located in the bibliography at the back of this book.

Two other topics discussed later are thread priority and thread affinity. Thread priority deals with which thread gets to run first when multiple threads can be scheduled. Thread affinity is the means by which a programmer tells the operating system on which processor to run a specific thread. Both of these...

UNLIMITED FREE
ACCESS
TO THE WORLD'S BEST IDEAS

SUBMIT
Already a GlobalSpec user? Log in.

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.

Customize Your GlobalSpec Experience

Category: Thread Rolling Dies
Finish!
Privacy Policy

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.