Operating Systems Demystified

๐Ÿ–ฅ๏ธโš™๏ธ Operating Systems Demystified: How Your Computer Actually Works Under the Hood

โ€œAn Operating System is not just software you openโ€”it is the invisible manager that makes every other software possible.โ€

Every time you open Chrome, run a Ruby program, save a file, connect to Wi-Fi, play a song, or start a Docker container, thousands of operations happen behind the scenes.

But who coordinates all of this?

๐Ÿ‘‰ The Operating System (OS).

Windows, Linux, macOS, Android, and iOS may look completely different, but underneath their user interfaces they perform many of the same fundamental jobs:

  • ๐Ÿง  Manage CPU and processes
  • ๐Ÿงฎ Manage memory
  • ๐Ÿ’พ Manage files and storage
  • ๐Ÿ”Œ Communicate with hardware
  • ๐ŸŒ Manage networking
  • ๐Ÿ” Provide security and permissions
  • ๐Ÿ“ฆ Load and execute applications
  • ๐Ÿงต Manage threads and concurrency
  • โšก Handle interrupts and system calls

ChatGPT Image Aug 27, 2026, 08_26_39 PM

Letโ€™s go deep into how an operating system actually worksโ€”and how the OS, kernel, libraries, applications, and hardware work together.


1๏ธโƒฃ What Exactly Is an Operating System?

An operating system is system software that acts as a bridge between applications and computer hardware.

A simplified architecture looks like this:

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚          USER APPLICATIONS          โ”‚
โ”‚ Chrome โ€ข VS Code โ€ข Rails โ€ข Games    โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                   โ”‚
                   โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚       SYSTEM LIBRARIES / APIs       โ”‚
โ”‚ libc โ€ข Win32 โ€ข Foundation โ€ข Bionic โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                   โ”‚
                   โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚          SYSTEM CALLS               โ”‚
โ”‚ open โ€ข read โ€ข write โ€ข fork โ€ข exec   โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                   โ”‚
                   โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚              KERNEL                 โ”‚
โ”‚ CPU โ€ข Memory โ€ข Files โ€ข Network      โ”‚
โ”‚ Drivers โ€ข Processes โ€ข Security      โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                   โ”‚
                   โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚              HARDWARE               โ”‚
โ”‚ CPU โ€ข RAM โ€ข SSD โ€ข GPU โ€ข NIC โ€ข USB  โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

The kernel is the core component.

An OS is larger than its kernel. It also includes system libraries, services, utilities, drivers, graphical interfaces, package managers, and other components.


2๏ธโƒฃ The Kernel: The Heart of the Operating System โค๏ธ

The kernel is the privileged software layer that controls access to hardware and provides fundamental services to applications.

It typically handles:

๐Ÿง  Process Management

Which program gets CPU time?

๐Ÿงฎ Memory Management

Which process gets which memory?

๐Ÿ’พ Storage

Where should a file be read from?

๐ŸŒ Networking

How should network packets be transmitted?

๐Ÿ”Œ Device Management

How should the keyboard, disk, GPU, or network card be controlled?

๐Ÿ” Security

Is this process allowed to access this resource?


3๏ธโƒฃ User Mode vs Kernel Mode

Modern processors provide privilege levels.

The most important conceptual distinction is:

USER MODE
โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
Chrome
Ruby
Python
PostgreSQL
VS Code
        โ”‚
        โ”‚ System Call
        โ–ผ
KERNEL MODE
โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
Kernel
Drivers
Memory Manager
Scheduler
File System
        โ”‚
        โ–ผ
HARDWARE

Applications normally execute with restricted privileges.

The kernel operates with much greater privileges.

Why?

Imagine every application could directly execute arbitrary hardware instructions.

๐Ÿ˜ฑ A browser could overwrite another programโ€™s memory.

A game could modify kernel memory.

A buggy application could crash the entire machine.

Instead, applications ask the kernel:

โ€œKernel, please open this file.โ€

โ€œKernel, please allocate memory.โ€

โ€œKernel, please send this network packet.โ€

