[Return to Bookshelf] [Contents] [Previous Section] [Next Section] [Index] [Help]


3.6.1 Mutex or Condition Variable

Use a mutex for tasks with fine granularity. Examples of fine- grained tasks are those that serialize access to shared memory or make simple modifications to shared memory (critical sections of a few program statements or less). Mutex waits are not interruptable- threads waiting to lock a mutex cannot be alerted or canceled.

A condition variable is not used to protect data. It is used to wait for data to assume a desired state. A condition variable is always used with a mutex that protects the shared data. Condition variable waits are interruptable.

See Section 2.3.1 and Section 2.3.2 for more information on mutexes and condition variables.