Processes, Threads, System Calls and Context Switching Short Notes for Gate Cs
Processes, Threads, System Calls and Context Switching short notes for GATE CS: 5 study cards covering concepts, formulas, shortcuts and exam traps, plus solv
Processes Threads System Calls and Context Switching short notes
State Transition Cheat Sheet: Quick Reference
Process States and Context Switching: Quick Reference
Five States
New: Being created
Ready: Waiting for CPU
Running: Executing instructions
Blocked: Waiting for event (I/O, signal, resource)
One-line exam method: For any thread option, ask: per-thread or per-process, and does this cross into the kernel?
2 more cards in this chapter
Try a question
Answer it here to see how it works. Nothing is recorded until you sign in.
Question 1
Level 1: Warm-up
In the standard five-state process model, a process is currently in the 'Running' state. How many distinct valid state transitions are possible directly from the 'Running' state?
Question 2
Level 1: Warm-up
Which of the following process state transitions is/are strictly IMPOSSIBLE in the standard five-state process model, ignoring any non-standard OS optimizations?
Question 3
Level 1: Warm-up
Consider three scenarios starting with a single initial process. Which of the following statements regarding the total number of processes (parent + children) existing after the operations complete is/are TRUE?
(1) The process executes fork() exactly once.
(2) The process executes fork() sequentially exactly twice.
(3) The process executes fork() sequentially exactly three times.
Question 4
Level 1: Warm-up
Consider a program that starts with a single initial process. It executes a loop that calls the fork() system call exactly k times sequentially, with no conditional breaks or wait() calls. Assuming all fork() calls are successful, if the total number of child processes created is 31, what is the value of k?
Question 5
Level 1: Warm-up
In a single-CPU system with no I/O devices, what is the maximum number of processes that can be simultaneously in the 'Running' state?
Question 6
Level 1: Warm-up
Assertion (A): Context switching is considered pure overhead in an operating system.
Reason (R): During a context switch, the CPU executes instructions that do not advance the execution of any user process.
Question 7
Level 1: Warm-up
Consider a process that starts execution, performs 3 scanf operations, 2 printf operations, and 1 fopen operation before terminating normally. Assuming the process enters the ready queue initially and after every I/O operation completion, how many times does this process enter the ready queue during its entire lifetime?
Question 8
Level 1: Warm-up
Which of the following events will ALWAYS trigger a context switch that results in the currently running process moving to a non-running state?
Question 9
Level 1: Warm-up
In a multithreaded process, which of the following resources is strictly private to each individual thread and is NOT shared among threads of the same process?
Question 10
Level 1: Warm-up
During a context switch between two threads of the SAME process, which of the following components is saved and restored by the operating system?
Free preview ends here
Login to view the complete short notes
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.
Processes, Threads, System Calls and Context Switching Short Notes for GATE CS
Processes, Threads, System Calls and Context Switching short notes for GATE CS: 5 study cards covering concepts, formulas, shortcuts and exam traps, plus solved practice questions.
State Transition Cheat Sheet: Quick Reference
Process States and Context Switching: Quick Reference
Five States
New: Being created
Ready: Waiting for CPU
Running: Executing instructions
Blocked: Waiting for event (I/O, signal, resource)
One-Line Exam Method: To determine if an event guarantees a transition, ask: Does this absolutely require privileged hardware access or OS intervention?
Processes, Threads, System Calls and Context Switching: Solved Questions with Step-by-Step Explanations (10 Problems)
Question 1 · Operating SystemNAT
In the standard five-state process model, a process is currently in the 'Running' state. How many distinct valid state transitions are possible directly from the 'Running' state?
Correct Answer:
3.00
Step-by-Step Solution
Key idea: This is a state transition diagram recall question, recognizable because it asks for valid moves from a specific state.
Step 1: Identify the current state: Running.
Step 2: List all valid outgoing transitions from the Running state:
Running → Ready (due to preemption or time quantum expiry)
Running → Blocked (due to I/O request or waiting for an event)
Running → Terminated (due to process completion or exit)
Step 3: Count the valid transitions. There are exactly 3.
Answer: 3.00
Question 2 · Operating SystemMSQ
Which of the following process state transitions is/are strictly IMPOSSIBLE in the standard five-state process model, ignoring any non-standard OS optimizations?
A.
New to Ready
B.
Ready to Blocked
C.
Blocked to Running
D.
Blocked to Terminated
Correct Answer:
["B","C","D"]
Step-by-Step Solution
Insight: The standard five-state model has strict rules: only Running processes can block or terminate, and Blocked processes must wake up to Ready first.
Exam route: Evaluate each transition. New → Ready is allowed. Ready → Blocked is impossible (must be Running). Blocked → Running is impossible (must go through Ready). Blocked → Terminated is impossible (must wake up first).
Learning route: The OS enforces state boundaries. A process in the Ready state is waiting for the CPU, so it cannot block (it is not executing anything to request I/O). A process in the Blocked state is waiting for an event; it cannot run or terminate until that event occurs and the OS moves it to the Ready queue. Thus, B, C, and D are impossible.
Wrong path: Assuming a process can terminate directly from Blocked (ignoring the constraint that it must be cleaned up after running or being explicitly killed from Ready/Running), leading to missing D.
Question 3 · Operating SystemMSQ
Consider three scenarios starting with a single initial process. Which of the following statements regarding the total number of processes (parent + children) existing after the operations complete is/are TRUE?
(1) The process executes fork() exactly once.
(2) The process executes fork() sequentially exactly twice.
(3) The process executes fork() sequentially exactly three times.
A.
The total number of processes in Scenario (1) is strictly less than in Scenario (2).
B.
The total number of processes in Scenario (2) is strictly less than in Scenario (3).
C.
The total number of processes in Scenario (1) is greater than in Scenario (2).
D.
The total number of processes in Scenario (3) is exactly 6.
Correct Answer:
["A","B"]
Step-by-Step Solution
Key idea: Each sequential fork() call doubles the total number of processes. The formula for n sequential forks is 2n total processes.
Step 1: Calculate total processes for Scenario (1). n=1, so total processes = 21=2.
Step 2: Calculate total processes for Scenario (2). n=2, so total processes = 22=4.
Step 3: Calculate total processes for Scenario (3). n=3, so total processes = 23=8.
Step 4: Evaluate Option A. Is 2<4? Yes. (True)
Step 5: Evaluate Option B. Is 4<8? Yes. (True)
Step 6: Evaluate Option C. Is 2>4? No. (False)
Step 7: Evaluate Option D. Is the total for Scenario (3) equal to 6? No, it is 8. The value 6 comes from the incorrect linear formula 2×3. (False)
Answer: Options A and B are true.
Question 4 · Operating SystemNAT
Consider a program that starts with a single initial process. It executes a loop that calls the fork() system call exactly k times sequentially, with no conditional breaks or wait() calls. Assuming all fork() calls are successful, if the total number of child processes created is 31, what is the value of k?
Correct Answer:
5.00
Step-by-Step Solution
Key idea: Use the exponential formula for sequential fork() calls to relate the number of calls to the total number of processes.
Step 1: Recall the formula for k sequential fork() calls starting from 1 process.
Step 2: Total processes = 2k.
Step 3: Total child processes = Total processes − Initial process = 2k−1.
Step 4: Set up the equation based on the given value: 2k−1=31.
Step 5: Solve for 2k: 2k=32.
Step 6: Solve for k: Since 25=32, k=5.
Answer: 5.00
Question 5 · Operating SystemMCQ
In a single-CPU system with no I/O devices, what is the maximum number of processes that can be simultaneously in the 'Running' state?
A.
0
B.
1
C.
2
D.
Depends on the scheduling algorithm
Correct Answer:
B
Step-by-Step Solution
Key idea: This tests the fundamental constraint of the 'Running' state in the five-state process model.
Step 1: Recall the definition of the 'Running' state: instructions are being executed.
Step 2: A single-CPU system has exactly one processing unit.
Step 3: Therefore, only ONE process can be actively executing instructions on that single CPU at any given instant.
Answer: B
Question 6 · Operating SystemMCQ
Assertion (A): Context switching is considered pure overhead in an operating system.
Reason (R): During a context switch, the CPU executes instructions that do not advance the execution of any user process.
A.
Both A and R are true, and R is the correct explanation of A.
B.
Both A and R are true, but R is NOT the correct explanation of A.
C.
A is true, but R is false.
D.
A is false, but R is true.
Correct Answer:
A
Step-by-Step Solution
Key idea: This tests the conceptual understanding of context switching and its impact on system performance.
Step 1: Evaluate Assertion (A): Context switching involves saving and loading state, which consumes CPU cycles without doing useful work for the user. Thus, it is pure overhead. (True)
Step 2: Evaluate Reason (R): During this save/load phase, the CPU is executing OS kernel instructions, not the instructions of any user process. (True)
Step 3: Check the link: R directly explains why A is true. The lack of progress for user processes is the very definition of this overhead.
Answer: A
Question 7 · Operating SystemMCQ
Consider a process that starts execution, performs 3 scanf operations, 2 printf operations, and 1 fopen operation before terminating normally. Assuming the process enters the ready queue initially and after every I/O operation completion, how many times does this process enter the ready queue during its entire lifetime?
A.
5
B.
6
C.
7
D.
8
Correct Answer:
C
Step-by-Step Solution
Key idea: This tests the formula for counting ready queue entries based on I/O operations.
Step 1: Identify the initial entry: The process enters the ready queue once when it is first created/admitted. (Count = 1)
Which of the following events will ALWAYS trigger a context switch that results in the currently running process moving to a non-running state?
A.
The process executes a simple arithmetic instruction
B.
A timer interrupt occurs
C.
The process allocates memory from the heap
D.
The process reads a variable from its own stack
Correct Answer:
B
Step-by-Step Solution
Key idea: This tests the specific events that force the OS to perform a context switch.
Step 1: Evaluate option A: Executing an arithmetic instruction is a normal user-mode action and does not trap to the OS. (False)
Step 2: Evaluate option B: A timer interrupt forces the OS to regain control and evaluate if the current process should be preempted, always triggering a context switch or preemption check. (True)
Step 3: Evaluate option C: Heap allocation is typically handled in user space and does not "always" trigger a switch. (False)
Step 4: Evaluate option D: Reading from the stack is a standard user-mode instruction. (False)
Answer: B
Question 9 · Operating SystemMCQ
In a multithreaded process, which of the following resources is strictly private to each individual thread and is NOT shared among threads of the same process?
A.
Heap memory
B.
Open file descriptors
C.
Program counter and stack
D.
Global variables
Correct Answer:
C
Step-by-Step Solution
Key idea: This tests the distinction between shared process resources and private thread state.
Step 1: Recall that threads within the same process share the process's address space and resources.
Step 2: Identify the shared resources: Heap memory, open file descriptors, and global variables (data segment) are all shared.
Step 3: Identify the private resources: Each thread must maintain its own independent execution state, which includes its own Program Counter (PC), CPU registers, and Stack.
Answer: C
Question 10 · Operating SystemMCQ
During a context switch between two threads of the SAME process, which of the following components is saved and restored by the operating system?
A.
Page table base register
B.
Heap memory segment
C.
Program counter
D.
Open file descriptor table
Correct Answer:
C
Step-by-Step Solution
Key idea: During a thread context switch, only the private state of the thread is saved. Shared process resources are untouched.
Step 1: Identify the components listed.
Step 2: Classify each as private (PC, registers, stack) or shared (page table, heap, open files).