The kernel validates the request and performs the operation.


4๏ธโƒฃ System Calls: The Doorway Into the Kernel ๐Ÿšช

Applications cannot simply call kernel functions like ordinary application functions.

They use system calls.

For example, a Unix-like system provides operations such as:

open()
read()
write()
close()
fork()
execve()
mmap()
socket()

A simplified flow:

Application
     โ”‚
     โ–ผ
Library Function
     โ”‚
     โ–ผ
System Call
     โ”‚
     โ–ผ
CPU switches privilege
     โ”‚
     โ–ผ
Kernel
     โ”‚
     โ–ผ
Hardware / Kernel subsystem

For example:

int fd = open("hello.txt", O_RDONLY);

The application isnโ€™t directly controlling the SSD.

Instead:

Application
     โ†“
open()
     โ†“
System Call
     โ†“
Kernel
     โ†“
File System
     โ†“
Storage Driver
     โ†“
SSD

The result eventually comes back to the application.


5๏ธโƒฃ What Happens When You Run a Program? ๐Ÿš€

Suppose you execute:

./program

A simplified sequence is:

Shell
 โ”‚
 โ”œโ”€โ”€ locate executable
 โ”‚
 โ”œโ”€โ”€ request process creation
 โ”‚
 โ”œโ”€โ”€ load executable
 โ”‚
 โ”œโ”€โ”€ create address space
 โ”‚
 โ”œโ”€โ”€ map program sections
 โ”‚
 โ”œโ”€โ”€ load shared libraries
 โ”‚
 โ”œโ”€โ”€ configure stack/heap
 โ”‚
 โ”œโ”€โ”€ initialize runtime
 โ”‚
 โ””โ”€โ”€ start program
          โ”‚
          โ–ผ
       main()

The OS creates a process and gives it:

  • Virtual address space
  • Process ID
  • File descriptors
  • Security credentials
  • Scheduling information
  • Environment variables
  • Access to required resources

Now the CPU can execute the program.


6๏ธโƒฃ Processes vs Threads ๐Ÿงต

A process is an executing program with its own virtual address space and resources.

A thread is an execution path within a process.

For example:

Chrome Process
โ”‚
โ”œโ”€โ”€ UI Thread
โ”œโ”€โ”€ Network Thread
โ”œโ”€โ”€ Rendering Thread
โ”œโ”€โ”€ JavaScript Thread
โ””โ”€โ”€ Worker Threads

Threads within the same process generally share:

Code
Heap
Files
Libraries

but each thread has its own:

Stack
Registers
Execution state

The OS scheduler decides when threads run.


7๏ธโƒฃ CPU Scheduling โšก

Suppose you have:

Chrome
VS Code
PostgreSQL
Music Player
Terminal

But your CPU has only a few cores.

How can everything appear to run simultaneously?

The OS scheduler rapidly assigns CPU time.

Conceptually:

CPU Core

Chrome โ”€โ”€โ”
         โ”‚
VS Code โ”€โ”ค
         โ”‚
Ruby โ”€โ”€โ”€โ”€โ”คโ”€โ”€> Scheduler โ”€โ”€> CPU
         โ”‚
Postgres โ”ค
         โ”‚
Terminal โ”˜

On a multicore CPU, multiple threads can execute truly in parallel.

Modern schedulers consider things such as:

  • Priority
  • CPU utilization
  • Fairness
  • Interactive responsiveness
  • Processor topology
  • Task state

Linux uses the Completely Fair Scheduler (CFS) historically for normal tasks, with newer Linux versions evolving toward EEVDF scheduling.


8๏ธโƒฃ Virtual Memory: The Magic Behind RAM ๐Ÿง 

One of the most important OS concepts is virtual memory.

A program thinks it has its own address space:

Application Virtual Address Space

0x0000 โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
       Code
       Libraries
       Heap
       ...
       Stack
0xFFFF โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€

But these virtual addresses are mapped to physical memory.

Virtual Address
       โ”‚
       โ–ผ
Page Tables
       โ”‚
       โ–ผ
