∑GateAndNet
Practice MCQs
GATE CS / Operating Systems
Edit
INTERMEDIATE🔥 High-Yield Exam Topic 4 min read 4 views

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 nn processes each require at most kik_i instances of a single resource type RR:

  • Maximum resources WITH deadlock still possible: ∑i=1n(ki−1)\sum_{i=1}^{n} (k_i - 1)
  • Minimum resources GUARANTEEING NO deadlock: [∑i=1n(ki−1)]+1\left[\sum_{i=1}^{n} (k_i - 1)\right] + 1

Example: 4 processes each need max 33 tape drives. Max drives with deadlock =4(3−1)=8= 4(3 - 1) = 8. Minimum drives for zero deadlock =8+1=9= 8 + 1 = \mathbf{9}!

fork() System Call Process Creation

Calling fork() nn times sequentially creates 2n2^n total processes (11 original parent + 2n−12^n - 1 child processes).

📐 Quick Revision Formula Sheet
Counting Semaphore Final Value
Sfinal=Sinit−(#P/wait)+(#V/signal)S_{\text{final}} = S_{\text{init}} - (\#\text{P/wait}) + (\#\text{V/signal})
💡 If S_final < 0, then |S_final| processes are blocked in semaphore queue!
Deadlock-Free Minimum Resources
R≥∑i=1n(Maxi−1)+1R \ge \sum_{i=1}^{n} (\text{Max}_i - 1) + 1
💡 Guarantees at least 1 process gets all needed resources and finishes!
#Operating Systems#Scheduling#Semaphores#Deadlock

🎯 Practice PYQs on This Topic (4)

Q1.GATE CS OS NATNATEASY
+2 Marks • No Negative

A system has 55 processes, and each process requires a maximum of 44 instances of resource RR to complete execution. What is the minimum number of instances of RR that guarantees the system will NEVER enter deadlock?

Q2.GATE CS OSMCQMEDIUM
+2 Marks • -0.67 Neg

A C program executes fork(); fork(); fork(); sequentially without any conditional branching. Including the initial parent process, how many child processes are newly created?

Q3.GATE CS OSMCQMEDIUM
+2 Marks • -0.67 Neg

A counting semaphore SS is initialized to 1010. Subsequently, 66 wait(P) operations and 44 signal(V) operations are completed on SS. What is the current value of SS?

Q4.UGC NET / GATE OSMCQMEDIUM
+2 Marks • -0.67 Neg

A system has 33 processes, each requiring at most 44 identical units of resource RR. What is the minimum number of units of RR that guarantees the system is always deadlock-free?

Previous TopicSyntax-Directed Translation (SDT), Three-Address Code & Register LivenessNext Topic Virtual Memory, Multi-Level Paging & TLB Effective Access Time