Operating System Notes
1. Introduction to Operating System
An Operating System (OS) is system software that acts as an interface between the user and hardware. It
manages resources and provides services for applications.
Functions of OS:
1. Process Management
2. Memory Management
3. File Management
4. Device Management
5. Security and Protection
6. User Interface
Types of OS:
1. Batch OS
2. Time-Sharing OS
3. Distributed OS
4. Real-Time OS
5. Multi-User OS
2. Process Management
A process is a program in execution.
States of a Process:
1. New
2. Ready
3. Running
4. Waiting
5. Terminated
Process Scheduling:
- Long-Term Scheduler: Selects processes to load into memory.
- Short-Term Scheduler: Chooses the next process for CPU.
- Medium-Term Scheduler: Swaps processes in/out of memory.
3. CPU Scheduling Algorithms
CPU scheduling determines which process runs at any point in time.
Algorithms:
1. First-Come, First-Served (FCFS): Non-preemptive. Processes execute in arrival order.
2. Shortest Job First (SJF): Selects the process with the shortest burst time.
3. Round Robin (RR): Time-sharing algorithm where each process gets a fixed time slot.
4. Priority Scheduling: Process with the highest priority runs first.
5. Multilevel Queue Scheduling: Divides processes into queues based on priority.
4. Memory Management
Memory management handles allocation and deallocation of memory to processes.
Techniques:
- Paging: Divides memory into fixed-size pages.
- Segmentation: Divides memory into variable-sized segments.
- Virtual Memory: Allows programs larger than physical memory to execute using techniques like paging.
Page Replacement Algorithms:
1. FIFO (First-In, First-Out)
2. LRU (Least Recently Used)
3. Optimal
5. Deadlocks
Deadlock is a situation where processes wait indefinitely for resources.
Necessary Conditions:
1. Mutual Exclusion
2. Hold and Wait
3. No Preemption
4. Circular Wait
Deadlock Prevention: Eliminates one of the conditions.
Deadlock Detection: Uses resource allocation graphs to detect cycles.
Deadlock Recovery:
- Terminate processes.
- Preempt resources.
6. File Management
File management involves creating, organizing, and managing files and directories.
File Attributes: Name, size, type, location, etc.
File Operations: Create, delete, read, write, and move files.
Directory Structures:
1. Single-Level
2. Two-Level
3. Hierarchical
4. Acyclic Graph
7. Device Management
Device management handles I/O operations and peripheral devices.
I/O Scheduling:
1. FCFS
2. SSTF (Shortest Seek Time First)
3. SCAN (Elevator Algorithm)
Spooling: Allows simultaneous I/O and CPU execution.
8. Security and Protection
The OS ensures protection against unauthorized access.
Methods:
- Authentication: Verifying users (e.g., passwords).
- Access Control: Managing user permissions.
- Encryption: Protects data from unauthorized access.