Physical RAM

The CPUโ€™s MMU (Memory Management Unit) helps translate virtual addresses into physical addresses.

This provides:

  • Process isolation
  • Memory protection
  • Flexible memory allocation
  • Shared memory
  • Memory mapping
  • Efficient loading

9๏ธโƒฃ What Is a Page?

Operating systems generally manage virtual memory in fixed-size chunks called pages.

A simplified example:

Virtual Memory

Page 0 โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–บ RAM Frame 8
Page 1 โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–บ RAM Frame 2
Page 2 โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–บ RAM Frame 15
Page 3 โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–บ Disk / Not Present

The application doesnโ€™t need to know where the physical memory actually resides.

This abstraction is extremely powerful.


๐Ÿ”Ÿ What Happens When RAM Is Full?

Suppose RAM becomes heavily utilized.

The OS can reclaim memory and, depending on the system, use disk-backed mechanisms such as swap.

Conceptually:

RAM
โ”‚
โ”œโ”€โ”€ Chrome
โ”œโ”€โ”€ PostgreSQL
โ”œโ”€โ”€ VS Code
โ””โ”€โ”€ Kernel
       โ”‚
       โ–ผ
   Memory pressure
       โ”‚
       โ–ผ
Reclaim / compression / swap
       โ”‚
       โ–ผ
Storage

However, disk storage is much slower than RAM.

If the system constantly swaps memory, you may experience severe performance degradation.


1๏ธโƒฃ1๏ธโƒฃ File Systems ๐Ÿ’พ

When you execute:

cat hello.txt

the OS needs to locate the file.

The storage system typically involves:

Application
     โ†“
System Call
     โ†“
Virtual File System
     โ†“
File System
     โ†“
Block Layer
     โ†“
Storage Driver
     โ†“
SSD/HDD

Different operating systems support different file systems.

Linux

Common examples:

  • ext4
  • XFS
  • Btrfs
  • tmpfs

Windows

Common examples:

  • NTFS
  • exFAT
  • FAT32

Apple platforms

Common examples:

  • APFS

The file system determines how files, directories, metadata, permissions, and storage blocks are organized.


1๏ธโƒฃ2๏ธโƒฃ Device Drivers ๐Ÿ”Œ

Hardware doesnโ€™t automatically understand commands such as:

"Play this audio."
"Write this file."
"Send this packet."

Drivers translate operating-system operations into hardware-specific commands.

Application
     โ†“
OS API
     โ†“
Kernel
     โ†“
Driver
     โ†“
Hardware

Examples include:

  • GPU drivers
  • Wi-Fi drivers
  • NVMe drivers
  • USB drivers
  • Audio drivers
  • Bluetooth drivers

This abstraction allows applications to work with hardware without knowing every hardware-specific detail.


1๏ธโƒฃ3๏ธโƒฃ Interrupts โšก

Hardware frequently needs to tell the CPU:

โ€œSomething happened!โ€

For example:

Keyboard key pressed
       โ†“
Keyboard Controller
       โ†“
Interrupt
       โ†“
CPU
       โ†“
Kernel interrupt handler
       โ†“
Input subsystem
       โ†“
Application

Similarly, when a network packet arrives:

Network Card
     โ†“
Interrupt / event
     โ†“
Kernel
     โ†“
Network Stack
     โ†“
Socket
     โ†“
Application

Interrupts are fundamental to efficient operating systems.


1๏ธโƒฃ4๏ธโƒฃ Networking ๐ŸŒ

When you visit a website:

Browser
   โ†“
Socket API
   โ†“
Kernel Networking Stack
   โ†“
TCP / UDP
   โ†“
IP
   โ†“
Network Driver
   โ†“
Wi-Fi / Ethernet
   โ†“
Router
   โ†“
Internet

The application usually doesnโ€™t manipulate Ethernet frames directly.

The OS networking stack provides abstractions such as sockets.

For example:

socket.connect(...)

eventually causes the operating system to perform networking operations.


1๏ธโƒฃ5๏ธโƒฃ Operating System #1 โ€” Linux ๐Ÿง

