Introduction
When operating Linux servers, you may encounter situations such as high CPU utilization, an increasing load average, or a rise in context switches. Although many people can check these metrics, surprisingly few can explain what is actually happening inside the CPU.
The CPU is the central component of a computer that processes instructions executed by applications. The Linux kernel, meanwhile, provides scheduling, interrupt handling, system calls, and many other mechanisms so that numerous processes can use the CPU fairly and efficiently.
Understanding how the CPU works enables you to systematically understand Linux internals, including why context switches occur, why system calls are necessary, and how interrupts are handled. This knowledge is valuable not only for daily operations and incident response, but also for gaining a deeper understanding of Linux.
This series begins with the CPU’s basic role and then explains, step by step, the relationship between processes and the scheduler, context switches, system calls, interrupts, CPU caches, and multicore CPUs in Linux.
This first article provides an accessible overview of the CPU—its role and its relationship with Linux—establishing the foundation for the entire series.
What Is a CPU?
The CPU (Central Processing Unit) is the component that executes program instructions in a computer. It functions much like the human brain, carrying out one operation after another as directed by applications.
For example, displaying directory contents with the ls command, copying a file with cp, and starting a service with systemctl may appear to be completely different operations. From the CPU’s perspective, however, all of them are accomplished by executing the instructions that make up a program.
The instructions executed by a CPU include the following.
- Arithmetic operations such as addition and subtraction
- Comparing data
- Reading from and writing to memory
- Conditional branching
- Loops
- Function calls
Even complex applications ultimately operate through combinations of these simple instructions.
Differences Between the CPU, Memory, and Storage
The CPU is responsible for executing operations, but it cannot run a program by itself. In practice, it works together with memory and storage.
Each component has the following role.
| Component | Primary role |
|---|---|
| CPU | Acts as the computer’s “brain,” executing program instructions and performing calculations and control operations |
| Memory (RAM) | Temporarily stores running programs and data so that the CPU can access them quickly |
| Storage (SSD/HDD) | Provides long-term storage that retains the OS, applications, and other data even when power is turned off |
For example, when a user runs the ls command, the executable on storage is mapped into the process’s virtual address space, and the instructions and data required for execution are loaded into memory. The CPU then executes those instructions in sequence, retrieves information about the directory, and displays the result on standard output.
The CPU, memory, and storage therefore have distinct roles and work together to operate the computer.
The CPU’s Role in Linux
Many processes and threads run concurrently on Linux. Fundamentally, however, each CPU core can execute only one stream of work at a time.
The Linux kernel therefore manages which process receives CPU time. It provides mechanisms such as process switching, priority control, and interrupt handling to share the CPU efficiently.
By learning about the relationship between Linux and the CPU in sequence, we will examine in detail how the CPU executes programs.
Main Components of a CPU
Although a CPU may look like a single component, it contains circuitry with many different functions. By dividing responsibilities among these circuits, the CPU can execute program instructions at high speed.

