Banker's algorithm avoids deadlock by granting a resource request only when the resulting allocation remains safe: some schedule can still let every execution finish, even at its declared maximum demand. section 11.2.2
Apply the safety check when each execution's resource requirements are known:
- Record each execution's maximum demand, current holdings, and the number of available resources. section 11.2.2
- Grant a request only if the allocation leaves a safe state; otherwise suspend the execution until resources become safe to grant. section 11.2.2
Database connection pool
Treat fixed database sessions as limited resources. Granting execution a another session can produce an unsafe state if no execution can then receive enough resources to finish. A practical Go arbitrator instead waits until all requested accounts are available, performs a transfer, releases them, and broadcasts to waiting goroutines. section 11.2.2