Linux is one of the most important operating systems in modern computing.

It powers:

  • Servers
  • Cloud infrastructure
  • Supercomputers
  • Embedded systems
  • Android devices
  • Containers
  • Networking equipment

Technically, Linux itself is the kernel. A complete Linux distribution combines the Linux kernel with user-space software.

Examples:

  • Ubuntu
  • Debian
  • Fedora
  • Arch Linux
  • RHEL
  • openSUSE

Programming languages

The Linux kernel is primarily written in:

C
Assembly
Rust

Rust is increasingly used in selected kernel areas, while C remains dominant.

Important libraries

Linux distributions commonly provide:

glibc
musl
libpthread / threading interfaces
libdl
libm

The exact user-space stack depends on the distribution.

Example

When Ruby executes:

File.read("hello.txt")

the chain can conceptually become:

Ruby
 โ†“
Ruby runtime
 โ†“
libc / OS interfaces
 โ†“
read/open system calls
 โ†“
Linux Kernel
 โ†“
File System
 โ†“
Storage Driver
 โ†“
SSD

1๏ธโƒฃ6๏ธโƒฃ Operating System #2 โ€” Windows ๐ŸชŸ

Windows is developed by Microsoft and is widely used on desktop computers, enterprise systems, gaming PCs, and servers.

Its architecture contains several major components, including:

User Applications
       โ†“
Windows APIs
       โ†“
System Services / Runtime
       โ†“
Windows Executive
       โ†“
Windows Kernel
       โ†“
Drivers
       โ†“
Hardware

Programming languages

Windows components have historically been heavily written in:

  • C
  • C++
  • Assembly

Other languages are used in tooling and higher-level components as well.

Important APIs / libraries

Windows developers commonly interact with:

  • Win32 API
  • Windows Runtime
  • .NET libraries
  • DirectX
  • Windows system DLLs

For example:

C# Application
       โ†“
.NET
       โ†“
Windows APIs
       โ†“
Windows Kernel
       โ†“
Hardware

A Windows application can therefore use a high-level language while the operating system handles low-level operations underneath.


1๏ธโƒฃ7๏ธโƒฃ Operating System #3 โ€” macOS ๐ŸŽ

macOS is Appleโ€™s desktop operating system.

Its underlying architecture is built around Darwin, which combines technologies including the XNU kernel, BSD components, and Mach.

Conceptually:

macOS Applications
       โ†“
Frameworks
       โ†“
Darwin / System Services
       โ†“
XNU Kernel
       โ†“
Drivers
       โ†“
Hardware

Programming languages

Major low-level components use:

  • C
  • C++
  • Objective-C
  • Assembly
  • Swift in various higher-level components

Important frameworks

macOS provides frameworks such as:

  • Foundation
  • Core Foundation
  • AppKit
  • Metal
  • Security
  • Network

For example:

Swift Application
       โ†“
Foundation / AppKit
       โ†“
System APIs
       โ†“
XNU
       โ†“
Hardware

1๏ธโƒฃ8๏ธโƒฃ Operating System #4 โ€” Android ๐Ÿค–

Android is built around the Linux kernel but adds a large Android-specific software stack.

Simplified architecture:

Android Applications
        โ†“
Android Framework
        โ†“
Android Runtime (ART)
        โ†“
Native Libraries
        โ†“
Linux Kernel
        โ†“
Hardware

Android applications are commonly written using:

  • Kotlin
  • Java

Native components frequently use:

  • C
  • C++

Androidโ€™s runtime is ART (Android Runtime).

Android also includes native components such as:

  • Bionic libc
  • Media libraries
  • Graphics components
  • SQLite
  • Hardware abstraction mechanisms

So when an Android application accesses a camera:

Kotlin App
    โ†“
Android Camera API
    โ†“
Framework
    โ†“
Native / HAL layers
    โ†“
Linux Kernel
    โ†“
Camera Driver
    โ†“
Camera Hardware

1๏ธโƒฃ9๏ธโƒฃ Operating System #5 โ€” iOS ๐Ÿ“ฑ

