chapter

    Processes, Threads, System Calls and Context Switching Practice Questions for Gate Cs

    Solve 253+ Processes, Threads, System Calls and Context Switching practice questions for GATE CS with answers and detailed solutions. Free sample questions be

    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 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 ?

    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 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.

    Explore complete test series, official past papers, and chapter-wise study tools.

    Why MastersUp

    Personalised first. High quality throughout.

    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 Practice Questions for GATE CS

    Solve 253+ Processes, Threads, System Calls and Context Switching practice questions for GATE CS with answers and detailed solutions. Free sample questions below.

    Chapter Roadmap: Processes, Threads, System Calls and Context Switching

    Chapter Journey: 4 Topics, One Clear Path

    This chapter builds your understanding of how the operating system manages execution. Here is what you will master:

    Topic 1: Process States, Ready Queues and Context Switching (Current)
    • Understand the lifecycle of a process: new, ready, running, blocked, terminated
    • Learn how the OS maintains ready queues and decides which process runs next
    • Master context switching: what gets saved, what gets loaded, and the overhead involved
    • Foundation for everything else in this chapter
    Topic 2: Threads and Thread Context
    • Threads as lightweight units of execution within a process
    • What threads share versus what they keep private
    • Thread context switching versus process context switching
    Topic 3: System Calls and User-Kernel Mode Transitions
    • The boundary between user mode and kernel mode
    • How programs request OS services through system calls
    • The mechanism of mode transition and its triggers
    Topic 4: Process Creation using Fork and Wait
    • The fork system call: creating child processes
    • Understanding parent-child relationships
    • The wait system call: synchronization between processes
    What You Will Achieve:

    By the end of this chapter, you will be able to trace process state transitions, calculate context switch overhead, distinguish between process and thread behavior, predict the number of processes created by fork loops, and identify which operations trigger user-to-kernel mode transitions.

    What is a Process? The Unit of Execution

    Process = Program in Execution

    A process is a program in execution. It is the fundamental unit of work in a modern operating system.

    Program versus Process

    AspectProgramProcess
    NaturePassive entityActive entity
    StorageStored on diskLoaded in memory
    AnalogyRecipe in a cookbookThe act of cooking
    LifetimePermanent fileTemporary execution

    What Makes Up a Process?

    A process in memory contains:

    1. Text section: The compiled program code
    2. Program counter: Points to the next instruction to execute
    3. Stack: Temporary data, function parameters, return addresses, local variables
    4. Data section: Global variables
    5. Heap: Dynamically allocated memory (grows during execution)

    Process Control Block (PCB)

    The operating system tracks each process using a Process Control Block (PCB). Think of it as the process identity card. It contains:

    • Process state: current state (new, ready, running, blocked, terminated)
    • Program counter: address of next instruction
    • CPU registers: contents of all registers when process was last running
    • CPU scheduling information: priority, pointers to scheduling queues
    • Memory management information: base and limit registers, page tables
    • Accounting information: CPU time used, time limits, process number
    • I/O status information: list of I/O devices allocated, open files

    The PCB is the key data structure that allows the operating system to support multiple processes simultaneously.

    Processes, Threads, System Calls and Context Switching: Solved Questions with Step-by-Step Explanations (10 Problems)

    Question 1 · Operating System NAT

    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 System MSQ

    Which of the following process state transitions is/are strictly IMPOSSIBLE in the standard five-state process model, ignoring any non-standard OS optimizations?

    1. A.

      New to Ready

    2. B.

      Ready to Blocked

    3. C.

      Blocked to Running

    4. 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 System MSQ

    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.

    1. A.

      The total number of processes in Scenario (1) is strictly less than in Scenario (2).

    2. B.

      The total number of processes in Scenario (2) is strictly less than in Scenario (3).

    3. C.

      The total number of processes in Scenario (1) is greater than in Scenario (2).

    4. 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 sequential forks is total processes.

    Step 1: Calculate total processes for Scenario (1). , so total processes = .

    Step 2: Calculate total processes for Scenario (2). , so total processes = .

    Step 3: Calculate total processes for Scenario (3). , so total processes = .

    Step 4: Evaluate Option A. Is ? Yes. (True)

    Step 5: Evaluate Option B. Is ? Yes. (True)

    Step 6: Evaluate Option C. Is ? 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 . (False)

    Answer: Options A and B are true.

    Question 4 · Operating System NAT

    Consider a program that starts with a single initial process. It executes a loop that calls the fork() system call exactly 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 ?

    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 sequential fork() calls starting from 1 process.

    Step 2: Total processes = .

    Step 3: Total child processes = Total processes Initial process = .

    Step 4: Set up the equation based on the given value: .

    Step 5: Solve for : .

    Step 6: Solve for : Since , .

    Answer: 5.00

    Question 5 · Operating System MCQ

    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?

    1. A.

      0

    2. B.

      1

    3. C.

      2

    4. 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 System MCQ

    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.

    1. A.

      Both A and R are true, and R is the correct explanation of A.

    2. B.

      Both A and R are true, but R is NOT the correct explanation of A.

    3. C.

      A is true, but R is false.

    4. 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 System MCQ

    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?

    1. A.

      5

    2. B.

      6

    3. C.

      7

    4. 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)

    Step 2: Identify all I/O operations: 3 (scanf) + 2 (printf) + 1 (fopen) = 6 I/O operations.

    Step 3: Each I/O operation completion causes the process to re-enter the ready queue. (Count = 6)

    Step 4: Total ready queue entries = Initial entry + I/O completions = 1 + 6 = 7.

    Answer: C

    Question 8 · Operating System MCQ

    Which of the following events will ALWAYS trigger a context switch that results in the currently running process moving to a non-running state?

    1. A.

      The process executes a simple arithmetic instruction

    2. B.

      A timer interrupt occurs

    3. C.

      The process allocates memory from the heap

    4. 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 System MCQ

    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?

    1. A.

      Heap memory

    2. B.

      Open file descriptors

    3. C.

      Program counter and stack

    4. 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 System MCQ

    During a context switch between two threads of the SAME process, which of the following components is saved and restored by the operating system?

    1. A.

      Page table base register

    2. B.

      Heap memory segment

    3. C.

      Program counter

    4. 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).

    Step 3: Select the private component.

    Answer: Program counter

    More practice questions in this unit