Mutex
A mutex is a lock on some shared operation between threads. For example accessing shared memory. To do the operation you must obtain the mutex (if some other thread has the mutex you enter a wait state). The mutex is just a data structure consisting of atleast:
- Status of the mutex,
- Current mutex owner, and
- List of threads waiting on the mutex.
Birrells original API used a context manager syntax but common apis use an lock and unlock command. The code in the context manager or between the lock and unlock commands is called the critical section.