Files
aji/docs/rfcs/0003-aji-memory-model.md
T
dev 17a55a7fef Initial import: Aji 0.1 draft spec and Zig scaffolding
Draft specification, RFCs, reference registries and examples, plus the
reference-implementation skeleton: build.zig, diagnostic envelope with
error-code registry synced to docs, aji CLI, conformance runner with seed
tests, CI and contributor docs.
2026-10-04 11:59:13 +03:00

62 lines
1.7 KiB
Markdown

# RFC 0003: Concurrency Memory Model
Status: Proposed
Target: Aji 0.1
## Summary
Aji adopts a data-race-free model for ordinary memory and explicit C/C++/Rust-style atomic ordering for low-level synchronization.
The intended user-level guarantee is DRF-SC:
> If a safe program has no data race, ordinary memory behaves as though operations occurred in some sequentially consistent interleaving consistent with happens-before.
## Relations
The model defines:
- sequenced-before;
- synchronizes-with;
- happens-before;
- atomic modification order.
## Synchronization examples
- operations before task spawn happen-before child start;
- child completion happens-before successful join return;
- channel send synchronizes with the matching receive;
- mutex unlock synchronizes with a later successful lock acquisition;
- release atomic operation synchronizes with an acquire operation that observes the release according to atomic semantics.
## Ordinary memory
Safe Aji rejects possible unsynchronized conflicting ordinary accesses.
The compiler may therefore optimize ordinary memory under the assumption that safe programs are race-free.
## Atomics
Orders:
```text
relaxed
acquire
release
acq_rel
seq_cst
```
No default order and no `consume`.
## Why no safe Atomic<ref<T>> initially
Publishing an address atomically does not solve reclamation. A verifier would need to reason about when pointed-to storage can be freed.
Therefore lock-free pointer structures should first exist behind audited library abstractions using epoch/hazard/RCU mechanisms.
## Weak-memory audit marker
Use of relaxed atomics should be visible in the effect/audit system as `atomic.weak`.
This has no runtime meaning; it is an auditability requirement.