iOS is Appleโ€™s mobile operating system.

Its foundations are closely related to Appleโ€™s Darwin technologies and the XNU kernel.

Simplified:

iOS App
   โ†“
UIKit / SwiftUI
   โ†“
Apple Frameworks
   โ†“
System Services
   โ†“
XNU / Darwin
   โ†“
Drivers
   โ†“
iPhone Hardware

Applications are commonly developed using:

  • Swift
  • Objective-C

Important frameworks include:

  • UIKit
  • SwiftUI
  • Foundation
  • Core Foundation
  • Metal
  • Core Graphics
  • AVFoundation

Appleโ€™s platform strongly emphasizes application sandboxing, code signing, permissions, and controlled access to hardware.


2๏ธโƒฃ0๏ธโƒฃ Operating System #6 โ€” Unix ๐Ÿ›๏ธ

Unix is historically one of the most influential operating-system families.

Unix introduced or popularized concepts that became fundamental to modern systems:

Processes
Pipes
File descriptors
Hierarchical file systems
Shells
Permissions
"Everything is a file" philosophy

The original Unix implementation was primarily written in assembly, and later Unix was famously rewritten in C, helping demonstrate that operating systems could be implemented in a portable high-level language.

Unix influenced:

BSD
Linux
macOS
iOS
Many Unix-like systems

2๏ธโƒฃ1๏ธโƒฃ The โ€œEverything Is a Fileโ€ Philosophy ๐Ÿ“

Unix-like systems often expose many resources through file descriptors.

For example:

File
Socket
Pipe
Terminal
Device

can be represented using descriptors.

For example:

int fd = open("data.txt", O_RDONLY);

Then:

read(fd, buffer, size);

This creates a powerful uniform abstraction.

A network socket can similarly be manipulated through a descriptor.

This simplicity is one reason Unix-like operating systems became so influential.


2๏ธโƒฃ2๏ธโƒฃ Libraries: The Missing Layer ๐Ÿงฉ

A common misconception is:

Application โ†’ Kernel

In reality, there is frequently a rich layer of libraries and runtimes between them.

For example:

Ruby
 โ†“
Ruby VM / Runtime
 โ†“
C extensions / libc
 โ†“
System Calls
 โ†“
Linux Kernel

Or:

Python
 โ†“
CPython
 โ†“
libc
 โ†“
Linux System Calls
 โ†“
Kernel

Or:

C++
 โ†“
C++ Standard Library
 โ†“
libc / OS APIs
 โ†“
Kernel

Libraries provide reusable functionality and make programming dramatically easier.


2๏ธโƒฃ3๏ธโƒฃ Example: What Happens When Ruby Reads a File? ๐Ÿ’Ž

Consider:

content = File.read("users.txt")

A simplified journey is:

Ruby Code
    โ”‚
    โ–ผ
Ruby Interpreter / VM
    โ”‚
    โ–ผ
Ruby File APIs
    โ”‚
    โ–ผ
Native OS Interface
    โ”‚
    โ–ผ
System Call
    โ”‚
    โ–ผ
Linux Kernel
    โ”‚
    โ–ผ
VFS
    โ”‚
    โ–ผ
ext4
    โ”‚
    โ–ผ
Block Layer
    โ”‚
    โ–ผ
NVMe Driver
    โ”‚
    โ–ผ
SSD

The data travels back through the layers:

SSD
 โ†“
Driver
 โ†“
Kernel
 โ†“
File System
 โ†“
System Call
 โ†“
Ruby Runtime
 โ†“
Ruby String

Finally:

puts content

prints the data.

๐Ÿ”ฅ One line of Ruby can therefore trigger a surprisingly large software stack.


2๏ธโƒฃ4๏ธโƒฃ Example: Opening a Website ๐ŸŒ

Suppose you enter:

https://example.com

into a browser.

A simplified flow is:

Browser
   โ†“
DNS
   โ†“
Socket API
   โ†“
OS Networking Stack
   โ†“
TCP / UDP
   โ†“
TLS
   โ†“
Network Driver
   โ†“
Wi-Fi Adapter
   โ†“
Router
   โ†“
Internet
   โ†“
Web Server

The response comes back:

Internet
   โ†“
Network Card
   โ†“
Driver
   โ†“
Kernel
   โ†“
Socket
   โ†“
Browser
   โ†“
TLS
   โ†“
HTTP
   โ†“
HTML/CSS/JS
   โ†“
Renderer
   โ†“
GPU
   โ†“
Screen

๐Ÿคฏ A simple webpage request crosses many layers.


2๏ธโƒฃ5๏ธโƒฃ Example: Running a Rails Application ๐Ÿš‚

Imagine you run:

bin/rails server

The chain looks roughly like:

Terminal
   โ†“
Shell
   โ†“
Process Creation
   โ†“
Ruby
   โ†“
Rails
   โ†“
Puma
   โ†“
Socket
   โ†“
Linux Kernel
   โ†“
Network Driver

When a browser requests:

GET /users

the request travels:

Browser
   โ†“
Network
   โ†“
Linux Kernel
   โ†“
Puma
   โ†“
Rails Router
   โ†“
Controller
   โ†“
Active Record
   โ†“
PostgreSQL

PostgreSQL itself is another operating-system process.

So:

Rails Process
      โ”‚
      โ”‚ TCP / Unix socket
      โ–ผ
PostgreSQL Process
      โ”‚
      โ–ผ
Linux Kernel
      โ”‚
      โ–ผ
Storage

This is a beautiful example of multiple applications cooperating through operating-system abstractions.


2๏ธโƒฃ6๏ธโƒฃ Containers and Operating Systems ๐Ÿ“ฆ

Docker containers are often misunderstood.

A container is not a complete operating system in the same sense as a virtual machine.

Containers share the host kernel.

For example:

HOST
Linux Kernel
โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€

Container A
Rails

Container B
PostgreSQL

Container C
Redis

All containers use the same underlying kernel.

Linux provides mechanisms such as:

  • Namespaces
  • cgroups
  • Capabilities
  • Seccomp

These help isolate and control processes.


2๏ธโƒฃ7๏ธโƒฃ Virtual Machines vs Containers ๐Ÿ–ฅ๏ธ๐Ÿ“ฆ

Virtual Machine

Hardware
   โ†“
Host OS
   โ†“
Hypervisor
   โ†“
Guest OS
   โ†“
Application

Each VM can have its own guest kernel.

Container

Hardware
   โ†“
Host OS / Kernel
   โ†“
Container Runtime
   โ†“
Container
   โ†“
Application

Containers are therefore generally lighter because they donโ€™t need a separate guest kernel for each container.


2๏ธโƒฃ8๏ธโƒฃ How Programming Languages Depend on the OS

Different languages sit at different levels of abstraction.

C

C
 โ†“
Compiler
 โ†“
Machine Code
 โ†“
System Calls
 โ†“
Kernel

Python

Python
 โ†“
CPython
 โ†“
C
 โ†“
OS APIs / System Calls
 โ†“
Kernel

Ruby

Ruby
 โ†“
Ruby VM
 โ†“
Native runtime
 โ†“
OS APIs
 โ†“
Kernel

Java

Java
 โ†“
JVM
 โ†“
Native JVM implementation
 โ†“
OS
 โ†“
Kernel

JavaScript

For Node.js:

JavaScript
 โ†“
V8
 โ†“
Node.js
 โ†“
libuv
 โ†“
OS APIs
 โ†“
Kernel

The high-level language doesnโ€™t eliminate the OS.

It builds on top of it.


2๏ธโƒฃ9๏ธโƒฃ How All These Technologies Work Together ๐Ÿ”—

