---
library: "bootstrap"
slug: "Lock"
name: "Lock"
ref: "Lock#95c2"
hash: "sema:Lock#mh:SHA-256:95c2ee952a5301d4b346a5e8693350829d88b3c600048eedcf87bb00c23ee5fb"
type: "Primitives"
layer: "Physics"
version: "0.11.0"
root: "a6a3d1ff0f982ee30430c5b42f3784c8ec901fd68482cfc1bc30899c1e5e48c5"
license: null
url: "https://semahash.org/vocabularies/bootstrap/patterns/Lock"
---

# Lock

Mutual exclusion enforcement

Physics · Primitives

## Mechanism

A synchronization primitive that enforces exclusive access to a resource. At most one holder may access the protected resource at any time. The holder must explicitly release the lock to allow others to acquire it.

## Invariants

- Exclusivity: At most one holder at any time.
- Acquire-before-access: Protected resource cannot be touched without holding the lock.
- Release-after-use: Holder must release after completing the critical section.

## Preconditions

- Shared resource exists
- Contending parties can communicate

## Postconditions

- Exactly one party holds exclusive access
- Other contenders are blocked or queued

## Failure modes

- Deadlock: Holder crashes or hangs without releasing, blocking all other contenders indefinitely.
- Priority Inversion: High-priority contender blocked by low-priority holder.

## Caution

Exclusive access — starvation enables denial of service.

## Where this came from

—

## Used by

- [EbbFlowSync](https://semahash.org/vocabularies/bootstrap/patterns/EbbFlowSync.md) (references)
- [Mutex](https://semahash.org/vocabularies/bootstrap/patterns/Mutex.md) (references)
- [StateLock](https://semahash.org/vocabularies/bootstrap/patterns/StateLock.md) (references)
- [WorkerMode](https://semahash.org/vocabularies/bootstrap/patterns/WorkerMode.md) (references)

## Identity

- Library: bootstrap 0.11.0 (root a6a3d1ff0f98)
- Ref: Lock#95c2
- Hash: sema:Lock#mh:SHA-256:95c2ee952a5301d4b346a5e8693350829d88b3c600048eedcf87bb00c23ee5fb

## Links

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