Cognitive Scaffold

Preparing your thinking workspace

arrow_back_ios_new
MENTAL MODEL · M6235

Mutex

Mutex
DecideHigh supportDecision Science
Included
account_tree

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

psychology

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

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/5

Practice this model in one real situation:

Check to track your progress (stored locally)
Learning progress0%
account_treeGenealogyexpand_more
menu_bookReferencesexpand_more

Source support: Explicit

  • link
    zh.wikipedia.orghttps://zh.wikipedia.org/wiki/%E4%BA%92%E6%96%A5%E9%94%81ZH · Explicit
    verified

RELATED MODELS