---
library: "bootstrap"
slug: "Mutex"
name: "Mutex"
ref: "Mutex#b031"
hash: "sema:Mutex#mh:SHA-256:b031c2dc75f23526ac765e042cd1ff77f66f0a7a23d57e480b30da0a8343e18e"
type: "Primitives"
layer: "Infrastructure"
version: "0.11.0"
root: "a6a3d1ff0f982ee30430c5b42f3784c8ec901fd68482cfc1bc30899c1e5e48c5"
license: null
url: "https://semahash.org/vocabularies/bootstrap/patterns/Mutex"
---

# Mutex

Ownership-based mutual exclusion

Infrastructure · Primitives

## Mechanism

An ownership-bearing [Lock](https://semahash.org/vocabularies/bootstrap/patterns/Lock.md) for a shared [Resource](https://semahash.org/vocabularies/bootstrap/patterns/Resource.md). An [Actor](https://semahash.org/vocabularies/bootstrap/patterns/Actor.md) that successfully acquires it becomes the sole owner and may enter the protected section. Only the owner may release it; another contender becomes owner only through a later successful acquisition after release.

## Invariants

- Exclusivity: at most one [Actor](https://semahash.org/vocabularies/bootstrap/patterns/Actor.md) owns the mutex at a time.
- Acquire-before-access: an [Actor](https://semahash.org/vocabularies/bootstrap/patterns/Actor.md) enters the protected section only after successful acquisition.
- Owner-only release: only the current owner may perform an ordinary release.
- Release-after-use: the owner releases the mutex after leaving the protected section.

## Preconditions

- A shared [Resource](https://semahash.org/vocabularies/bootstrap/patterns/Resource.md) and protected section exist.
- All contenders use the same mutex state.

## Postconditions

- A successful acquisition yields exactly one owner.
- Non-owners do not enter the protected section.
- Release removes the former owner's protected access.

## Failure modes

- Deadlock: contenders form a wait cycle and no acquisition can complete.
- Orphaned ownership: an owner fails without release, leaving the mutex unavailable.
- Starvation: a contender is repeatedly denied under the selected acquisition policy.
- Ownership violation: a non-owner releases the mutex or enters the protected section.

## Caution

Exclusive access — starvation enables denial of service.

## Where this came from

—

## Builds on

- [Resource](https://semahash.org/vocabularies/bootstrap/patterns/Resource.md) (references)
- [Lock](https://semahash.org/vocabularies/bootstrap/patterns/Lock.md) (references)
- [Actor](https://semahash.org/vocabularies/bootstrap/patterns/Actor.md) (accepts)

## Identity

- Library: bootstrap 0.11.0 (root a6a3d1ff0f98)
- Ref: Mutex#b031
- Hash: sema:Mutex#mh:SHA-256:b031c2dc75f23526ac765e042cd1ff77f66f0a7a23d57e480b30da0a8343e18e

## Links

- Page: https://semahash.org/vocabularies/bootstrap/patterns/Mutex
- JSON: https://semahash.org/vocabularies/bootstrap/patterns/Mutex.json
- Library: https://semahash.org/vocabularies/bootstrap
- Library index: https://semahash.org/vocabularies/bootstrap/index.json
