🖥️⚙️ Operating Systems Demystified: How Your Computer Actually Works Under the Hood

🖥️⚙️ 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

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 │
openreadwriteforkexec
└──────────────────┬──────────────────┘


┌─────────────────────────────────────┐
│ 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 responsivenes
  • 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 📊

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:

RubyPostgreSQL

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.

Comments

Popular posts from this blog

🚀 Deploying a Ruby on Rails Application Like a Pro (Step-by-Step Guide) 🌍🔥

🚀 Ruby on Rails 8: The Ultimate Upgrade for Modern Developers! Game-Changing Features Explained 🎉💎

🧠 RSpec Guidelines for Pro Developers: Test Like a Pro!