Internal synchronization state from pinned Miri #
This file starts a source-shaped port of upstream/miri-source/src/concurrency/sync.rs
(blob 3e848a071e2a67792eada4625b1751eec119b21d). It preserves the state fields
of Mutex, RwLock, Condvar, Semaphore, and Futex. The lock transitions below
preserve Miri's mutation order and use the existing GlobalState clock hooks
and ThreadManager blocking/wakeup state.
Unblock callbacks are returned as explicit obligations. A transition carrying one has not completed the source operation yet. OS object lookup, shim-side memory checks, interpreter callback execution, futex/semaphore callback bodies, and actual memory writes remain outside this component; none is interpreted as success here. This is not a complete Rust concurrency semantics.
- none : SyncClockHandler
- vectorClocks : SyncClockHandler
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
Equations
Equations
- One or more equations did not get rendered due to their size.
Instances For
The actual defaulted state held by Miri's RwLock. Reader counts use a
finite association list as a representation of the source FxHashMap; all
operations preserve unique thread keys and positive counts.
Instances For
Equations
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- waiters : List FutexWaiter
- clock : VClock
Instances For
Equations
Equations
- One or more equations did not get rendered due to their size.
Instances For
Built-in callback bodies created by the generic sync layer. Pointer and scalar destinations are opaque interpreter tokens; this file never writes through them.
- mutexAcquire : SyncCallbackProgram
- rwlockReaderAcquire (returnValueToken destinationToken : Nat) : SyncCallbackProgram
- rwlockWriterAcquire (returnValueToken destinationToken : Nat) : SyncCallbackProgram
- mutexAcquireAndWrite (returnValueToken destinationToken : Nat) : SyncCallbackProgram
- writeScalar (valueToken destinationToken : Nat) : SyncCallbackProgram
- condvarWait (mutexToken successValueToken timeoutValueToken destinationToken : Nat) : SyncCallbackProgram
- futexWait (userCallbackToken : Nat) : SyncCallbackProgram
- semaphoreWait (userCallbackToken : Nat) : SyncCallbackProgram
- opaqueInterpreterCallback (callbackToken : Nat) : SyncCallbackProgram
Instances For
Equations
- One or more equations did not get rendered due to their size.
- Miri.Concurrency.instDecidableEqSyncCallbackProgram.decEq Miri.Concurrency.SyncCallbackProgram.mutexAcquire Miri.Concurrency.SyncCallbackProgram.mutexAcquire = isTrue ⋯
- Miri.Concurrency.instDecidableEqSyncCallbackProgram.decEq Miri.Concurrency.SyncCallbackProgram.mutexAcquire (Miri.Concurrency.SyncCallbackProgram.futexWait userCallbackToken) = isFalse ⋯
- Miri.Concurrency.instDecidableEqSyncCallbackProgram.decEq Miri.Concurrency.SyncCallbackProgram.mutexAcquire (Miri.Concurrency.SyncCallbackProgram.semaphoreWait userCallbackToken) = isFalse ⋯
- Miri.Concurrency.instDecidableEqSyncCallbackProgram.decEq (Miri.Concurrency.SyncCallbackProgram.futexWait userCallbackToken) Miri.Concurrency.SyncCallbackProgram.mutexAcquire = isFalse ⋯
Instances For
Equations
Equations
- One or more equations did not get rendered due to their size.
Instances For
- globalState (error : GlobalStateError) : SyncError
- missingGlobalClock : SyncError
- threadManager (error : ThreadError) : SyncError
- mutexSourceAssertion (message : String) : SyncError
- mutexLockCountOverflow (bits : Nat) : SyncError
- mutexLockCountUnderflow : SyncError
- rwlockSourceAssertion (message : String) : SyncError
- rwlockReaderMapInvariant : SyncError
- rwlockReaderCountOverflow (bits : Nat) : SyncError
- callbackProgramMismatch (expected actual : SyncCallbackProgram) : SyncError
- callbackUnblockedWithTimeout : SyncError
- callbackReasonMismatch (expected actual : BlockReason) : SyncError
- callbackKindMismatch (expected actual : UnblockKind) : SyncError
- callbackTargetMismatch (expected actual : ThreadId) : SyncError
- callbackReturnedError : SyncError
- blockThreadSource (error : BlockThreadSourceError) : SyncError
- condvarWaitMutexNotLocked : SyncError
- condvarWaitRecursiveMutex (lockCount : Nat) : SyncError
- condvarMutexOwnedByActiveThread (thread : ThreadId) : SyncError
- futexThreadAlreadyWaiting (thread : ThreadId) : SyncError
- semaphoreCounterOverflow : SyncError
Instances For
Equations
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
Instances For
- unblock : UnblockCallbackObligation
- program : SyncCallbackProgram
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
A callback request is a live, unresolved action in the source operation.
outcome records the component's return value only as a continuation value;
callers must run the request and use the corresponding completion function
before treating the enclosing operation as returned.
- syncState : State
- global : G
- threads : ThreadManager
- callback : Option SyncCallbackRequest
- callbackRegistration : Option (Nat × SyncCallbackProgram)
Instances For
Equations
Equations
- One or more equations did not get rendered due to their size.
Instances For
- returnedNone : MutexUnlockResult
- returnedSome (oldLockCount : Nat) : MutexUnlockResult
Instances For
Equations
- One or more equations did not get rendered due to their size.
- Miri.Concurrency.instDecidableEqMutexUnlockResult.decEq Miri.Concurrency.MutexUnlockResult.returnedNone Miri.Concurrency.MutexUnlockResult.returnedNone = isTrue ⋯
- Miri.Concurrency.instDecidableEqMutexUnlockResult.decEq Miri.Concurrency.MutexUnlockResult.returnedNone (Miri.Concurrency.MutexUnlockResult.returnedSome oldLockCount) = isFalse ⋯
- Miri.Concurrency.instDecidableEqMutexUnlockResult.decEq (Miri.Concurrency.MutexUnlockResult.returnedSome oldLockCount) Miri.Concurrency.MutexUnlockResult.returnedNone = isFalse ⋯
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
Equations
- transition.outcomeIsOk = match transition.outcome with | Except.ok a => True | Except.error a => False
Instances For
Equations
- transition.hasPendingWork = (transition.callback.isSome || transition.callbackRegistration.isSome)
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- One or more equations did not get rendered due to their size.
- state.queueForBlock threads Miri.Concurrency.MutexUnlockResult.returnedNone = { state := state, outcome := Except.error Miri.Concurrency.SyncError.condvarWaitMutexNotLocked }
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
Instances For
Equations
- state.queueIsEmpty = state.queue.isEmpty
Instances For
Exact source operation mutex_lock: owner/count mutations precede
acquire_clock, and therefore remain visible if that hook reports an error.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Exact source operation mutex_enqueue_and_block through
block_thread. Queue insertion precedes the source assertion and blocking;
the callback registration names the closure body installed by Miri.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Exact source operation mutex_unlock. A woken thread is enabled and made
active by unblockThread; the callback must then be completed with
finishMutexAcquireCallback before the source operation has returned.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Execute the known internal callback installed by
mutex_enqueue_and_block: it requires a Ready unblock, asserts that ownership
was transferred to an unlocked mutex, acquires the lock/clock, and restores
the previously active thread only after normal callback return.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Continuation used by condvar_reacquire_mutex when the mutex is still
owned. It runs Miri's installed callback through lock/clock acquisition, then
leaves the captured scalar store as an explicit interpreter obligation.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- state.isWriteLocked = state.writer.isSome
Instances For
Equations
- state.queueIsEmpty = (state.writerQueue.isEmpty && state.readerQueue.isEmpty)
Instances For
Exact rwlock_reader_lock state update and following clock acquire.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Exact rwlock_writer_lock state update and following clock acquire.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Queue a reader behind a writer, preserving the source's push-before-assert
and block_thread order. The closure's scalar write is an opaque token.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Queue a writer behind an existing reader or writer, using the source's writer queue and callback registration.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Exact rwlock_reader_unlock ordering. It first removes/decrements the
reader entry, then releases and joins the active clock, then transfers the
joined-reader clock and wakes one queued writer if the lock becomes free.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Exact rwlock_writer_unlock: the writer clears ownership before the clock
release; queued writers have priority, otherwise all waiting readers are
removed from the queue before their callbacks are invoked in FIFO order.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Continue a source loop that is waking the readers drained by
rwlock_writer_unlock. The caller must first execute the callback in the
previous request and provide its resulting manager.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Run the internal callback body installed while a reader/writer waited for
an RwLock: acquire the appropriate lock/clock, then expose the source's
write_scalar as a pending interpreter action.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- state.queueIsEmpty = state.waiters.isEmpty
Instances For
Continue condvar_wait only after mutex_unlock returned successfully
with an original count of one. The call preserves the source order: waiter
queue insertion, then checked blocking with its timeout constraints.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Exact condvar_signal: release the signal clock before popping a waiter,
then unblock at most the FIFO head. The callback stays pending until the
interpreter executes the captured condvar/mutex continuation.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Execute the internal condvar callback through its source effects. On Ready it acquires the signal clock; on timeout it first removes the waiter. It then reacquires the captured mutex. If another thread owns it, this thread blocks on that mutex with the source lock-and-write callback registered. If the mutex is free, it acquires it and leaves the captured scalar write pending.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- state.waiterCount = state.waiters.length
Instances For
Exact source futex_wait registration: reject a duplicate waiter, append
the thread/bitset pair, then apply Miri's timeout checks and block it. Its
callback wrapper is retained as an explicit registration for the wake path.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Exact futex_wake: release the clock before filtering and removing waiters;
the first unblock callback and every continuation are returned explicitly.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Miri's futex wrapper acquires the futex clock on Ready, removes the active waiter on timeout, then invokes the OS-shim callback. That last callback is opaque here and remains pending until the caller supplies its actual result.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Continue the futex_wake source loop only after the previous outer and
OS-shim callbacks returned normally. Callback failure stops the loop before
active-thread restoration, as Miri's ? propagation does.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Complete the actual interpreter write_scalar hook at the end of a
mutex/rwlock/condvar unblock callback. A failed write preserves the callback's
state and active-thread context, matching source ? propagation.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Complete a callback body whose implementation belongs to an OS shim or the interpreter. The caller supplies the post-callback manager and the actual return status; errors preserve its active-thread state, while normal return restores the previous active thread exactly once.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- state.queueIsEmpty = state.waiters.isEmpty
Instances For
Exact source semaphore decrement through value update, clock acquire, and callback registration. If the counter is zero, queue insertion precedes checked blocking and the callback remains attached to the thread.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- One or more equations did not get rendered due to their size.