Mutex
Version 1.0.0 · Updated 2026-07-28
CORE DEFINITION
A mutex (short for mutual exclusion) is a mechanism used in multithreaded programming to prevent two threads from simultaneously reading and writing to the same shared resource (such as a global variable). This is achieved by dividing the code into critical sections. A critical section is a block of code that accesses a shared resource; it is not a mechanism or algorithm. A program, process, or thread can have multiple critical sections, but they may not necessarily use a mutex. Examples of resources that require this mechanism include flags, queues, counters, interrupt handlers, and other resources used to pass data or synchronize state among multiple concurrently running code paths. Maintaining synchronization, consistency, and integrity of these resources is difficult because a thread can be paused (suspended) or resumed (awakened) at any moment. For example, code (A) is modifying a piece of data step by step. At that moment, another thread (B) is awakened for some reason.
SCAFFOLDING EFFECT
Reduce cognitive load
A mutex (short for mutual exclusion) is a mechanism used in multithreaded programming to prevent two threads from simultaneously reading and writing to the same shared resource (such as a global variable). This is achieved by dividing the code into critical sections. A critical section is a block of code that accesses a shared resource; it is not a mechanism or algorithm. A program, process, or thread can have multiple critical sections, but they may not necessarily use a mutex.
Anchor fast decisions
A mutex is a binary semaphore that ensures a critical resource is held by only one execution unit at a time; non-holders block and wait, thereby avoiding data races and inconsistencies caused by concurrent reads and writes.
MINIMUM ACTION
In progress 0/5Practice this model in one real situation:
account_treeGenealogyexpand_more
menu_bookReferencesexpand_more
Source support: Explicit
- zh.wikipedia.orghttps://zh.wikipedia.org/wiki/%E4%BA%92%E6%96%A5%E9%94%81verified
PRIVATE NOTES · Only visible to you
SAVED Q&A
ENTRY Q&A · Private saving available
Ask with a clear boundary
thinkingmodels answers from published entry context only.
Your question is sent to thinkingmodels. The answer uses public entry context only.
RELATED MODELS