Operating systemsLesson 4 of 5 in the course Processes and scheduling

Context Switching: Scheduling, Interrupts, and Performance Costs

5 flashcards · 5 quiz questions · 5 match pairs · 5 fill-in sentences · English

Lesson progress
0 / 5

Your progress is kept in this browser only.Sign up to save it

Summary

A computer’s CPU can execute only a limited amount of work at a time, but an operating system can make multiple processes appear to run concurrently. This lesson explains how a context switch lets the CPU pause one process and resume another.

A process is a program that is currently executing. As it runs, it uses CPU registers and other state to keep track of its work. Important state includes the program counter, which identifies the next instruction, and the stack pointer, which identifies the current position in the process’s stack.

All flashcards

What is a context switch?
It is the operation of saving the state of one process or thread and restoring the saved state of another so the CPU can switch tasks.
What does the program counter record?
It records the location of the next instruction to execute, allowing a task to resume at the correct point.
What is a process control block (PCB)?
A PCB is an operating-system data structure that holds information needed to manage a process, including saved execution state such as registers and the program counter.
What is the ready queue used for?
It keeps track of processes that are ready to run, allowing the scheduler to choose one for CPU time.
How does a context switch support multitasking?
By saving one task and restoring another, the operating system lets multiple tasks take turns using the CPU and later resume their work.

Quiz questions

  1. In a pre-emptive system, what can happen when a process uses its full time slice?Answer: The scheduler may preempt it and let another task run.
  2. When an interrupt is handled, must the CPU switch to a different process?Answer: No; the interrupted process may resume after the handler finishes.
  3. What does a user-mode to kernel-mode transition establish by itself?Answer: A privilege-mode change, but not necessarily a process change.
  4. Why can switching between threads of one process require less work than switching between separate processes?Answer: Threads in one process share resources such as the virtual memory map.
  5. What interval does interrupt latency measure?Answer: The time from a hardware interrupt being generated until it is serviced.

Based on the Wikipedia article Context switch, licensed CC BY-SA 4.0. Adapted into a summary, flashcards and quizzes.

All Operating systems lessons