Consider a modern web application:

                 USER
                  โ”‚
                  โ–ผ
             Web Browser
                  โ”‚
                  โ–ผ
             JavaScript
                  โ”‚
                  โ–ผ
              HTTP/TLS
                  โ”‚
                  โ–ผ
        โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
        โ”‚   Linux Kernel  โ”‚
        โ”‚                 โ”‚
        โ”‚ Networking      โ”‚
        โ”‚ Processes       โ”‚
        โ”‚ Memory          โ”‚
        โ”‚ Files           โ”‚
        โ”‚ Security        โ”‚
        โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                 โ”‚
       โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
       โ–ผ         โ–ผ         โ–ผ
     Rails    PostgreSQL  Redis
       โ”‚         โ”‚         โ”‚
       โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                 โ–ผ
              Storage

Every component depends on lower-level abstractions.


3๏ธโƒฃ0๏ธโƒฃ Security ๐Ÿ”

Operating systems must answer:

Who is allowed to do what?

Security mechanisms include:

Users

alice
bob
root

Permissions

read
write
execute

Process Isolation

One process should not normally access another processโ€™s private memory.

Sandboxing

Applications can be restricted to specific resources.

Authentication

Who are you?

Authorization

What are you allowed to access?

Encryption

Sensitive data can be protected both at rest and in transit.

Modern operating systems also use mechanisms such as:

  • ASLR
  • DEP/NX
  • Code signing
  • Sandboxing
  • Secure boot
  • Capability restrictions
  • Mandatory access-control systems in some environments

3๏ธโƒฃ1๏ธโƒฃ Booting an Operating System ๐Ÿš€

What happens when you press the power button?

A simplified process:

Power ON
   โ†“
Firmware
BIOS / UEFI
   โ†“
Bootloader
   โ†“
Kernel
   โ†“
Kernel Initialization
   โ†“
Device Initialization
   โ†“
Root File System
   โ†“
System Services
   โ†“
Login / Desktop

On a Linux system, you may eventually reach:

systemd
   โ†“
Services
   โ†“
Login Manager
   โ†“
Desktop Environment

On other operating systems, the corresponding initialization architecture is different.


3๏ธโƒฃ2๏ธโƒฃ The Shell ๐Ÿš

When you type:

ls

into a Linux terminal, the shell interprets the command.

For example:

User
 โ†“
Bash / Zsh
 โ†“
ls program
 โ†“
System Calls
 โ†“
Kernel
 โ†“
File System

The shell itself is an application running on the OS.

This is an important realization:

The terminal is not the operating system.

It is merely one interface to the operating system.


3๏ธโƒฃ3๏ธโƒฃ Why Linux Dominates Cloud Computing โ˜๏ธ

Modern cloud infrastructure heavily relies on Linux because of its:

  • Open-source nature
  • Stability
  • Automation capabilities
  • Networking capabilities
  • Container ecosystem
  • Performance
  • Customizability
  • Strong tooling

A typical cloud deployment might look like:

AWS / Cloud
    โ†“
Linux
    โ†“
Docker
    โ†“
Kubernetes
    โ†“
Rails / Node / Python
    โ†“
PostgreSQL / Redis

Every layer builds upon the layer underneath it.


3๏ธโƒฃ4๏ธโƒฃ Operating Systems Comparison ๐Ÿ“Š

OS Kernel / Foundation Major Languages Typical Libraries / APIs Common Uses
๐Ÿง Linux Linux Kernel C, Assembly, Rust glibc, musl, POSIX APIs Servers, Cloud, Embedded
๐ŸชŸ Windows Windows NT Kernel C, C++, Assembly Win32, .NET, Windows APIs Desktop, Enterprise, Gaming
๐ŸŽ macOS XNU / Darwin C, C++, Objective-C, Swift Foundation, AppKit, Core Foundation Apple desktops
๐Ÿค– Android Linux Kernel + Android stack Kotlin, Java, C/C++ Android Framework, Bionic Smartphones, TVs, Automotive
๐Ÿ“ฑ iOS XNU / Darwin Swift, Objective-C, C/C++ UIKit, SwiftUI, Foundation iPhone/iPad
๐Ÿ›๏ธ Unix Various Unix kernels C, Assembly POSIX / Unix APIs Servers, Research, Enterprise

The exact implementation differs, but the fundamental concepts remain remarkably similar.


