In this chapter, we describe two tools that threads can use to synchronize their actions: mutexes and condition variables. Mutexes allow threads to synchronize their use of a shared resource, so that, for example, one thread doesn't try to access a shared variable at the same time as another thread is modifying it. Condition variables perform a complementary task: They allow threads to inform each other that a shared variable (or other shared resource) has changed state.
30 Threads: Thread Synchronization
30.1 Protecting Accesses to Shared Variables: Mutexes
30.1.1 Statically Allocated Mutexes
30.1.2 Locking and Unlocking a Mutex
30.1.3 Performance of Mutexes
30.1.4 Mutex Deadlocks
30.1.5 Dynamically Initializing a Mutex
30.1.6 Mutex Attributes
30.1.7 Mutex Types
30.2 Signaling Changes of State: Condition Variables
30.2.1 Statically Allocated Condition Variables
30.2.2 Signaling and Waiting on Condition Variables
30.2.3 Testing a Condition Variable’s Predicate
30.2.4 Example Program: Joining Any Terminated Thread
30.2.5 Dynamically Allocated Condition Variables
30.3 Summary
30.4 Exercises
2009-09-01
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment