Skip to content

Latest commit

 

History

History
166 lines (102 loc) · 3.03 KB

File metadata and controls

166 lines (102 loc) · 3.03 KB

To begin the journey of writing your own kernel:

What is a kernel?

The kernel is the central component of an operating system. It is the first software layer that begins running after the computer boots and remains active until it is shut down.

The kernel's primary role is to act as an intermediary between the hardware and software.

No application has direct access to the processor, memory, or devices. All requests go through the kernel.


How the Kernel Works in the System

The system is organized into layers:

Hardware (processor, memory, devices)
↓
Kernel
↓
System interfaces
↓
Applications and tools

Kernel:

  • manages resources
  • isolates programs from each other
  • ensures stability and security

Main Parts of the Kernel

1. Processor Management (Scheduler)

The kernel decides:

  • which program is currently running
  • when to suspend it
  • when to transfer control to another

2. Memory Management

Kernel:

  • allocates RAM
  • ensures that programs do not interfere with each other
  • manages virtual memory

Without this, one error could bring the entire system to a halt.


3. Device Management

The keyboard, screen, disk, and network are all controlled by the kernel.

The kernel:

  • receives signals from devices
  • passes data to programs
  • abstracts hardware differences

4. Interrupts and Events

Hardware devices don't wait for a program to finish. They send interrupts.

The kernel:

  • handles interrupts
  • temporarily suspends execution
  • responds to events in a timely manner

5. System Interface

The kernel provides a formal way for programs to interact with the system.

Through this interface, programs can:

  • read and write data
  • run other programs
  • work with devices

Programs don't know how the hardware works—it's hidden by the kernel.


6. Security and Isolation

Kernel:

  • Separates access levels
  • Prevents unauthorized actions
  • Isolates program errors

In what mode does the kernel operate?

The processor has different operating modes.

The kernel runs in privileged mode, where the following is available:

  • Memory management
  • Interrupt handling
  • Device management

Normal programs run in a restricted mode.


What languages ​​are kernels written in, and which ones will we use to create our own kernel?

Kernels are written in languages ​​that allow:

  • precise memory management
  • processor interaction
  • minimizing overhead

Almost always used:

  • low-level languages ​​for system startup
  • system languages ​​for core logic

The choice of language is a tradeoff between:

  • control
  • security
  • performance

What the kernel does NOT do

The kernel does not:

  • provide a user interface
  • process user commands
  • display windows or a terminal

All these functions are performed by programs on top of the kernel.


Summary

The kernel is:

  • the foundation of the system
  • resource manager
  • security layer
  • the link between programs and hardware

Without the kernel, an operating system is impossible.