Operating Systems
— Complete DIT Notes
All 5 modules — architecture, processes, memory, file systems, and CLI administration — with Windows vs Linux comparisons and every practical lab included. Free to read — no account needed.
OS Fundamentals & Architecture
What an operating system actually does, how kernels are built, and what happens in the seconds before you see a login screen.
What Is an Operating System?
An OS is the software layer that sits between your hardware and every program you run. It allocates CPU time, manages memory, controls storage, and enforces security — so applications never have to talk to hardware directly.
OS design evolved through stages: Batch (jobs queued, no interaction) → Multiprogramming (multiple jobs held in memory, CPU switches between them) → Time-Sharing (multiple users, fast switching creates the illusion of simultaneity) → Real-Time (guaranteed response times for critical systems like medical devices or industrial control).
Kernel Architecture & System Calls
The kernel is the core of the OS — the part that actually talks to hardware. A Monolithic kernel (Linux) runs almost everything — drivers, file systems, memory management — in one privileged space for speed. A Microkernel (older QNX, parts of Windows NT) keeps only the bare essentials in privileged space and runs the rest as separate services, trading some speed for stability and security.
Programs never touch hardware themselves — they ask the kernel through system calls (e.g. open(), read(), fork()). This is the boundary between User Mode (where your applications run, restricted) and Kernel Mode (full hardware access, trusted code only).
| Stage | Linux | Windows |
|---|---|---|
| Firmware | BIOS or UEFI initializes hardware | BIOS or UEFI initializes hardware |
| Partition table | MBR (legacy) or GPT (UEFI) | MBR (legacy) or GPT (UEFI) |
| Bootloader | GRUB2 — shows a kernel selection menu | Windows Boot Manager (bootmgr) |
| Kernel init | Kernel loads, mounts root filesystem, starts systemd | ntoskrnl.exe loads, starts Session Manager |
| First process | systemd (PID 1) starts all services | Services.exe starts Windows services |
| View boot logs | journalctl -b or dmesg | Event Viewer → System log |
# Install a hypervisor (Oracle VM VirtualBox or VMware Workstation) # Then create two VMs for this course: 1. Create VM #1 # Desktop OS — install Windows 10/11 2. Create VM #2 # Server/CLI OS — install Ubuntu Server or Debian # Recommended VM specs for both: RAM: 2 GB minimum # (4 GB for Windows) Disk: 20 GB dynamically allocated Network: Bridged or NAT — NAT is simpler for a first install
- Kernel
- The core program that manages hardware and grants access to it via system calls.
- System Call
- A controlled request an application makes to the kernel — the only way to touch hardware.
- BIOS / UEFI
- Firmware that initializes hardware and hands control to the bootloader. UEFI is the modern replacement for BIOS.
- MBR / GPT
- Two partition table formats. GPT is newer, supports larger disks and more partitions.
- Bootloader
- The program that loads the kernel into memory — GRUB2 on Linux, Boot Manager on Windows.
- Real-Time OS
- An OS designed to guarantee a task completes within a fixed time window — used in embedded/industrial systems.
Try it: After installing your Linux VM, run systemctl list-units --type=service --state=running to see everything systemd started during boot.
Process & Thread Management
How the OS tracks every running program, decides who gets the CPU next, and what can go wrong when programs compete for resources.
Process Concepts
Every running program is a process, tracked by the kernel through a Process Control Block (PCB) — a data structure holding its ID, state, register values, memory pointers, and priority.
A process moves through five states: New (being created) → Ready (waiting for CPU) → Running (executing) → Waiting (blocked on I/O) → Terminated. It can bounce between Ready and Running many times before finishing.
CPU Scheduling
Since one CPU core can only run one instruction at a time, the OS uses schedulers to decide execution order. The long-term scheduler decides which processes enter the Ready queue; the short-term scheduler decides which Ready process runs next — this happens constantly, via context switching (saving one process's state, loading another's).
| Algorithm | How it picks | Trade-off |
|---|---|---|
| FIFO / FCFS | First process to arrive runs first | Simple, but a long job blocks everyone behind it |
| SJF | Shortest job runs next | Minimizes average wait time, but needs to know job length in advance |
| Round Robin | Each process gets a fixed time slice, then goes to the back of the queue | Fair for interactive systems, more context-switch overhead |
| Priority | Highest-priority process runs first | Fast for urgent tasks, risks starving low-priority ones |
Threads & Concurrency
A thread is a lightweight unit of execution inside a process — multiple threads in one process share the same memory space, unlike separate processes which are isolated. A single-threaded app does one thing at a time; a multi-threaded app (e.g. a web browser) runs several tasks concurrently within the same process. A basic hazard to know: a deadlock happens when two processes each hold a resource the other needs, and neither can proceed.
# Linux ps aux # list all running processes top # live process monitor kill -9 <PID> # force-terminate a process # Windows (CMD/PowerShell — used in Lab 2) tasklist # list all running processes taskkill /PID <pid> /F # force-terminate a process
- PCB
- Process Control Block — the kernel's record of everything it needs to know about a process.
- Context Switch
- Saving the state of one process and loading another so the CPU can move on.
- Thread
- A lightweight execution unit within a process; threads in the same process share memory.
- Deadlock
- A standstill where two or more processes each wait on a resource the other is holding.
Windows equivalent of top: Task Manager's Details tab shows live CPU/memory per process — same information, GUI instead of terminal.
Memory Management
How the OS gives every process the illusion of having its own private, unlimited memory — with a fixed amount of physical RAM.
Address Spaces & Linking
A process works with a logical (virtual) address space — addresses it thinks it owns. The Memory Management Unit translates these to physical addresses in real RAM. Dynamic loading loads a routine into memory only when it's called; dynamic linking connects a program to shared libraries at run time instead of baking them in at compile time.
Swapping & Fragmentation
Swapping temporarily moves an inactive process out of RAM to disk to free space for others. With contiguous allocation, memory develops internal fragmentation (wasted space inside an allocated block) and external fragmentation (free memory scattered in unusable small chunks) — solved by periodic compaction, which shuffles processes together to consolidate free space.
Paging, Segmentation & Virtual Memory
Paging splits memory into fixed-size pages, tracked in a per-process page table; a TLB (Translation Lookaside Buffer) caches recent translations for speed. Segmentation instead divides memory by logical unit (code, stack, heap) with variable sizes. Virtual memory combines these ideas with demand paging — pages load only when actually needed, triggering a page fault if a needed page isn't in RAM. When RAM is full, a page replacement algorithm decides what to evict.
| Algorithm | Rule |
|---|---|
| FIFO | Evict the page that has been in memory the longest |
| LRU | Evict the page that hasn't been used for the longest time — usually a better predictor of future use |
# Linux free -h # total/used/free RAM and swap, human-readable vmstat 1 # live memory + CPU stats, refresh every second # Windows systeminfo | findstr Memory # quick memory summary # or: Task Manager → Performance tab → Memory
- Page Fault
- An interrupt raised when a process references a page not currently in physical memory.
- TLB
- A hardware cache that speeds up virtual-to-physical address translation.
- Thrashing
- A state where the system spends more time swapping pages than executing — happens when RAM is badly oversubscribed.
Watch for: heavy swap usage on `free -h` output usually means the system doesn't have enough physical RAM for its workload — not a bug to fix in software.
File Systems & Storage Structure
How data is organized on disk, how directories are structured, and how to partition and format a drive.
Files, Attributes & Access Methods
Every file has attributes — name, type, size, permissions, timestamps. Files support operations like create, read, write, delete, and can be accessed sequentially (read start to finish, like a tape) or via direct/random access (jump straight to any byte, like a disk).
Directory Structures
A single-level directory holds all files in one flat list (fine for tiny systems, unusable at scale). A two-level directory gives each user their own directory. A tree-structured directory — what every modern OS uses — allows unlimited nested subdirectories.
| Aspect | Linux (ext4) | Windows (NTFS) |
|---|---|---|
| Allocation method | Indexed (inode-based) | Indexed ($MFT — Master File Table) |
| Case sensitivity | Case-sensitive (File.txt ≠ file.txt) | Case-preserving but insensitive |
| Path separator | Forward slash / | Backslash \ |
| Older FAT32 | Supported for USB drives (4 GB file size limit) | Still default for USB/SD cards |
| Permissions model | rwx for owner/group/other | ACL-based, per-user/group |
# Linux — using fdisk and mkfs on a virtual disk sudo fdisk /dev/sdb # enter partitioning tool for a second disk # inside fdisk: n (new partition), w (write changes) sudo mkfs.ext4 /dev/sdb1 # format the new partition as ext4 sudo mount /dev/sdb1 /mnt/data # Windows — Disk Management (diskmgmt.msc) or DiskPart diskpart list disk select disk 1 create partition primary format fs=ntfs quick assign
- Inode
- A Linux data structure storing a file's metadata and pointers to its data blocks — not the filename itself.
- FAT / NTFS / ext4
- File system formats — FAT32 is old and universal, NTFS is Windows' modern default, ext4 is Linux's modern default.
- MBR vs GPT
- Partition table styles — GPT supports disks over 2 TB and more than 4 primary partitions.
Never format your only disk by mistake: always double-check the device name (/dev/sdb vs /dev/sda) before running mkfs — sda is usually your main OS disk.
CLI & Administration
Windows CMD/PowerShell and the Linux Bash shell — file operations, users, permissions, and system monitoring from the command line.
Command Line Fundamentals
Windows CLI comes in two flavours — the legacy Command Prompt (CMD) and the modern, scriptable PowerShell. Linux uses Bash almost universally, built around pipelines (|) that feed one command's output into the next, and redirection (>, >>) to send output to a file instead of the screen.
| Task | Bash (Linux) | CMD / PowerShell (Windows) |
|---|---|---|
| List files | ls -la | dir / Get-ChildItem |
| Change directory | cd /var/log | cd C:\Logs |
| Create directory | mkdir project | mkdir project |
| Copy file | cp a.txt b.txt | copy a.txt b.txt |
| Delete file | rm file.txt | del file.txt |
| Mirror a folder | rsync -av src/ dst/ | robocopy src dst /E |
# Navigate and manage the filesystem pwd # print working directory touch notes.txt # create empty file cp notes.txt backup.txt # Permissions — symbolic and numeric (octal) modes chmod u+x script.sh # symbolic: add execute for owner chmod 750 script.sh # numeric: rwx for owner, r-x for group, --- for others chown ahmed:devteam script.sh # change owner and group
# Linux sudo useradd -m ahmed # create user with home directory sudo passwd ahmed # set password sudo groupadd devteam sudo usermod -aG devteam ahmed # add ahmed to devteam group # Windows (CMD) net user ahmed Passw0rd! /add net localgroup devteam /add net localgroup devteam ahmed /add
# Windows CLI system admin (Lab 2) systeminfo # full system report attrib +r file.txt # set read-only attribute chkdsk C: /f # check and fix disk errors # Resource monitoring (Lab 6) top # Linux — live CPU/memory per process htop # Linux — friendlier top with color and mouse support df -h # Linux — disk space usage by mount point # Windows — Task Manager / Resource Monitor (resmon.exe)
- Pipeline (|)
- Sends one command's output directly into another command as input.
- Redirection (>, >>)
- Sends command output to a file — overwrite (>) or append (>>).
- sudo
- Runs a single command with administrator (root) privileges on Linux.
- Octal permissions
- A 3-digit shorthand for rwx permissions — e.g. 750 = rwxr-x---.
Course uses: Windows 10/11 and Ubuntu Server side by side in VirtualBox so every command in this module can be run on both, back to back.
Ready to go beyond reading?
The live course includes hands-on labs, Q&A sessions, and a final enterprise project for your GitHub portfolio. Same instructor who wrote these notes.
💬 Enroll via WhatsApp →Batch info & fee on request