3๏ธโƒฃ5๏ธโƒฃ The Big Picture ๐Ÿง 

Think about the entire computer as a layered cake:

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚          APPLICATIONS        โ”‚
โ”‚ Rails โ€ข Chrome โ€ข VS Code     โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚        LANGUAGES / RUNTIME    โ”‚
โ”‚ Ruby โ€ข Python โ€ข JVM โ€ข V8     โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚          LIBRARIES           โ”‚
โ”‚ libc โ€ข .NET โ€ข Foundation     โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚          OS APIs             โ”‚
โ”‚ POSIX โ€ข Win32 โ€ข Frameworks   โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚        SYSTEM CALLS          โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚            KERNEL            โ”‚
โ”‚ CPU โ€ข RAM โ€ข Disk โ€ข Network   โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚           DRIVERS            โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚          HARDWARE            โ”‚
โ”‚ CPU โ€ข RAM โ€ข SSD โ€ข GPU โ€ข NIC  โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Each layer hides complexity from the layer above.

That is the real power of operating systems.


3๏ธโƒฃ6๏ธโƒฃ The Most Important OS Concepts to Master ๐ŸŽฏ

If you want to become a strong software engineer, donโ€™t stop at knowing that โ€œLinux runs servers.โ€

Understand these concepts deeply:

๐Ÿง  Processes

How programs execute.

๐Ÿงต Threads

How concurrent execution works.

โšก Scheduling

How CPU time is distributed.

๐Ÿงฎ Virtual Memory

How processes receive isolated address spaces.

๐Ÿ“„ System Calls

How applications communicate with the kernel.

๐Ÿ’พ File Systems

How persistent data is organized.

๐Ÿ”Œ Drivers

How software communicates with hardware.

๐ŸŒ Networking

How applications communicate across machines.

๐Ÿ” Security

How operating systems isolate and protect resources.

๐Ÿ“ฆ Containers

How OS primitives create lightweight isolated environments.

๐Ÿš€ Boot Process

How hardware eventually becomes a usable operating environment.


3๏ธโƒฃ7๏ธโƒฃ Final Mental Model ๐Ÿš€

Whenever you execute something like:

users = User.all

donโ€™t imagine only:

Ruby โ†’ PostgreSQL

Think much deeper:

Ruby
 โ†“
Ruby VM
 โ†“
Rails / ActiveRecord
 โ†“
Database Client
 โ†“
Socket
 โ†“
System Call
 โ†“
Operating System Kernel
 โ†“
Network Stack
 โ†“
Network Driver
 โ†“
Hardware
 โ†“
Network
 โ†“
PostgreSQL Server
 โ†“
Operating System
 โ†“
Kernel
 โ†“
Storage / Memory

That is the real world of software engineering.


๐Ÿ”ฅ Final Takeaway

An Operating System is essentially a resource manager, abstraction layer, security boundary, and hardware coordinator.

It transforms incredibly complex hardware into simple abstractions:

CPU       โ†’ Process / Thread
RAM       โ†’ Virtual Memory
Disk      โ†’ Files
Network   โ†’ Sockets
Hardware  โ†’ Drivers
Security  โ†’ Permissions / Isolation
Execution โ†’ Processes

And that is why operating systems are one of the most important foundations of computer science.

๐Ÿ’ก Once you understand the OS, you start seeing software differently.

A Rails application isnโ€™t just Rails.

A Python script isnโ€™t just Python.

A Docker container isnโ€™t just Docker.

A browser isnโ€™t just Chrome.

They are all participants in a huge hierarchy:

Application โ†’ Runtime โ†’ Libraries โ†’ System Calls โ†’ Kernel โ†’ Drivers โ†’ Hardware.

And underneath every modern application is an operating system quietly orchestrating the entire show. ๐Ÿ–ฅ๏ธโš™๏ธ๐Ÿš€

Learn the OS, and you donโ€™t just learn how programs runโ€”you learn what โ€œrunning a programโ€ actually means.

© Lakhveer Singh Rajput - Blogs. All Rights Reserved.