Introduction

Modern computing relies heavily on concurrency and multitasking to optimize system performance. While most people associate concurrency with multi-core processors, threads play a crucial role even on single-core CPUs. To understand why, we need to explore the concepts of processes, CPU scheduling, blocking operations, and how threads provide an efficient alternative to traditional multi-process approaches.


What is a Process?

A process is an instance of a running program. When you execute an application, the operating system creates a process to manage its execution. Each process has its own:


How the CPU Handles Multiple Processes

A single-core CPU can only execute one instruction at a time. However, modern operating systems create an illusion of simultaneous execution through context switching. The scheduler rapidly switches the CPU between different processes, allowing each process to make progress over time. This is known as concurrency.

Context Switching

Context switching is the process of storing the current state of a running process or thread and restoring the state of another process or thread so that execution can continue.