Operating System - Detailed Study Notes
System Calls
• System calls provide an interface between a process and the operating system.
• They allow user-level processes to request services such as file operations, process
control, and communication.
• Common types: Process control, File management, Device management, Information
maintenance, Communication.
• Example: read(), write(), fork(), exec(), wait(), exit().
Processes
• A process is a program in execution that requires CPU time, memory, files, and I/O
devices.
• Each process has a Process Control Block (PCB) containing information like process ID,
state, registers, and priority.
• Process states: New → Ready → Running → Waiting → Terminated.
• Operations on processes: creation, scheduling, execution, termination.
Threads
• A thread is the smallest unit of CPU utilization, often called a lightweight process.
• Threads within the same process share code, data, and resources but have separate
registers and stack.
• Benefits: Responsiveness, resource sharing, economy, scalability.
• Multithreading models: Many-to-One, One-to-One, Many-to-Many.
Inter Process Communication (IPC)
• IPC allows processes to communicate and synchronize their actions.
• Methods: Shared memory and Message passing.
• Shared Memory: Processes share a region of memory for communication; faster but
requires synchronization.
• Message Passing: Processes exchange data via send/receive operations; safer and
simpler in distributed systems.
Concurrency and Synchronization
• Concurrency refers to multiple processes executing simultaneously (possibly overlapping).
• Synchronization ensures ordered execution to avoid race conditions.
• Race condition: when multiple processes access shared data simultaneously leading to
unpredictable results.
• Synchronization tools: Locks, Semaphores, Monitors, Condition variables.
• Critical Section Problem: Each process must ensure mutual exclusion, progress, and
bounded waiting.
Deadlock
• A deadlock occurs when two or more processes are waiting for resources held by each
other, and none can proceed.
• Necessary conditions (Coffman): Mutual exclusion, Hold and wait, No preemption, Circular
wait.
• Handling strategies: Deadlock prevention, avoidance (Banker’s Algorithm), detection, and
recovery.
CPU and I/O Scheduling
• CPU scheduling determines which process gets the CPU next; goal is to maximize CPU
utilization and throughput.
• Scheduling criteria: CPU utilization, throughput, turnaround time, waiting time, response
time.
• Scheduling algorithms: FCFS, SJF, Priority, Round Robin, Multilevel Queue.
• I/O scheduling decides the order of I/O requests to optimize performance.
• Common I/O scheduling algorithms: FCFS, SSTF, SCAN, C-SCAN.
Memory Management and Virtual Memory
• Memory management allocates and deallocates memory to processes efficiently.
• Techniques: Contiguous allocation, Paging, Segmentation.
• Paging: divides memory into fixed-size blocks (pages); avoids external fragmentation.
• Segmentation: divides memory into variable-sized segments; closer to logical structure of
programs.
• Virtual Memory: allows execution of processes not fully in physical memory using demand
paging and page replacement algorithms (LRU, FIFO, Optimal).
• Benefits: Enables multitasking, isolates processes, improves system efficiency.