Operation System Journey

Review: 57

From Power On to Execution

The Operating System’s Journey

From Power On to Execution

Every time you press the power button on your computer, a complex and fascinating chain of events is initiated, ultimately leading to the launch of your favorite operating system, whether it’s Windows, Linux, or macOS. But what exactly happens? Let’s explore together.

The Moment of Power On - The Journey Begins

When you hit the power button, the first thing that occurs is the delivery of electrical current to all the hardware components of the computer. However, these components, without a primary coordinator, are incapable of doing anything. This is where the BIOS (Basic Input/Output System), or its newer generation, UEFI (Unified Extensible Firmware Interface), comes into play. BIOS/UEFI is a small but vital piece of software residing on a non-volatile memory chip (typically flash memory) on the motherboard.

BIOS (Basic Input/Output System)

UEFI (Unified Extensible Firmware Interface)

The First Self-Test

Immediately after power-on, the BIOS/UEFI executes a series of diagnostic tests known as POST (Power On Self Test). These tests ensure that critical hardware components of the computer, such as the processor (CPU), Random Access Memory (RAM), graphics card, and even the keyboard, are correctly identified and activated. If an error occurs during POST (e.g., RAM is not properly seated), the BIOS/UEFI will typically alert you by emitting a series of specific beeps (beep codes) or displaying error codes on the screen (if the graphics card is active). This is the first step in ensuring the physical health of the system.

POST (Power On Self Test)

Beep codes

The Boot Process: Searching for the Commander

After the successful completion of POST, the BIOS/UEFI embarks on its next critical task: finding a system it can orchestrate. This system is, of course, our operating system. The BIOS/UEFI consults a list of storage devices (such as hard drives, SSDs, optical drives, or even USB drives) that are configured for booting (the Boot Order).

How is this search conducted? Every bootable storage device has crucial information at its very beginning. In older systems, this information was located in the Master Boot Record (MBR). The MBR is a small area at the start of the disk containing executable code (boot code) and the disk’s partitioning table. The MBR’s boot code is responsible for finding the active partition and loading the first part of the operating system (known as the boot sector or Volume Boot Record - VBR).

In more modern systems utilizing UEFI, this process is slightly different. Instead of MBR, UEFI uses a special partition called the EFI System Partition (ESP), which contains the bootloader’s executable files. UEFI directly executes these files.

The key point here is that the BIOS/UEFI (or the initial bootloader invoked by them) can detect if a storage device contains a recognizable operating system by reading the first few bytes from the storage device. These bytes typically include a specific signature (like 0xAA55 at the end of the MBR) and initial information to commence the loading process. If the BIOS/UEFI doesn’t find a recognizable operating system on the first device, it moves on to the next device in the Boot Order list until it finally finds the desired operating system.

Operating System (OS)

Master Boot Record (MBR)

Boot Order

Partition (MBR, UEFI)

Boot Sector (Volume Boot Record - VBR)

Finding and Loading the Operating System - The Crowning Moment

After the BIOS/UEFI has successfully identified the device containing the operating system, it’s the Bootloader’s turn. The Bootloader is a small program whose primary job is to load the core of the operating system (the Kernel) from the disk into the main memory (RAM) and then hand over control of the computer to it.

Entering the Operating System World

Depending on the type of operating system and how it’s installed, various Bootloaders exist. For example:

In Windows systems, BOOTMGR (Boot Manager) plays the primary role. In the Linux world, GRUB (GRand Unified Bootloader) is very common and also allows for selecting between different operating systems (if multiple are installed). Even macOS has its own specific Bootloaders. After being activated by the BIOS, it begins its work. Its main goal is to find the critical files of the operating system’s core (Kernel). These files are typically located in specific folders on the disk.

For example:

Windows (c:\Windows\System32) Linux (boot/)

Loading the Kernel into RAM: Moving the Soldiers to the Front Lines

As mentioned in the previous section, the computer needs Random Access Memory (RAM) to execute programs and the operating system. RAM operates much faster than any storage disk, so it’s essential for the operating system’s code and data to be loaded into RAM before execution.

The Bootloader is responsible for reading the Kernel file(s) and other necessary operating system modules from the disk and placing them in a designated area of RAM. This process is akin to a commander moving the essential orders and soldiers to the front lines (RAM) to prepare for battle.

At this stage, more complex concepts like Physical Address Space and Virtual Address Space also come into play. RAM has unique physical addresses. The operating system uses an abstraction layer called virtual address space to give each process an independent address space, often larger than the actual physical RAM. Managing these spaces and mapping between virtual and physical addresses is one of the key tasks of the operating system, a part of which begins during these initial stages by the Kernel.

Once the Bootloader ensures the Kernel and its necessary components are in RAM, it hands over control of the computer to the Kernel. This moment is the turning point of the journey; it’s when the operating system effectively “comes alive” and is ready to take full command of the system.

Power > BIOS/UEFI > Bootloader > Kernel > Init (Process 1)

graph TD
    A[Power On] --> B(BIOS/UEFI);
    B --> C{POST};
    C -- Success --> D[Bootloader];
    C -- Failure --> E[Error Beep/Code];
    D --> F[/Detect Boot Device/];
    F --> G[Load Kernel to RAM];
    G --> H(Kernel Initialization);
    H --> I[Memory Management];
    H --> J[Hardware Drivers];
    H --> K(Init Process - PID 1);
    K --> L[Load Services];
    K --> M[Load Display Manager];
    M --> N[Login Screen];
    N --> O[User Session];

  • Power On: Process begins with powering on the device.
  • BIOS/UEFI: The first software to execute.
  • POST (Power On Self Test): Initial hardware testing.
  • Bootloader: Program that loads the Kernel.
  • Detect Boot Device: Identifying the device where the operating system is installed.
  • Load Kernel to RAM: Transferring the Kernel to main memory.
  • Kernel Initialization: Initial setup of the Kernel.
  • Memory Management: Setting up the memory management system.
  • Hardware Drivers: Loading hardware drivers.
  • Init Process (PID 1): The first system process to run.
  • Load Services: Starting necessary system services.
  • Load Display Manager: Loading the display manager for the graphical interface.
  • Login Screen: Displaying the user login screen.
  • User Session: User’s session begins, and the system is ready for use.
  • Error Beep/Code: In case of an error during POST.
An unhandled error has occurred. Reload 🗙

Rejoining the server...

Rejoin failed... trying again in seconds.

Failed to rejoin.
Please retry or reload the page.

The session has been paused by the server.

Failed to resume the session.
Please reload the page.