Operating Systems — Notes & 50 MCQs

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.

50 Practice MCQs — Correct answers highlighted

1. What is a process?

  • A) A program in execution ✅
  • B) A program stored on disk
  • C) A file descriptor
  • D) A hardware interrupt

2. Which state transition occurs when a process finishes its CPU burst and needs I/O?

  • A) Running -> Ready
  • B) Running -> Blocked (Waiting) ✅
  • C) Ready -> Running
  • D) Blocked -> Terminated

3. Which scheduler decides which process runs next on CPU?

  • A) Short-term (CPU) scheduler ✅
  • B) Long-term scheduler
  • C) Medium-term scheduler
  • D) I/O scheduler

4. Which scheduling algorithm minimizes average waiting time but may cause starvation?

  • A) Shortest Job First (SJF) ✅
  • B) First-Come First-Serve
  • C) Round Robin
  • D) Priority with aging

5. What is a thread?

  • A) A lightweight process sharing address space ✅
  • B) A separate process with its own address space
  • C) A file system structure
  • D) A memory page

6. Which mechanism prevents race conditions?

  • A) Mutual exclusion (locks/mutex) ✅
  • B) Caching
  • C) Paging
  • D) Swapping

7. Which of the following is NOT a necessary condition for deadlock?

  • A) Preemption ✅
  • B) Mutual exclusion
  • C) Hold and wait
  • D) Circular wait

8. What does 'thrashing' refer to?

  • A) Excessive paging causing low CPU utilization ✅
  • B) High CPU usage with no I/O
  • C) Disk failure
  • D) Network congestion

9. Which page replacement algorithm approximates LRU with low overhead?

  • A) Clock (Second chance) ✅
  • B) FIFO
  • C) Optimal
  • D) Random

10. What is the role of the Translation Lookaside Buffer (TLB)?

  • A) Cache recent page table entries for fast virtual-to-physical translation ✅
  • B) Store disk blocks
  • C) Manage process states
  • D) Schedule I/O

11. What does context switch involve?

  • A) Saving and restoring process state ✅
  • B) Flushing disk cache
  • C) Changing file permissions
  • D) Rebooting the system

12. Which scheduling algorithm gives each process a small fixed time slice?

  • A) Round Robin ✅
  • B) SJF
  • C) FCFS
  • D) Multilevel Queue

13. Which structure stores per-process information like registers, memory limits, and process state?

  • A) Process Control Block (PCB) ✅
  • B) Page Table
  • C) File Table
  • D) TLB

14. What is virtual memory?

  • A) Illusion of large logical memory using disk as backing store ✅
  • B) Physical RAM only
  • C) Cache memory
  • D) GPU memory

15. Which of the following is a method of dynamic memory allocation?

  • A) Buddy system ✅
  • B) Skip lists
  • C) Inode allocation
  • D) Hashing

16. Which file allocation method stores file as a linked list of disk blocks?

  • A) Linked allocation ✅
  • B) Contiguous allocation
  • C) Indexed allocation
  • D) FAT only

17. What does 'semaphores' primarily provide?

  • A) Synchronization primitives for controlling access ✅
  • B) Memory allocation
  • C) File indexing
  • D) Network routing

18. Which is true about kernel mode vs user mode?

  • A) Kernel mode has full hardware access, user mode is restricted ✅
  • B) User mode can access hardware directly
  • C) Kernel mode is slower than user mode always
  • D) They are the same

19. Which command traces system calls made by a process (Linux)?

  • A) strace ✅
  • B) top
  • C) ps
  • D) vmstat

20. Which algorithm avoids deadlock by ensuring a safe state?

  • A) Banker's algorithm ✅
  • B) FIFO
  • C) Round Robin
  • D) LRU

21. Which technique speeds up disk I/O by grouping nearby requests?

  • A) Disk scheduling (e.g., SCAN, C-SCAN) ✅
  • B) Paging
  • C) Swapping
  • D) Context switching

22. What is copy-on-write?

  • A) Delay copying until modification to save memory ✅
  • B) Immediate deep copy always
  • C) Disk cloning tool
  • D) Page replacement strategy

23. Which structure maps virtual page numbers to physical frame numbers?

  • A) Page table ✅
  • B) Inode table
  • C) File descriptor table
  • D) Swap table

24. Which is a journaling file system?

  • A) ext4 ✅
  • B) FAT16
  • C) NTFS without journaling
  • D) ISO9660

25. Which command shows memory usage in Linux?

  • A) free ✅
  • B) ls
  • C) chmod
  • D) cat

