Detailed Operating Systems Notes
Concise but thorough coverage: processes, threads, CPU scheduling, memory management, virtual memory, file systems, I/O, concurrency, deadlock, security, and practical tuning tips.
1. What is an Operating System (OS)?
An OS is system software that manages hardware resources and provides services to applications. It acts as an intermediary between user programs and hardware.
2. Processes & Threads
Process: program in execution — has its own address space, PCB (process control block), registers, and state. Thread: lightweight process sharing address space with other threads in the same process. Multithreading improves concurrency and resource utilization.
3. CPU Scheduling
Schedulers: long-term, medium-term, short-term. Common algorithms: FCFS, SJF, SRTF, Round Robin, Priority Scheduling, Multilevel Queue, Multilevel Feedback Queue. Metrics: throughput, turnaround, waiting, response time, fairness.
4. Synchronization & Concurrency
Problems: race conditions, critical sections. Mechanisms: locks (mutex), semaphores, monitors, condition variables. Deadlock: mutual exclusion, hold and wait, no preemption, circular wait. Prevention, avoidance (Banker's algorithm), detection & recovery.
5. Memory Management
Contiguous allocation, paging, segmentation. Virtual memory provides process illusion of large contiguous memory using paging, page tables, TLBs, page replacement algorithms (LRU, FIFO, Optimal, Clock).
6. Virtual Memory & Paging
Pages & frames, demand paging, copy-on-write, thrashing (excessive page faults). Working set model and locality of reference help control thrashing.
7. File Systems
File abstraction, directories, inodes, file allocation methods (contiguous, linked, indexed), journaling file systems (ext4, NTFS), metadata, permissions, and caching. Mounting and virtual file systems (VFS).
8. I/O Systems
Device drivers, polling vs interrupts, DMA, buffering, spooling. Block vs character devices. Performance tuning: batching, asynchronous I/O.
9. Deadlock
Deadlock handling techniques: prevention (breaking one of the necessary conditions), avoidance (Banker), detection (resource allocation graphs), and recovery (preemption, rollback).
10. Security & Protection
Access control, authentication, authorization, encryption, secure kernels, sandboxing, least privilege. Practical: patching, minimizing trusted computing base.
11. Performance Tuning
Use profiling to find bottlenecks, tune scheduler quantum, adjust cache sizes, monitor page fault rates, and use appropriate filesystem for workload.