โ† CS Visual Lab ยท Operating Systems

๐Ÿฆ Deadlock avoidance: Banker's algorithm

๐Ÿ’ก The ideaBefore giving resources, the OS checks that every process can still finish in some order (a safe sequence). Need = Max โˆ’ Allocation. A process can run if its Need fits in Work; when it finishes, its allocation returns to Work.
๐Ÿ  In real lifeA bank lends money only if it can still satisfy every customer's maximum loan in some order, so the bank never runs dry.

๐ŸŽฌ Watch it work

Step 1 of 7
ProcessAllocationMaxNeed = Max โˆ’ Alloc
P00 1 07 5 37 4 3
P12 0 03 2 21 2 2
P23 0 29 0 26 0 0
P32 1 12 2 20 1 1
P40 0 24 3 34 3 1

Check P0: Need [7 4 3] > Work [3 3 2] โ†’ it must wait.

โœ… Check yourself (2 of 3 to pass)

1. Need matrix =
2. If no safe sequence exists, the state is:
3. When a process finishes in the safety check, Work becomes:
Next: Disk scheduling โ†’Get a free certificate in Operating Systems