---
title: "Processes, Context Switches and What They Cost"
description: "A process is a running program plus everything the kernel remembers about it: registers, memory map, open files. Swapping one for another means saving all of that and loading another set, which is che"
canonical: https://lightmysky.com/learn/computing/processes-context-switches-and-what-they-cost-mt_oiOwHKUoXG
source: https://lightmysky.com/learn/computing/processes-context-switches-and-what-they-cost-mt_oiOwHKUoXG.md
retrieved: 2026-09-12
---

> **Agent view.** This is the Markdown twin of the page, for tools and assistants.
> When to use this site, and the call that answers each job: https://lightmysky.com/agent-instructions.md
> API description (OpenAPI 3.1): https://lightmysky.com/openapi.json · Authentication: https://lightmysky.com/auth.md
> Pricing: https://lightmysky.com/pricing.md · Catalog: https://lightmysky.com/llms.txt · Full catalog: https://lightmysky.com/llms-full.txt
> Every machine-readable file on this domain: https://lightmysky.com/.well-known/ai-catalog.json
> Ask for Markdown with `Accept: text/markdown`, a `.md` address, or `?mode=agent`.

# Processes, Context Switches and What They Cost

A process is a running program plus everything the kernel remembers about it: registers, memory map, open files. Swapping one for another means saving all of that and loading another set, which is cheap in instructions and expensive in lost cache.

Subject: Computing · Area: Computer Systems · Ages 19 to 20
Page: https://lightmysky.com/learn/computing/processes-context-switches-and-what-they-cost-mt_oiOwHKUoXG

## Ready when they can

- List what the kernel has to save and restore on a context switch
- Follow a process through the ready, running and blocked states
- Explain why a switch costs more than the register copying suggests

## Lesson: What a context switch really moves

A process is a program while it runs, plus everything the kernel remembers about it: its registers, its memory map, and its open files. Your music player is one process and your browser is another.

A context switch pauses one process and starts another. The kernel saves the old state, loads the saved state of the next process, and jumps back in. A process waits in ready, owns a processor in running, and stalls in blocked until an event like disk data arrives.

**Example.** Copying registers is only a handful of quick moves, yet the switch still costs a lot. The cache is full of the old process data, so the new process fetches its own instructions slowly from main memory until the cache warms up again. That cold cache is the hidden bill.

**Tip.** Switching too often pays that bill again and again, so the processor refetches instead of working. In the tiny teaching system xv6 you can watch the scheduler save one set of registers, load the next, and resume.

**Recap.** A switch saves registers, maps, and files, then pays a cold cache bill, so too many switches slow the machine.

## Practice

8 questions on this page, each with its working shown.

## Needs first

- [The Memory Hierarchy and Why Caching Works](https://lightmysky.com/learn/computing/the-memory-hierarchy-and-why-caching-works-mt_0f5ArFPlxP)
- [What an Operating System Is: Privilege and System Calls](https://lightmysky.com/learn/computing/what-an-operating-system-is-privilege-and-system-calls-mt_0kMavEKxpX)

## Opens up

- [Virtual Memory and Address Translation](https://lightmysky.com/learn/computing/virtual-memory-and-address-translation-mt_B-PiAyderj)
- [Scheduling: Deciding Which Process Runs Next](https://lightmysky.com/learn/computing/scheduling-deciding-which-process-runs-next-mt_QZYzfVIcP6)