26. What is preemptive multitasking?

  • A) OS forcibly switches processes after time slice ✅
  • B) Processes voluntarily yield CPU only
  • C) Single-threaded execution
  • D) No context switching

27. Which of the following is true about user-level threads?

  • A) Managed by user-level library, fast context switch, but blocking system calls block entire process ✅
  • B) Managed by OS kernel only
  • C) Cannot be implemented in user space
  • D) Always better than kernel threads

28. Which mechanism isolates processes and provides security boundaries?

  • A) Virtual memory and process isolation ✅
  • B) Caches only
  • C) Disk partitioning only
  • D) File permissions only

29. Which layer handles system calls like open, read, write?

  • A) Kernel (system call interface) ✅
  • B) User libraries only
  • C) File system only
  • D) Device drivers only

30. What is the advantage of multithreaded servers?

  • A) Can handle many concurrent clients with shared memory, lower overhead than processes ✅
  • B) Simpler to implement than single-threaded
  • C) Uses more memory than multiple processes always
  • D) Avoids synchronization entirely

31. Which file system structure stores metadata in inodes?

  • A) Unix-like file systems (e.g., ext) ✅
  • B) FAT only
  • C) NTFS only
  • D) HFS only

32. Which synchronization primitive allows signaling between threads?

  • A) Condition variable ✅
  • B) Spinlock
  • C) Interrupts
  • D) Semaphores only

33. What is demand paging?

  • A) Loading pages into memory only when referenced ✅
  • B) Preloading all pages at process start
  • C) Swapping entire process immediately
  • D) Disk defragmentation

34. Which is a disadvantage of contiguous file allocation?

  • A) External fragmentation and difficulty growing files ✅
  • B) High metadata overhead
  • C) Slow sequential access
  • D) No random access possible

35. Which mechanism provides faster IPC on the same machine?

  • A) Shared memory ✅
  • B) Socket communication
  • C) Remote procedure call (RPC)
  • D) Message queues only

36. Which algorithm is used to select a victim page for replacement by predicting future references?

  • A) Optimal (Belady's) algorithm ✅
  • B) LRU
  • C) FIFO
  • D) Clock

37. Which of these is true about kernel preemption?

  • A) Allowing preemption in kernel improves responsiveness at cost of complexity ✅
  • B) Kernel always non-preemptive
  • C) Preemption reduces context switches
  • D) Preemption disables interrupts permanently

38. What is the primary purpose of an I/O scheduler?

  • A) Order and optimize disk requests for performance ✅
  • B) Manage network traffic
  • C) Allocate memory pages
  • D) Handle process creation

39. Which technique is used to recover from deadlocks by forcing preemption?

  • A) Resource preemption and rollback ✅
  • B) Ignoring deadlocks
  • C) Increasing time slices
  • D) Swapping only

40. Which metric measures how long a process takes from submission to completion?

  • A) Turnaround time ✅
  • B) Waiting time
  • C) Response time
  • D) Throughput

41. Which system component manages device drivers and hardware access?

  • A) Kernel ✅
  • B) Shell
  • C) Application layer
  • D) File system

42. What is kernel panic?

  • A) Fatal OS error forcing halt/reboot ✅
  • B) High CPU utilization only
  • C) Memory leak detection
  • D) Normal shutdown

43. Which technique improves performance by keeping frequently used pages in memory?

  • A) Working set model ✅
  • B) FIFO
  • C) Random replacement
  • D) Contiguous allocation

44. Which command shows running processes in Linux?

  • A) ps/top ✅
  • B) ls
  • C) chmod
  • D) mount

45. Which concept allows multiple processes to access CPU concurrently?

  • A) Multiprogramming ✅
  • B) Multitasking only
  • C) Multithreading only
  • D) Single processing

46. What is the difference between paging and segmentation?

  • A) Paging divides memory into fixed-size pages; segmentation uses variable-size logical segments ✅
  • B) Segmentation is hardware only
  • C) Paging allows variable-sized pages
  • D) They are identical

47. Which of the following is true about swap space?

  • A) Used as backing store for pages when memory is overcommitted ✅
  • B) Stores executable binaries only
  • C) Is the same as file cache
  • D) Cannot be used for hibernation

48. Which term describes switching between user and kernel mode?

  • A) System call / trap ✅
  • B) Interrupt only
  • C) Context switch always
  • D) Paging

49. Which scheduling metric measures how many processes complete per unit time?

  • A) Throughput ✅
  • B) Turnaround time
  • C) Waiting time
  • D) Response time

50. Which Linux subsystem is responsible for managing filesystems and mounting?

  • A) VFS (Virtual File System) ✅
  • B) systemd
  • C) udev
  • D) init