GATE CS Operating System: 5 chapters, 48 previous year questions (100% of Operating System), 1332 practice questions and one solved question from each chapter
A question from this chapter
Question 1
Level 3: Exam Standard
A single-threaded process P1 executes a read system call. While in kernel mode handling this call, a hardware timer interrupt occurs, causing a context switch to process P2. P2 is currently in the Ready state and was last running in user mode. After P2 executes for a while, it is preempted, and P1 is resumed, eventually returning to user mode. What is the minimum number of times the hardware mode bit changes state (from User to Kernel or Kernel to User) from the moment P1 executes the read instruction until P1 resumes its next user instruction?
Question 2
Level 3: Exam Standard
Four processes P1,P2,P3,P4 arrive at times 0,2,4,5 with CPU burst times 7,3,2,6 respectively. The system uses Shortest Remaining Time First (SRTF) scheduling. Ignore context switching overhead. What is the sum of the response times of all four processes?
Question 3
Level 3: Exam Standard
A system has 4 processes sharing a single resource type. The maximum resource demands of the processes are 3, 5, 6, and 8 instances respectively. What is the minimum number of total resource instances required to guarantee that the system is completely deadlock-free under any possible allocation?
Question 4
Level 3: Exam Standard
Consider a system with a Translation Lookaside Buffer (TLB) and a two-level page table. The TLB hit ratio is 0.8. The TLB access time is 10 ns, and the main memory access time is 100 ns. Assume TLB and memory accesses are sequential. On a TLB miss, the system takes 2 memory accesses to walk the two-level page table, followed by 1 memory access to fetch the data. The page fault rate is zero. The Effective Access Time (in ns) is _________.
Question 5
Level 3: Exam Standard
A file system supports both contiguous and linked allocation. Match the following file operations with the number of disk accesses required to perform them. Assume the File Control Block (FCB) is already in memory, and the data block to be inserted is already in memory. The insertion point is between the k-th and (k+1)-th block of a file.
List I (Operation)
P. Contiguous allocation, insert at k=50 in a 100-block file
Q. Linked allocation, insert at k=50 in a 100-block file
R. Contiguous allocation, insert at k=100 in a 100-block file
S. Linked allocation, insert at k=100 in a 100-block file
List II (Disk Accesses)
1
53
101
103
Options:
A. P-3, Q-2, R-1, S-4
B. P-3, Q-4, R-1, S-2
C. P-2, Q-3, R-1, S-4
D. P-3, Q-2, R-4, S-1
Free preview ends here
Login to view the complete practice questions and solutions
Creating an account is free. You get the rest of this chapter, step-by-step solutions, and a study plan built around the topics you are actually weak at.
Most platforms hand everyone the same content. Here the content moves with your performance, topic by topic.
Built around you, not around a syllabus PDF
Every answer you give moves your topic-level intelligence rate. The next question, the next revision card and tomorrow's plan all change with it.
Revision that hits your weak spots
We only revise topics you have actually attempted and are still below the safe bar on — never the same chapter on repeat.
Questions calibrated to the real exam
Each question carries a measured toughness. You are served a rung above your current level, so practice keeps stretching you.
Notes written for recall, not for volume
Full lesson cards for first study, curated short-note cards for the last mile — with derivations, traps and exam patterns marked.
One place for everything
Notes, chapter practice, previous-year questions, test series and full-length papers — all feeding one picture of your preparation.
Honest progress
No vanity streaks. Progress here means chapters mastered and accuracy that held up on harder questions.
Unlock the whole course
Full notes and short notes, the complete question bank with worked solutions, mock tests, full-length papers, and an adaptive plan that rebuilds itself as you improve.
GATE CS Operating System: 5 chapters, 48 previous year questions (100% of Operating System), 1332 practice questions and one solved question from each chapter.
About Operating System Practice Questions
1332 practice questions for Operating System in GATE CS, sorted chapter by chapter and graded from basic to exam level, each with a full solution.
Operating System Weightage in GATE CS
Operating System accounts for 48 of 48 Operating System previous year questions in our bank (100%), about 4.8 per paper across 10 papers.
Process States, Ready Queues and Context Switching, Threads and Thread Context, System Calls and User-kernel Mode Transitions, Process Creation Using Fork and Wait
Sjf and Srtf Scheduling Metrics, Scheduling Properties, Preemption and Starvation, Round Robin Scheduling and Context-switch Sequences, Priority and Multiprocessor Scheduling
One Solved Question from Each Operating System Chapter
Question 1 · Processes, Threads, System Calls and Context SwitchingMCQ
A single-threaded process P1 executes a read system call. While in kernel mode handling this call, a hardware timer interrupt occurs, causing a context switch to process P2. P2 is currently in the Ready state and was last running in user mode. After P2 executes for a while, it is preempted, and P1 is resumed, eventually returning to user mode. What is the minimum number of times the hardware mode bit changes state (from User to Kernel or Kernel to User) from the moment P1 executes the read instruction until P1 resumes its next user instruction?
A.
2
B.
4
C.
6
D.
8
Correct Answer:
B
Step-by-Step Solution
Key idea: This is a minimum-value question testing the exact sequence of mode bit changes during system calls, interrupts, and context switches.
Step 1: P1 executes read. This is a synchronous software trap. The mode bit changes from User to Kernel. (Change 1)
Step 2: A timer interrupt occurs. P1 is already in Kernel mode. The interrupt handler runs in Kernel mode. No mode bit change occurs here.
Step 3: The OS scheduler switches to P2. P2 was last running in User mode. To resume P2, the mode bit must change from Kernel to User. (Change 2)
Step 4: P2 runs in User mode until it is preempted. Preemption involves a timer interrupt or software trap, forcing P2 into Kernel mode. The mode bit changes from User to Kernel. (Change 3)
Step 5: The OS switches back to P1. P1 needs to return to its user-mode instruction after the read completes. The mode bit changes from Kernel to User. (Change 4)
Step 6: Total minimum mode bit changes = 4.
Answer: B
Question 2 · CPU SchedulingMCQ
Four processes P1,P2,P3,P4 arrive at times 0,2,4,5 with CPU burst times 7,3,2,6 respectively. The system uses Shortest Remaining Time First (SRTF) scheduling. Ignore context switching overhead. What is the sum of the response times of all four processes?
A.
8
B.
13
C.
31
D.
10
Correct Answer:
A
Step-by-Step Solution
Key idea: Response time is the duration from arrival until the first CPU allocation. Once a process gets the CPU for the first time, its response time is locked — preemptions afterward do not affect it. This is a SRTF trace where you must carefully track the first allocation instant for each process.
Step 1: Build the SRTF Gantt chart by tracking remaining burst times (RBT) at every arrival event.
t=0: Only P1 has arrived. P1 starts. First allocation of P1 is at t=0.
t=2: P1 has RBT =5. P2 arrives with BT =3. Since 3<5, P2 preempts P1. First allocation of P2 is at t=2.
t=4: P2 has RBT =1. P3 arrives with BT =2. Since 2>1, no preemption. P2 continues.
t=5: P2 finishes (CT =5). P4 arrives. Ready queue: P1 (RBT =5), P3 (RBT =2), P4 (RBT =6). Minimum RBT is P3. P3 starts. First allocation of P3 is at t=5.
t=12: P1 finishes (CT =12). P4 starts. First allocation of P4 is at t=12.
t=18: P4 finishes (CT =18).
Step 2: Compute response times.
RT1=0−0=0
RT2=2−2=0
RT3=5−4=1
RT4=12−5=7
Step 3: Sum =0+0+1+7=8.
Answer: 8
Question 3 · Concurrency, Synchronization and DeadlocksMCQ
A system has 4 processes sharing a single resource type. The maximum resource demands of the processes are 3, 5, 6, and 8 instances respectively. What is the minimum number of total resource instances required to guarantee that the system is completely deadlock-free under any possible allocation?
A.
18
B.
22
C.
19
D.
23
Correct Answer:
C
Step-by-Step Solution
Key idea: This is a "minimum resources to prevent deadlock" question, recognizable because it asks for the absolute minimum instances to guarantee a deadlock-free state across multiple processes with varying maximum demands.
Step 1: Identify the worst-case scenario for deadlock. This occurs when every process holds exactly one less than its maximum demand and is waiting for exactly one more instance.
Step 2: Calculate the resources tied up in this worst case. For demands 3, 5, 6, and 8, the held instances are (3−1)+(5−1)+(6−1)+(8−1)=2+4+5+7=18.
Step 3: Add exactly 1 more resource instance to the system. This single instance guarantees that at least one process can acquire its final needed resource, finish execution, and release all its held resources, thereby breaking the deadlock chain.
Step 4: Total minimum resources = 18+1=19.
Answer: 19
Question 4 · Memory Management, Paging and Virtual MemoryNAT
Consider a system with a Translation Lookaside Buffer (TLB) and a two-level page table. The TLB hit ratio is 0.8. The TLB access time is 10 ns, and the main memory access time is 100 ns. Assume TLB and memory accesses are sequential. On a TLB miss, the system takes 2 memory accesses to walk the two-level page table, followed by 1 memory access to fetch the data. The page fault rate is zero. The Effective Access Time (in ns) is _________.
Correct Answer:
150.00
Step-by-Step Solution
Key idea: Effective Access Time (EAT) is the weighted average of hit and miss times, including all sequential memory accesses.
Step 1: Calculate hit time. TLB access + 1 memory access for data = 10+100=110 ns.
Step 3: Calculate EAT. EAT=(h×hit_time)+((1−h)×miss_time)=(0.8×110)+(0.2×310)=88+62=150 ns.
Answer: 150.00
Question 5 · File Systems and Storage AllocationMCQ
A file system supports both contiguous and linked allocation. Match the following file operations with the number of disk accesses required to perform them. Assume the File Control Block (FCB) is already in memory, and the data block to be inserted is already in memory. The insertion point is between the k-th and (k+1)-th block of a file.
List I (Operation)
P. Contiguous allocation, insert at k=50 in a 100-block file
Q. Linked allocation, insert at k=50 in a 100-block file
R. Contiguous allocation, insert at k=100 in a 100-block file
S. Linked allocation, insert at k=100 in a 100-block file
List II (Disk Accesses)
1
53
101
103
Options:
A. P-3, Q-2, R-1, S-4
B. P-3, Q-4, R-1, S-2
C. P-2, Q-3, R-1, S-4
D. P-3, Q-2, R-4, S-1
A.
P-3, Q-2, R-1, S-4
B.
P-3, Q-4, R-1, S-2
C.
P-2, Q-3, R-1, S-4
D.
P-3, Q-2, R-4, S-1
Correct Answer:
A
Step-by-Step Solution
Key idea: This is a disk access counting question for file insertion, recognizable by the specific allocation methods and insertion positions.
Step 1: For contiguous allocation, inserting at position k in an N-block file requires shifting blocks k+1 to N to the right. This takes N−k reads and N−k writes, plus 1 write for the new block. Total = 2(N−k)+1.
Step 2: For linked allocation, inserting at position k requires traversing the chain to the k-th block (k reads), reading the (k+1)-th block to get its pointer (1 read), writing the new block (1 write), and updating the k-th block's pointer (1 write). Total = k+3.