The following sections briefly introduce the major components of a CPU.
Core
A core is the processing unit that actually executes program instructions.
Older CPUs had only one core, but multicore CPUs containing multiple cores are now common. An eight-core CPU, for example, can execute different instruction streams concurrently on each core. This enables high processing performance even when multiple applications run at the same time.
On Linux, the CPU scheduler assigns processes and threads to individual cores, enabling efficient use of CPU resources.
Threads (SMT/Hyper-Threading)
SMT (Simultaneous Multithreading) is a technology that processes instructions from multiple threads concurrently on a single physical core. Linux recognizes each hardware thread as a logical CPU. Intel’s implementation is known as Hyper-Threading.
For example, when Hyper-Threading is enabled on a four-core CPU, Linux recognizes eight CPUs. Increasing the number of logical CPUs allows idle execution resources to be used more effectively and improves processing efficiency for many workloads.
This does not increase the number of physical cores to eight. Hardware threads on the same core share some resources, including execution units and caches.
Registers
Registers are extremely fast storage locations inside the CPU.
When performing calculations, the CPU commonly loads data from memory into registers and processes the values held there. Although registers have very limited capacity, their location inside the CPU makes them dramatically faster than main-memory access. Different registers serve different purposes, including the program counter and stack pointer.
Cache
CPU cache is high-speed storage that temporarily holds instructions and data used by the CPU.
Ordinarily, the CPU accesses main memory (RAM) to retrieve data. Because memory access is slow relative to CPU execution, accessing RAM for every operation would reduce performance. Data that has already been read is therefore kept in cache so that it can be accessed quickly when needed again.
A typical CPU has multiple cache levels known as the L1, L2, and L3 caches.
Control Unit
The control unit manages the CPU’s overall operation. It reads instructions from the program, determines how to execute them, and directs the various circuits inside the CPU.
For example, it controls sequences such as loading data into a register, performing a calculation in the ALU, and writing the result to memory.
The CPU can execute instructions in the correct order because the control unit coordinates the entire process.
ALU (Arithmetic Logic Unit)
The ALU (Arithmetic Logic Unit) is circuitry that performs calculations and comparisons. Specifically, it is responsible for operations such as the following.
- Addition and subtraction
- Multiplication and division (some of which may be handled by dedicated circuits)
- Greater-than and less-than comparisons
- Logical operations such as AND, OR, and XOR
Instructions such as “calculate 1 + 2” and “compare variables A and B” are executed by the ALU.
The CPU from Linux’s Perspective
The CPU executes program instructions, but the Linux kernel manages which program is assigned to the CPU and when.
Many processes and threads run concurrently on Linux. The kernel therefore uses the CPU scheduler to select the next runnable process or thread to execute.
When switching execution targets, Linux saves the current state and restores the state of the next process or thread. This operation is called a context switch.
When an application needs to read or write a file, communicate over a network, or perform another privileged operation, it requests the operation from the Linux kernel through a system call.
Events generated by devices, such as the arrival of a network packet or completion of storage I/O, are reported to the CPU through interrupts.
In this way, the Linux kernel uses the CPU efficiently by combining mechanisms such as CPU scheduling, context switching, system calls, and interrupts.
How a Program Runs on the CPU
We have explained the CPU’s role and its relationship with the Linux kernel. Let us now examine the overall sequence from launching a program on Linux to executing it on the CPU.

1. Execute a Program
Program execution begins when a user runs a Linux command or systemd starts a service. The Linux kernel then performs the preparations required to execute the specified program.
2. Create a Process or Thread
A process or thread is created to run the program, and the required execution information is prepared. Program code and data become accessible through the virtual address space, allowing the CPU to execute the program.
3. The CPU Scheduler Selects What to Run
Not all runnable processes and threads can use the CPU simultaneously. The CPU scheduler selects the next runnable process or thread to execute. As execution states change because of elapsed time, priorities, I/O waits, and other factors, the scheduler switches the execution target.
4. The CPU Executes Instructions
The process or thread selected by the CPU scheduler executes instructions on the CPU. The CPU reads each instruction and uses registers, the ALU, and other components to perform calculations, memory accesses, and related operations. The program advances by repeatedly performing this cycle.
5. Request Kernel Services Through System Calls
While running, a program may need OS functions such as file I/O, network communication, or memory allocation. It then uses a system call to request the operation from the Linux kernel. A system call is a synchronous operation initiated by the running program. Once the kernel operation has completed, control normally returns to the program and execution continues.
6. Handle Interrupts
Devices continue to generate events while the CPU is executing a program. Examples include receiving a network packet and completing storage I/O. When such an event is reported as an interrupt, the CPU temporarily suspends its current work and executes the required interrupt handler. A system call is a synchronous request from a program, whereas a hardware interrupt is an asynchronous event generated by a device or similar source.
7. Continue Program Execution
After a system call or interrupt has been handled, the CPU continues executing the program. It advances to the next instruction and repeats instruction fetching, calculations, memory accesses, and other operations. The program progresses through this repeated process.
8. Switch Execution Targets Through a Context Switch
The CPU does not always execute the same process or thread. It may need to be assigned to another process or thread because a time slice has expired, the current task is waiting for I/O, or a higher-priority task must run. The Linux kernel then saves the current execution state and restores the state of the next process or thread. This change of execution target is called a context switch. After the switch, the CPU begins executing the new process or thread selected by the scheduler.
Conclusion
The CPU is the central computer component that executes program instructions. The CPU alone, however, cannot run multiple applications efficiently. Linux makes effective use of the CPU through the coordinated operation of mechanisms such as CPU scheduling, process switching, context switches, system calls, and interrupts.
This article presented an overview of the CPU’s role and components, how Linux views the CPU, and the sequence through which a program is executed on it. Understanding CPU operation enables you to systematically understand what is happening inside Linux.


コメント