Bird
Raised Fist0

When a CPU switches from running one thread to another within the same process, what sequence of events occurs internally?

easy🧠🧾 Concept Trace Q12 of Q15
Operating Systems - Process vs Thread - Key Differences
When a CPU switches from running one thread to another within the same process, what sequence of events occurs internally?
AThe OS terminates the current thread and creates a new thread for the next task
BThe OS saves the entire process state and reloads it for the new thread
CThe OS flushes the process's memory cache and reloads it for the new thread
DThe OS saves the thread's CPU registers and stack pointer, then loads the next thread's registers and stack pointer
Step-by-Step Solution
  1. Step 1: Identify what is saved during thread context switch

    Only the CPU registers and stack pointer specific to the thread are saved and restored, since threads share the process memory space.
  2. Step 2: Understand process state remains unchanged

    The process's memory and resources remain intact; no need to save or reload the entire process state.
  3. Step 3: Evaluate options

    The OS saves the entire process state and reloads it for the new thread incorrectly saves the entire process state. The OS flushes the process's memory cache and reloads it for the new thread incorrectly flushes memory cache. The OS terminates the current thread and creates a new thread for the next task incorrectly terminates and recreates threads.
  4. Final Answer:

    Option D -> Option D
  5. Quick Check:

    Thread context switch saves/restores thread-specific CPU state only [OK]
Quick Trick: Thread switch saves CPU registers, not whole process state [OK]
Common Mistakes:
MISTAKES
  • Confusing process context switch with thread context switch
  • Assuming memory cache must be flushed on thread switch
  • Believing threads are terminated and recreated on each switch
Trap Explanation:
PITFALL
  • Candidates often confuse process and thread context switching, leading to overestimating overhead.
Interviewer Note:
CONTEXT
  • Tests understanding of the internal mechanics of thread context switching versus process switching.
Master "Process vs Thread - Key Differences" in Operating Systems

2 interactive learning modes - each teaches the same concept differently

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Operating Systems Quizzes