What is the loading of operating system into computer memory?

An operating system is a software program that manages computer hardware and software resources. It provides common services for applications and a user interface. The loading or booting process is what happens when a computer is turned on and the operating system is initialized and loaded into the computer’s main memory (RAM). This allows the computer to operate and run other programs. The loading process involves several key steps including starting the BIOS, running bootloaders, initializing kernel and drivers, starting services, and finishing with a login prompt.

This article will examine the key phases of the operating system loading process in detail.

BIOS

BIOS (Basic Input/Output System) plays a key role in loading the operating system. When a computer first powers on, the BIOS runs a power-on self test (POST) to ensure the hardware components like memory, drives, and CPU are functioning properly (Source).

The BIOS also initializes these system components and looks for boot devices like hard disks or USB drives. It contains firmware code and settings stored on the motherboard itself rather than the hard drive (Source).

After this hardware initialization, the BIOS loads and executes the bootloader that starts the operating system loading process. This handoff from firmware to software is a key role of the BIOS – it prepares the hardware and then boots the OS (Source). Without a functioning BIOS, the operating system could not load.

Bootloader

A bootloader is a small program that loads the operating system kernel into memory so that the computer can boot up [What is a bootloader? IONOS Digitalguide; 1&1 IONOS Inc.]. When a computer first turns on, the bootloader code that is stored in the master boot record of the hard drive gets executed. The bootloader has three main responsibilities:

  • Perform minimal hardware initialization and setup
  • Select the operating system to load
  • Load the kernel of the selected operating system into memory

Without a bootloader, an operating system cannot be loaded and the computer would not be functional. The bootloader allows the computer to get past initial startup and launch the operating system. Overall, the bootloader plays a crucial role in loading and initiating the operating system.

Kernel Initialization

Once the bootloader has loaded the operating system kernel into memory, the kernel takes control and begins its initialization process 1. The kernel performs several important tasks during initialization:

  • It initializes the CPU and memory management features like virtual memory, page tables, and scheduling.
  • It detects, initializes, and manages system hardware like disk drives, network interfaces, input/output devices, etc.
  • It loads essential device drivers required to interact with hardware.
  • It starts key operating system processes and services for memory management, task scheduling, file systems, networking, etc.
  • It creates and mounts the root file system containing critical system files.
  • It starts the first user space initialization process.

The kernel initialization puts the system into a usable state before any user applications start. The complexity and time taken depends on the kernel design, hardware, and configurations. Modern kernels aim to initialize quickly and transition to user space processes.

Hardware Initialization

Hardware initialization is the process where the operating system detects, identifies, and initializes the hardware components and devices connected to the computer during boot up [1]. This includes the CPU, memory, disk drives, graphics card, sound card, network card, and any other devices. The steps involved typically include:

  • Performing a power-on self test (POST) to check core system hardware.
  • Detecting and enumerating buses like PCI/PCIe to find connected devices.
  • Assigning IRQs, I/O ports, memory addresses to devices.
  • Initializing device drivers and firmware interfaces.
  • Activating and testing devices to confirm they are functioning.

Modern operating systems load generic drivers to activate basic device functionality. Specific proprietary drivers are loaded later to unlock full capabilities. The goal is to bring all hardware into an operational state so that the OS and applications can use the devices as needed.

Services and Daemons

Once the operating system kernel is initialized, it will start various background services and daemons. As explained by the Fedora Project documentation, “A daemon is a service process that runs in the background and supervises the system or provides functionality to other processes.” Some key daemons and services loaded at boot time include:

  • systemd – The init system and service manager.
  • NetworkManager – For managing network connections.
  • crond – To run cron jobs at scheduled times.
  • sshd – To allow remote login via SSH.

The systemd init system handles starting all these background daemons and services based on configuration files located in /etc/systemd. Using the systemctl command, you can manage services, start/stop them, enable/disable them from starting at boot, and check their current status.

User Space Initialization

In the Linux operating system, user space refers to the programs and libraries that interface with the kernel to perform tasks like input/output operations. After the kernel initializes, it begins loading the user space which contains the user applications and libraries. According to Wikipedia, “User space usually refers to the various programs and libraries that the operating system uses to interact with the kernel: software that performs input/output, manipulates files, handles network connections, etc.”

The kernel creates the first process called init which has a process ID of 1. The init process is responsible for initializing the user space by starting various scripts and services. As explained in this Medium article, “Init is the first user world process that runs in linux, It creates processes by starting scripts stored in /etc/inittab.” These init scripts mount filesystems, start daemons, run shell scripts, and get everything ready for users to log in.

Initializing user space allows users to interact with a fully functional operating system. Once the user space is loaded, the system displays a login prompt and waits for users to log in. At this stage, the operating system is considered to be fully booted up and operational.

Login Prompt

After the operating system has initialized and loaded all the necessary services and daemons, it will present the login prompt for the user to enter their credentials. This is the final step before the graphical user interface loads and the desktop environment becomes accessible. The login prompt typically displays the hostname and asks the user to enter their username and password.

For example, on a Windows machine, the login prompt may display “DESKTOP-abcd1234” and ask the user to “Press Ctrl+Alt+Delete to unlock this computer.” The user would then need to press Ctrl+Alt+Delete and enter their Windows username and password to proceed. On Linux and Mac machines, the login prompt is typically a simple text prompt that says “login:” or “username:” before asking the user to enter their credentials.

The login prompt serves as a security mechanism to ensure only authorized users can access the system. It verifies the user’s identity through the username/password credentials before allowing access to personalized user data and settings. Without a login prompt, the system would be exposed to anyone with physical access. The prompt also enables multiple user accounts on a single system, so different users can maintain separate environments and permissions.

Some key ways the operating system presents the login prompt include:

  • Displaying the hostname or computer name
  • Asking the user to “Press Ctrl+Alt+Delete” or “Enter username and password”
  • Providing input fields for username and password
  • Allowing users to select different user accounts
  • Showing the usernames of each available user account

Overall, the login prompt is a standard final step during the operating system boot process before passing control to the user. It enables secure access control and sets the stage for a personalized user experience.

Loading Times

The amount of time it takes for an operating system to load can vary greatly depending on the hardware configuration and complexity of the operating system. However, there are some general benchmarks for common operating systems like Windows, macOS, and Linux distributions.

According to a report by Browserstack, the average Windows 10 desktop boots to the login screen in around 10-25 seconds, while loading the desktop fully can take 30-90 seconds depending on hardware.

MacOS boot times are generally faster, with Apple reporting average boot times around 10-13 seconds for recent Macs. However, more complex startup tasks can extend this by several seconds.

Linux distributions like Ubuntu generally have boot times comparable to Windows 10, in the 15-30 second range. Factors like hard drive speed have a significant impact.

In summary, while results vary, modern operating systems generally load in well under a minute in most cases. Hardware improvements like solid-state drives have pushed boot times down substantially in recent years across all platforms.

Conclusion

In summary, the loading of an operating system into computer memory is a complex process that involves several key steps. First, the BIOS runs a power-on self-test and locates boot devices. Next, the bootloader loads and starts the kernel. The kernel then initializes the hardware and core system services and daemons. With the core OS loaded, the init system starts initialization of user space including mounting filesystems, starting additional services/daemons, and opening the login prompt. While loading times vary across different operating systems and hardware configurations, the entire process generally takes between 10-60 seconds on modern systems. The coordination between firmware, bootloaders, the kernel, system services, and user space is crucial to ensure a smooth and successful operating system load.