---
slug: "Lock"
name: "Lock"
type: "Primitives"
layer: "Physics"
ref: "Lock#95c2"
sema_id: "sema:Lock#mh:SHA-256:95c2ee952a5301d4b346a5e8693350829d88b3c600048eedcf87bb00c23ee5fb"
tags: ["Physics","Primitives"]
updated: 2026-11-11
mindscape: "bootstrap"
index_url: https://mindscape.pages.dev/bootstrap/index.json
url: https://mindscape.pages.dev/bootstrap/Lock/
related: ["EbbFlowSync","Mutex","StateLock","WorkerMode"]
---

# Lock

Mutual exclusion enforcement

Layer: Physics · Category: 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.

## Builds on

—

## Used by

- [EbbFlowSync](https://mindscape.pages.dev/bootstrap/EbbFlowSync.md) (Society; References)
- [Mutex](https://mindscape.pages.dev/bootstrap/Mutex.md) (Infrastructure; Extends)
- [Mutex](https://mindscape.pages.dev/bootstrap/Mutex.md) (Infrastructure; References)
- [StateLock](https://mindscape.pages.dev/bootstrap/StateLock.md) (Society; References)
- [WorkerMode](https://mindscape.pages.dev/bootstrap/WorkerMode.md) (Society; References)

## Identity

- Sema ID: `sema:Lock#mh:SHA-256:95c2ee952a5301d4b346a5e8693350829d88b3c600048eedcf87bb00c23ee5fb`
- Ref: `Lock#95c2`

## Links

- [Pattern page](https://mindscape.pages.dev/bootstrap/Lock/)
- [View in the interactive graph](https://mindscape.pages.dev/bootstrap/#Lock)
- [JSON](https://mindscape.pages.dev/bootstrap/Lock.json)
- [Index of all patterns](https://mindscape.pages.dev/bootstrap/index.json)
