CPU Scheduling, Semaphores & Deadlock Banker’s Formula
TAT/WT numericals, counting semaphore wait/signal invariants, and minimum/maximum resource deadlock formulas.
Deadlock Resource Allocation Shortcut
Suppose processes each require at most instances of a single resource type :
- Maximum resources WITH deadlock still possible:
- Minimum resources GUARANTEEING NO deadlock:
Example: 4 processes each need max tape drives. Max drives with deadlock . Minimum drives for zero deadlock !
fork() System Call Process Creation
Calling fork() times sequentially creates total processes ( original parent + child processes).
Interactive CPU Scheduling Gantt Chart Simulator (SRTF, RR, SJF, FCFS)
CPU Scheduling Live Gantt Chart (SRTF / RR / SJF / FCFS)
| Process | Arrival (AT) | Burst (BT) | Completion (CT) | TAT = CT − AT | WT = TAT − BT |
|---|---|---|---|---|---|
| P1 | 0 | 5 | 10 | 10 | 5 |
| P2 | 1 | 3 | 4 | 3 | 0 |
| P3 | 2 | 4 | 14 | 12 | 8 |
| P4 | 4 | 2 | 6 | 2 | 0 |
Interactive Banker’s Deadlock Safety Sequence Trace
Banker’s Deadlock Safety Sequence Step-by-Step
[A=3, B=3, C=2]| Proc | Allocation (A,B,C) | Max (A,B,C) | Need = Max − Alloc | State |
|---|---|---|---|---|
| P0 | [0, 1, 0] | [7, 5, 3] | [7, 4, 3] | Pending |
| P1 | [2, 0, 0] | [3, 2, 2] | [1, 2, 2] | Pending |
| P2 | [3, 0, 2] | [9, 0, 2] | [6, 0, 0] | Pending |
| P3 | [2, 1, 1] | [2, 2, 2] | [0, 1, 1] | Pending |
| P4 | [0, 0, 2] | [4, 3, 3] | [4, 3, 1] | Pending |
Practice Questions on This Chapter (6)
A system has processes, and each process requires a maximum of instances of resource to complete execution. What is the minimum number of instances of that guarantees the system will NEVER enter deadlock?
A C program executes fork(); fork(); fork(); sequentially without any conditional branching. Including the initial parent process, how many child processes are newly created?
A counting semaphore is initialized to . Subsequently, wait(P) operations and signal(V) operations are completed on . What is the current value of ?
A system has processes, each requiring at most identical units of resource . What is the minimum number of units of that guarantees the system is always deadlock-free?
Four processes arrive at times with CPU burst times respectively. Under SRTF (Shortest Remaining Time First) preemptive scheduling, what is the average turnaround time?
Consider Peterson’s two-process software synchronization solution using shared flag[0..1] and turn. Which of the three Critical Section requirements (Mutual Exclusion, Progress, Bounded Waiting) does it satisfy on a sequentially consistent processor?