Operating Systems: Memory Management, Storage, and Process Scheduling

Memory Management

RAM (Random Access Memory)

Volatile, fast access.

ROM (Read-Only Memory)

Non-volatile, stores firmware.

Memory Hierarchy

  • Registers -> Cache -> Main Memory -> Secondary Storage

Cache Memory

  • Levels: L1 (fastest), L2, L3.
  • Mapping: Direct, associative, set-associative.
  • Replacement Policies: LRU (Least Recently Used), FIFO (First In First Out), Random.

Memory Allocation

  • Fixed Partitioning: Fixed-size blocks.
  • Dynamic Partitioning: Variable-size blocks, uses algorithms like Best-Fit, Worst-Fit, First-Fit.
  • Paging: Divides memory into fixed-size pages.
  • Segmentation: Divides memory into segments based on logical divisions.

Virtual Memory

  • Extends physical memory onto disk.
  • Enables a larger address space.

Paging

  • Page Table: Maps virtual pages to physical frames.
  • TLB (Translation Lookaside Buffer): Cache for page table entries.
  • Page Replacement Algorithms: FIFO, LRU, Optimal.

Segmentation

  • Divides programs into segments (code, stack, data).
  • Uses a segment table.

Combined Paging and Segmentation

  • Uses both for flexible memory management.

Demand Paging

  • Loads pages into memory only when needed.
  • Page Fault: Occurs when accessing a page not in memory.

Mass Storage

Disk Structure

  • Platters: Multiple spinning disks.
  • Tracks: Concentric circles on a platter.
  • Sectors: Subdivisions of tracks.
  • Cylinders: Group of tracks aligned vertically.

Disk Scheduling Algorithms

  • FCFS (First-Come, First-Served): Processes requests in order received.
  • SSTF (Shortest Seek Time First): Selects the request with the shortest seek time.
  • SCAN: Moves the head in one direction, then reverses.
  • C-SCAN: Circular SCAN, the head returns to the start after reaching the end.
  • LOOK/C-LOOK: Variants of SCAN/C-SCAN that only go as far as the last request.

RAID Levels

  • RAID 0: Striping, no redundancy.
  • RAID 1: Mirroring.
  • RAID 5: Striping with parity.
  • RAID 6: Striping with double parity.
  • RAID 10: Combination of striping and mirroring.

Process Scheduling

Processes alternate between CPU and I/O bursts.

Scheduling Events

  • Running -> Waiting
  • Running -> Ready
  • Waiting -> Ready
  • Termination

Scheduling Algorithms

  • FCFS (First-Come, First-Served): Simple, non-preemptive.
  • SJF (Shortest Job First): Optimal, but hard to predict.
  • SRTF (Shortest Remaining Time First): Preemptive SJF.
  • Priority Scheduling: Assigns priority to each process.
  • Round Robin (RR): Each process gets a fixed time quantum.
  • Multilevel Queue: Multiple queues with different priorities.
  • Multilevel Feedback Queue: Processes can move between queues based on behavior.

Evaluation Metrics

  • CPU Utilization: % of time CPU is active.
  • Throughput: Number of processes completed per unit time.
  • Turnaround Time: Total time taken to complete a process.
  • Waiting Time: Time a process spends in the ready queue.
  • Response Time: Time from request submission to first response.