Operating System - Complete Notes
Unit 1: Introduction to OS
Q: Define an operating system and explain its major functions.
A: An Operating System (OS) is a system software that manages computer hardware, software resources,
and provides common services for computer programs.
Major Functions:
- Process Management
- Memory Management
- File System Management
- Device Management
- Security and Protection
- User Interface
Q: Differentiate between monolithic and microkernel architectures.
A: Monolithic Kernel:
- Entire OS runs in kernel space.
- Faster due to less context switch.
- Examples: Linux, Unix
Microkernel:
- Only essential functions in kernel.
- User services run in user space.
- More secure and modular.
- Example: Minix, QNX
Operating System - Complete Notes
Q: Compare multiprogramming, multitasking, timesharing, realtime, multiuser, and multithreaded
systems.
A: - Multiprogramming: Multiple programs in memory.
- Multitasking: Switch between tasks fast.
- Time-sharing: Equal CPU time slots.
- Real-time: Strict timing constraints.
- Multiuser: Multiple users access system.
- Multithreaded: Multiple threads in a process.
Unit 2: Concurrency & Synchronization
Q: Explain the Critical Section Problem and define the required conditions for a safe solution.
A: Critical Section Problem: Occurs when multiple processes access shared data.
Conditions for Safe Solution:
- Mutual Exclusion
- Progress
- Bounded Waiting
Q: Describe semaphores (binary vs counting) and illustrate a solution to the ProducerConsumer
problem.
A: - Binary Semaphore: Only 0 and 1.
- Counting Semaphore: Integer value.
Producer-Consumer using semaphores:
- Use 'empty', 'full', and 'mutex' semaphores to control access.
Operating System - Complete Notes
Q: Explain classical synchronization problems Dining Philosophers, Sleeping Barber and their
solutions with semaphores or monitors.
A: - Dining Philosophers: Avoid deadlock using semaphore or mutex.
- Sleeping Barber: Use semaphores for barber, waiting chairs, and customers.
Unit 3: CPU Scheduling & Deadlocks
Q: Diagram and explain process states and context switching.
A: States: New -> Ready -> Running -> Waiting -> Terminated
Context Switching: Saving and loading process state during switch.
Q: Compare scheduling algorithms: FCFS, SJF (preemptive and nonpreemptive), Priority, Round
Robin with examples and Gantt charts.
A: - FCFS: First-Come-First-Serve
- SJF: Shortest Job First
- Priority: Based on priority value
- RR: Time quantum-based round robin scheduling
Q: Define deadlock: list the four necessary conditions and discuss prevention, avoidance (Bankers
algorithm), detection, recovery.
A: - Deadlock: Set of processes blocked.
Conditions:
1. Mutual Exclusion
2. Hold and Wait
3. No Preemption
Operating System - Complete Notes
4. Circular Wait
- Prevention: Eliminate one condition
- Avoidance: Bankers Algorithm
- Detection: Resource Allocation Graph
- Recovery: Process Termination
Unit 4: Memory Management
Q: Explain paging vs segmentation, and paged segmentation.
A: - Paging: Fixed-size pages
- Segmentation: Variable-size segments
- Paged Segmentation: Segments divided into pages
Q: Describe virtual memory concepts: demand paging, page replacement algorithms (FIFO, LRU,
optimal), thrashing.
A: - Virtual Memory: Logical extension of RAM
- Demand Paging: Load pages as needed
- FIFO, LRU, Optimal: Page replacement
- Thrashing: Excessive page faults
Q: Discuss fragmentation (external vs internal) and how paging/segmentation address them.
A: - Internal: Wasted space inside blocks
- External: Wasted space outside blocks
- Paging removes external fragmentation
- Segmentation reduces internal fragmentation
Operating System - Complete Notes
Unit 5: I/O & File Systems
Q: Explain disk scheduling FCFS, SSTF, SCAN, CSCAN and solve head movement problems.
A: - FCFS: Process in arrival order
- SSTF: Nearest track first
- SCAN: Elevator algorithm
- CSCAN: Circular SCAN
Q: Define RAID, list levels (RAID 0, 1, 5 etc.), give pros & cons.
A: - RAID 0: Striping, no redundancy
- RAID 1: Mirroring
- RAID 5: Block-level with parity
- Pros: Reliability, Performance
- Cons: Cost, Complexity
Q: Describe file system concepts: file directories, access methods, implementation, protection &
security.
A: - Directories: Single-level, Two-level, Tree
- Access: Sequential, Direct
- Implementation: Contiguous, Linked, Indexed
- Security: Permissions, Encryption