Mutex
A special object that controls thread access to shared resources to prevent data race. Only one process at a time is allowed to read/write. Mutexes have some downsides, see .
# Notes
If one process only writes to some variable, and another only reads from it, you don’t need to use mutex for this. Because only read and only write are atomic operations.
# Links
- How does a mutex work? What does it cost?
- linux - How pthread_mutex_lock is implemented
- Thread locks implementation
- 5 Big Fat Reasons Why Mutexes Suck Big Time
- Is it safe to concurrently read from shared memory?