0% found this document useful (0 votes)
2 views

OS_Notes

The document provides comprehensive notes on Operating Systems, covering key topics such as process management, CPU scheduling, process synchronization, deadlocks, memory management, file and disk management, system calls, OS structure, and inter-process communication. It details various process states, scheduling algorithms, synchronization mechanisms, and deadlock conditions, along with their prevention and recovery strategies. Additionally, it includes important formulas for turnaround, waiting, and response times, as well as expected exam questions related to these topics.

Uploaded by

kaushalabhay15
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

OS_Notes

The document provides comprehensive notes on Operating Systems, covering key topics such as process management, CPU scheduling, process synchronization, deadlocks, memory management, file and disk management, system calls, OS structure, and inter-process communication. It details various process states, scheduling algorithms, synchronization mechanisms, and deadlock conditions, along with their prevention and recovery strategies. Additionally, it includes important formulas for turnaround, waiting, and response times, as well as expected exam questions related to these topics.

Uploaded by

kaushalabhay15
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

# Operating System (OS) Notes

## 1. Process Management

A process is a program in execution. The operating system manages processes to ensure efficient executio

- **Process States:**

- **New:** Process is being created.

- **Ready:** Process is waiting for CPU allocation.

- **Running:** Process is currently executing.

- **Blocked (Waiting):** Process is waiting for an event (e.g., I/O completion).

- **Terminated:** Process has finished execution.

- **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 & Aging:**

- **Starvation:** Occurs when low-priority processes are ignored due to continuous execution of high-prior

- **Aging:** Prevents starvation by gradually increasing process priority over time.

## 3. Process Synchronization

Ensures correct execution of concurrent processes by handling shared resource access.

- **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:**

- **Binary Semaphore (Mutex):** Used to enforce mutual exclusion.

- **Counting Semaphore:** Allows multiple processes to access a limited number of resources.

- **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.

- **Conditions for Deadlock:**


1. **Mutual Exclusion:** Resources cannot be shared.

2. **Hold and Wait:** Processes hold some resources while waiting for others.

3. **No Preemption:** Resources cannot be forcibly taken from processes.

4. **Circular Wait:** A circular chain of processes exists, each waiting for a resource held by the next proc

- **Deadlock Prevention:** Avoids deadlock by breaking one of the above conditions.

- **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

Handles memory allocation and deallocation for processes.

- **Paging:** Divides memory into fixed-size blocks (pages), reducing fragmentation.

- **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

## 6. File & Disk Management

Handles data storage, retrieval, and organization on disks.

- **File Systems:** Organize and manage files.

- **Hierarchical:** Uses directories for structured storage.

- **Linked:** Uses pointers to connect file blocks.

- **Indexed:** Uses an index table for fast access.

- **Disk Scheduling Algorithms:**

- **FCFS (First Come First Serve):** Processes requests in arrival order.

- **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

System calls allow user programs to request OS services.

- **System Call Types:**

- **Process Control:** Create, terminate, wait (e.g., fork(), exit()).

- **File Management:** Open, close, read, write files.

- **Device Management:** Interact with hardware (e.g., ioctl()).

- **Information Maintenance:** Retrieve system info (e.g., getpid()).

- **Communication:** Send/receive messages (e.g., pipe(), socket()).

- **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).

- **Real-Time OS (RTOS):** Guarantees timely task execution (e.g., FreeRTOS, VxWorks).

- **Multiprocessor OS:** Manages multiple CPUs efficiently.

## 8. Inter-Process Communication (IPC)

Enables processes to communicate and synchronize their execution.

- **Shared Memory:** Allows direct memory access for communication.

- **Message Passing:** Uses send/receive mechanisms for communication.

- **Race Conditions:** Occur when multiple processes modify shared data simultaneously. Solved using sy

## 9. Important Formulas

- **Turnaround Time (TAT) = Completion Time - Arrival Time**

- **Waiting Time (WT) = Turnaround Time - Burst Time**


- **Response Time (RT) = First Execution Time - Arrival Time**

## 10. Expected Exam Questions

1. Solve CPU scheduling problems (SJF, SRTF, Round Robin, Preemptive Priority).

2. Draw Gantt charts and calculate waiting/turnaround times.

3. Explain Process Synchronization (Peterson's Algorithm, Semaphores).

4. Solve Deadlock scenarios (Banker's Algorithm, Prevention methods).

5. Compare Monolithic and Microkernel OS.

6. Describe Process States with a diagram.

7. Discuss Context Switching and PCB.

8. Explain System Calls and IPC mechanisms.

9. Solve Dining Philosophers problem using Semaphores.

10. Explain Aging, Starvation, and solutions.

You might also like