01Decision
Copy Available, Allocation and Need under the mutex, release it, and run the search on the copy.
over Holding the mutex for the duration of the search.
- The pressure
- The safety search is O(P²·R) and reads every matrix in the system, while goroutines standing in for processes are asking for resources the whole time.
- Why this way
- The lock exists to keep the matrices consistent, not to serialise the simulation. A quadratic search inside the critical section makes every other goroutine wait on work that does not need live state.
- What it cost and bought
- The check never blocks a request, and it answers about the state as it was at copy time — which is the correct semantics for a decision the manager is about to act on under the same lock.