What calls pil_boot?
pil_boot function is called by the Linux kernel's startup code, which is responsible for initializing the kernel and transitioning it from its initial boot state (known as the "purgatory") to a fully operational state.
The startup code is typically located in a file called
arch/x86/boot/header.S in the Linux kernel source code. This file contains assembly language code that is executed by the boot loader (such as GRUB) to load the kernel image into memory and transfer control to the kernel's entry point.
Once the startup code has loaded the kernel image into memory and set up the initial environment for the kernel, it calls the
pil_boot function to perform further initialization of the kernel's core data structures and subsystems.
pil_boot has completed its initialization tasks, control is transferred to the
start_kernel function, which is responsible for starting the kernel's main execution loop and launching the init process.
pil_boot is a function that is defined in the Linux kernel source code. It is called during the boot process of the kernel, and is responsible for initializing the kernel's process ID (PID) and other core data structures.
pil_boot function is defined in the
arch/x86/kernel/purgatory/purgatory.c file of the Linux kernel source code. This file contains the implementation of the kernel's initial boot process, which is responsible for setting up the environment in which the kernel will run.
In particular, the
pil_boot function is responsible for performing the following tasks:
Initialize the kernel's process ID (PID): The
pil_bootfunction sets the initial process ID of the kernel to 0 (the PID of the init process).
Initialize the kernel's page table: The function sets up the initial page table for the kernel, which maps the kernel's virtual address space to the physical memory.
Initialize the kernel's interrupt handlers: The function initializes the interrupt handling routines that are used by the kernel to respond to hardware interrupts.
Initialize the kernel's memory management subsystem: The function initializes the kernel's memory management subsystem, which is responsible for managing the allocation and deallocation of system memory.
Initialize the kernel's scheduler: The function sets up the kernel's scheduler, which is responsible for scheduling tasks (processes and threads) to run on the CPU.
pil_boot is an important function in the Linux kernel that is responsible for initializing key data structures and subsystems that are required for the kernel to run properly. Without
pil_boot, the kernel would not be able to boot up and function correctly.
Did you say PURGATORY?
Yes, I did! The term "purgatory" in the context of the Linux kernel code refers to a temporary environment that the kernel runs in during its boot process. This environment is known as the "kernel purgatory" or simply "purgatory".
The kernel purgatory is a transitional phase between the boot loader (which is responsible for loading the kernel image into memory) and the fully operational kernel. During this phase, the kernel is not yet fully initialized and does not have access to all of its resources, such as the page table or interrupt handlers.
The term "purgatory" is used metaphorically to describe this transitional state, as it is often associated with a state of temporary suffering or purification before reaching a more permanent state. In the context of the Linux kernel code, "purgatory" refers to the transitional state of the kernel during the boot process, in which it is not yet fully operational but is in the process of initializing its key data structures and subsystems.
The name "purgatory" was coined by Rusty Russell, an Australian software engineer who contributed extensively to the development of the Linux kernel. The term has since become widely used in the Linux kernel community to refer to this transitional phase of the kernel boot process.