knowledge

Overview

This note covers OS internals including virtual memory management, device driver architecture, and virtualization components for both Windows and Linux systems. These concepts are foundational for understanding how operating systems manage hardware resources, memory, and virtualized environments.

ℹ︎Backlog

When content grows, split into separate notes — Virtual Memory.md, Device Drivers.md, and Virtualization.md


Terminology

TermDefinition
Virtual MemoryOS feature compensating for physical memory shortages by temporarily moving pages to disk
Paging / SwappingCopying virtual memory pages between disk and RAM
ThrashingExcessive swapping causing severe performance degradation
Page FrameFixed-size block of physical memory (typically 4KB)
PTE (Page Table Entry)Maps a virtual page to a physical page frame
DriverSoftware allowing the OS and hardware to communicate
Hypervisor (VMM)Software that creates and manages Virtual Machines
Binary RewritingTechnique for intercepting and modifying instructions in virtualization

Core Concepts

Virtual Memory

How It Works

  • Divides each process into small chunks called pages (typically 4KB per page frame)
  • Maps virtual addresses used by processes to physical RAM addresses
  • Pages not actively used are moved to a swap/page file on disk

Key Structures

StructurePurpose
Page Frame TablesMap virtual pages to physical memory locations
Page DirectoriesPoint to specific page tables
Page TablesContain Page Table Entries (PTEs)
PTEContains page address; maps virtual to physical page frame
Swap / Page FileDisk space used for memory not currently needed in RAM

Thrashing

  • Occurs when excessive swapping dominates CPU time
  • Results in severe performance degradation
  • Caused by insufficient RAM for active working sets

Device Drivers — Windows

Driver TypeDescription
Function DriverCommunicates directly with the hardware device
Filter DriverPerforms auxiliary processing alongside the function driver
Software DriverRuns in kernel mode; may not require direct hardware access

Driver Routines

RoutineDescription
Initialization RoutineRegisters driver routines when module is loaded
Add-Device RoutineTriggered when a Plug and Play device is detected
Start I/O RoutineInitiates data transfer to/from the device
Dispatch RoutineMain function for I/O operations; called by the OS
ISR (Interrupt Service Routine)Triggered by a hardware interrupt
DPC (Deferred Procedure Call)Ends ISR processing and returns control to the OS

Device Drivers — Linux

  • Privileged, memory-resident routines for low-level hardware handling
  • All devices appear in the /dev directory
  • Devices are treated as files; file operations mirror Windows dispatch routines
Device TypeDescription
Block Device512-byte chunks, random access (e.g., disk drives)
Character DeviceUnbuffered direct access to hardware

Virtualization

Virtual Machine Monitor (VMM) / Hypervisor

Software that creates and manages Virtual Machines by acting as the interface between guest OS and physical hardware.

VMM TypeDescription
Hypervisor VMMMaximum control and performance; uses its own drivers
Host OS VMMInstalled on existing OS; I/O redirected to VM
Service OS VMMCombines hypervisor robustness with host OS flexibility

Guest OS Virtualization Techniques

TechniqueDescription
Virtualization ApplicationSoftware layer enabling VM creation
Binary RewritingIntercepts and modifies instructions for compatibility
Shared Kernel VirtualizationGuest OS shares the host kernel

Root File System

  • Contains all libraries, files, and utilities required for OS functionality
  • Foundation of the OS directory structure


References / Images

  • Memory management diagrams (paging, swapping)
  • Windows and Linux driver stack illustrations
  • Hypervisor and guest OS virtualization diagrams