Expand description
Critical sections: run code with CPU interrupts masked.
On the PS1 a critical section clears COP0 SR.IEc for its duration and puts the previous value back afterwards, so sections nest. psx-rt’s own interrupt handler is assembly that touches no Rust state, so the SDK does not need one; games that install a Rust IRQ handler do, to share data with it.
The shape follows the critical-section crate: acquire and
release are the raw pair, with the scoped form, and Mutex
hands out a shared reference only while a CriticalSection token is
alive. With psx-rt’s critical-section feature the same pair is also
registered as that crate’s implementation, so critical_section::with
in any dependency masks interrupts here too.
Host builds (tests, tools) serialise through a spin lock instead, so the same code stays sound under a multi-threaded test runner.
Structs§
- Critical
Section - Proof that the current code runs inside a critical section.
- Mutex
- Data shared with interrupt code, reachable only inside a critical section.
- Restore
State - What
releaseneeds to put back: whether interrupts were enabled.