Role of an operating system
Abstracts hardware complexity and manages system resources (CPU, memory, I/O, storage, devices) to provide a stable platform for applications.
Kernel vs user-space
Kernel performs privileged operations and manages hardware; user-space runs applications without direct hardware access.
System call
Mechanism by which user programs request services from the kernel (e.g., open file, allocate memory).
Main functions of an operating system
Process management, memory management, file system, device management, scheduling, security, GUI, virtualization, networking, accounting.
User interface vs programming interface
GUI/CLI are interfaces for users
APIs/system calls are interfaces for programs.
Process states
New, Ready, Running, Waiting (Blocked), Terminated - typical process lifecycle.
Context switch
Saving and restoring CPU state (registers, program counter) when switching processes; introduces overhead.
Preemption
Interrupting a running process to run a higher-priority one; essential for RTOS and fairness.
Purpose of process scheduling
Optimize CPU usage, ensure responsiveness, meet deadlines (in RTOS) and fairness between processes.
FCFS (First-Come First-Served) characteristics
Simple: tasks served in arrival order; drawback: convoy effect (long job blocks short ones).
Round Robin characteristics
Time-sliced scheduling (quantum) for fairness; quantum size affects latency and context-switch overhead.
Priority scheduling
Higher-priority processes run before lower-priority ones; risk of starvation for low-priority processes.
Multilevel queue scheduling
Processes are divided into queues (e.g., interactive, batch), each with its own policy and priority level between queues.
EDF (Earliest Deadline First)
Dynamic scheduling for real-time systems: job with closest deadline runs first.
RMS (Rate Monotonic Scheduling)
Static priority scheduling for periodic tasks: shorter period = higher priority, with schedulability guarantees under assumptions.
Comparing Round Robin vs Priority
RR: fairness and responsiveness for interactive tasks
Priority: better for time-critical tasks but requires starvation mitigation
Convoy effect explanation
A long job at the head of the queue delays many short tasks, reducing responsiveness.
What is an interrupt?
Hardware or software signal that temporarily halts CPU execution to run an interrupt handler.
Advantages of interrupts
Lower CPU overhead, immediate reaction to events, suitable for I/O and real-time tasks.
Polling - what and when
CPU repeatedly checks device status; simple but CPU-intensive; used when interrupts are unavailable or polling cost is acceptable.
Polling vs interrupts comparison
Polling: simple but wastes CPU
Interrupts: efficient and responsive but more complex to handle and manage context switching
Virtual memory concept
Mapping logical addresses to physical memory using pages, providing isolation and ability to use disk as extension of RAM.
Paging vs segmentation
Paging: fixed-size pages
Segmentation: logical segments of variable length (code, data, stack)
Swapping and thrashing
Swapping: moving processes between RAM and disk
Thrashing: excessive swapping causing low throughput and high overhead