Operating System Question Paper AI-1
Operating System Question Paper AI-1
The FIFO Page Replacement Algorithm operates by replacing the oldest page in memory when a new page is needed, using a first-in, first-out approach. The simplicity of FIFO makes it easy to implement, but it can lead to efficiency drawbacks such as the Belady's anomaly, where increasing the number of page frames results in more page faults. This occurs because FIFO does not account for page usage patterns or frequency, leading to suboptimal decisions when less frequently used but critical pages are removed before less crucial ones .
Paging divides memory into fixed-size pages corresponding to frames in physical memory, simplifying allocation and avoiding external fragmentation, though it can suffer from internal fragmentation. It provides easy virtual to physical address mapping but does not reflect the logical view of programs. Segmentation allocates memory in variable-size segments based on logical units such as functions or data structures, aligning with the program structure and providing isolated memory spaces for different modules. This facilitates protection and sharing but can lead to external fragmentation .
Fixed Partitioning divides memory into a set number of small fixed-size partitions, leading to internal fragmentation when memory requirements of processes do not match partition sizes. This often results in wasted space but simplifies memory allocation bookkeeping. Variable Partitioning allocates memory dynamically sized to fit process requirements, reducing internal fragmentation but potentially increasing external fragmentation where free space is fragmented into small unusable chunks. Fixed Partitioning is easier to manage and predict but less flexible than Variable Partitioning, which better utilizes memory at the expense of complex management .
Round Robin (RR) scheduling allocates a fixed time slice or quantum to each process in the ready queue, cycling through them and ensuring a fair CPU time distribution. This can lead to increased overhead due to frequent context switches but minimizes process starvation. In contrast, Shortest Job First (SJF) selects the process with the smallest execution time next, which can minimize average waiting time but may cause starvation for longer processes. RR performs better in time-sharing systems where fairness is crucial, while SJF is more efficient in batch systems where minimizing average wait time is prioritized .
Thrashing occurs when a system spends a significant amount of time swapping pages in and out of memory rather than executing processes, drastically reducing performance. It is caused by processes exceeding available physical memory, leading to excessive paging. Strategies to mitigate thrashing include implementing the Working Set Model to ensure processes have enough pages loaded for efficient operation, deploying page replacement algorithms like LRU to prioritize frequently used pages, and increasing physical memory to better handle load demands. These strategies help stabilize memory use and improve overall system throughput .
The Dining Philosopher Problem models the challenges of allocating limited resources (forks) among multiple processes (philosophers) without causing deadlock or resource starvation. It illustrates the complexities of ensuring safe and efficient resource sharing while avoiding deadlock conditions such as circular waiting. A practical solution is using a waiter or an arbitrator that grants forks only when all are available, ensuring that resources are allocated atomically. Alternatively, using semaphores to control fork access can prevent deadlock by breaking the circular wait condition .
Peterson's Solution is effective in achieving mutual exclusion by using two shared variables to alternate access and ensure entry and exit sections control before critical section execution. However, its practical application is limited in modern multiprocessor systems due to assumptions of atomicity in flag setting and checking operations, which may not hold on contemporary architectures with instruction reordering and caching mechanisms. Additionally, Peterson's Solution works only for two processes, limiting its scalability in environments requiring broader concurrency handling .
The Process Control Block (PCB) is crucial in context switching as it stores the information associated with a process, such as its process state, program counter, CPU registers, memory limits, and open files. During a context switch, the operating system must save the state of the currently running process into its PCB and then load the saved state of the next process to be executed. This ensures that processes can be paused and resumed correctly, maintaining their execution state and other vital data .
The Working Set Model plays an important role in memory management by keeping track of the set of pages currently in use by a process, determining the necessary pages that must be loaded to minimize page faults. It addresses thrashing by adjusting the number of allocated frames to a process based on its current working set size, thereby ensuring that each process has sufficient memory to operate efficiently. By tracking the active pages over a specified period, it helps optimize memory utilization and stabilize system performance, reducing the likelihood of thrashing caused by frequent, excessive page swapping .
Banker's Algorithm is effective for deadlock avoidance as it simulates resource allocation requests and ensures a safe state by only approving operations that do not lead to deadlock. It offers a systematic approach to handle resource requests, providing flexibility and control. However, its implementation complexity increases with system size due to the need for constant recalculation of resource availability and process state assessments. It requires precise resource need estimations, which may not always be feasible, and introduces computational overhead, making it less suited for real-time systems .