mutex

A lock that lets only one piece of code at a time run a critical section or do a particular piece of work.

In more detail

Code acquires the lock before the critical section and releases it after, and other callers wait. Mutexes prevent two tasks from corrupting shared data or doing the same expensive work.

Examples

LOCK = threading.Lock()  # VIII: scale means more threads in here
A mutex lets one request rebuild an expired cache entry while others wait.
mu.Lock()
defer mu.Unlock()
Go: mu.Lock(); defer mu.Unlock()
A malware family's mutex name is often fixed, which makes it a useful string in YARA rules and a host indicator to sweep for.

Related terms

Taught in

References