Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training,
learning paths, books, tutorials, and more.

Process Switch

To control the execution of processes, the kernel must be able to
suspend the execution of the process running on the CPU and resume
the execution of some other process previously suspended. This
activity goes variously by the names process switch
, task switch
, or context switch
. The next sections describe the elements
of process switching in Linux.

Hardware Context

While each process can have its own
address space, all processes have to share the CPU registers. So
before resuming the execution of a process, the kernel must ensure
that each such register is loaded with the value it had when the
process was suspended.

The set of data that must be loaded into the registers before the
process resumes its execution on the CPU is called the
hardware context
. The hardware context is a subset of
the process execution context, which includes all information needed
for the process execution. In Linux, a part of the hardware context
of a process is stored in the process descriptor, while the remaining
part is saved in the Kernel Mode stack.

In the description that follows, we will assume the
prev local variable refers to the process
descriptor of the process being switched out and
next refers to the one being switched in to
replace it. We can thus define a process switch
as the activity consisting of saving the hardware context of
prev and replacing it with the hardware context of
next. Since process switches occur quite often, it is important to minimize the time spent ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training,
learning paths, books, interactive tutorials, and more.