OS_Notes
OS_Notes
## 1. Process Management
A process is a program in execution. The operating system manages processes to ensure efficient executio
- **Process States:**
- **Suspended Ready:** Process is moved to secondary storage due to memory constraints but can be re
- **Suspended Blocked:** A blocked process that has been swapped out to secondary storage.
- **Scheduling Algorithms:**
- **FCFS (First Come First Serve):** Non-preemptive, processes are executed in order of arrival. Simple b
- **SJF (Shortest Job First):** The process with the shortest execution time is selected first. Optimal but m
- **SRTF (Shortest Remaining Time First):** Preemptive version of SJF, allowing interruption of longer tas
- **Round Robin (RR):** Each process gets a fixed time slice before moving to the next. Ensures fairness
- **Priority Scheduling:** Processes with higher priority execute first. Can be preemptive or non-preemptiv
- **Context Switching:** The process of saving and restoring the state of a process so the CPU can switch
- **Process Control Block (PCB):** A data structure that stores process details such as process ID, state, p
## 2. CPU Scheduling
CPU scheduling determines which process gets CPU time for execution.
- **Schedulers:**
- **Long-Term Scheduler (Job Scheduler):** Controls the admission of processes into the system, affectin
- **Short-Term Scheduler (CPU Scheduler):** Selects which process runs next on the CPU.
- **Mid-Term Scheduler (Swapper):** Moves processes between main memory and disk to optimize syste
- **Starvation:** Occurs when low-priority processes are ignored due to continuous execution of high-prior
## 3. Process Synchronization
- **Critical Section Problem:** A segment of code where shared resources are accessed. A solution must s
1. **Mutual Exclusion:** Only one process can enter the critical section at a time.
2. **Progress:** If no process is in the critical section, one should be able to enter it.
3. **Bounded Waiting:** A process should not wait indefinitely to enter the critical section.
- **Peterson's Algorithm:** A software-based solution for mutual exclusion between two processes.
- **Semaphores:**
- **Dining Philosophers Problem:** A classic synchronization problem dealing with resource sharing among
## 4. Deadlocks
A deadlock occurs when processes are indefinitely waiting for resources held by other processes.
2. **Hold and Wait:** Processes hold some resources while waiting for others.
4. **Circular Wait:** A circular chain of processes exists, each waiting for a resource held by the next proc
- **Deadlock Avoidance:** Uses algorithms like Banker's Algorithm to ensure safe resource allocation.
- **Deadlock Detection & Recovery:** Identifies deadlocks and resolves them by terminating processes or p
## 5. Memory Management
- **Segmentation:** Divides memory into variable-sized logical sections (segments), leading to external frag
- **Virtual Memory & Demand Paging:** Uses secondary storage as additional memory space, allowing exe
- **Cache Management:** Stores frequently accessed data in fast-access memory to reduce processing tim
- **SSTF (Shortest Seek Time First):** Selects the request closest to the current disk position.
- **SCAN & C-SCAN:** Moves in one direction before reversing, reducing seek time.
## 7. System Calls & OS Structure
- **OS Types:**
- **Monolithic Kernel:** Single large kernel with all OS services (e.g., Linux, Unix).
- **Microkernel:** Minimal kernel with essential services, improving security (e.g., QNX, Minix).
- **Race Conditions:** Occur when multiple processes modify shared data simultaneously. Solved using sy
## 9. Important Formulas
1. Solve CPU scheduling problems (SJF, SRTF, Round Robin, Preemptive Priority).