AMCAT Operating Systems Fundamentals 2 — Questions and Answers
Question 1: Which page replacement algorithm is known as the optimal algorithm but is impractical for real-time use?
- First In First Out (FIFO)
- Least Recently Used (LRU)
- Optimal Page Replacement (OPT/Belady's) (Correct answer)
- Clock Algorithm
Correct answer: Optimal Page Replacement (OPT/Belady's)
The Optimal Page Replacement algorithm (also known as Belady's algorithm) replaces the page that will not be used for the longest time in the future. While it produces the minimum number of page faults, it requires future knowledge of memory references, making it impractical for real systems. It is used as a benchmark to evaluate other algorithms.
Question 2: What is the main advantage of a multilevel feedback queue scheduling algorithm?
- It uses only one queue, making it simple to implement
- It can adapt to the behavior of processes by moving them between queues of different priorities (Correct answer)
- It guarantees that all processes finish in the same amount of time
- It eliminates the need for context switching
Correct answer: It can adapt to the behavior of processes by moving them between queues of different priorities
A multilevel feedback queue scheduler dynamically adjusts process priorities based on their behavior. CPU-bound processes that use their full time quantum are moved to lower-priority queues, while I/O-bound processes that release the CPU early stay in higher-priority queues. This adaptability makes it versatile.
Question 3: In a system using demand paging, when is a page loaded into memory?
- When the process is first created
- When all pages of the process are needed
- Only when the page is actually accessed and causes a page fault (Correct answer)
- At regular time intervals determined by the scheduler
Correct answer: Only when the page is actually accessed and causes a page fault
Demand paging is a lazy loading strategy where pages are loaded into physical memory only when they are actually needed (demanded) by the process. When a process accesses a page not in memory, a page fault occurs, and the OS loads that specific page from disk.
Question 4: What is the Banker's Algorithm used for in operating systems?
- Memory allocation and defragmentation
- CPU scheduling and time-sharing
- Deadlock avoidance by determining if resource allocation will leave the system in a safe state (Correct answer)
- File system management and disk scheduling
Correct answer: Deadlock avoidance by determining if resource allocation will leave the system in a safe state
The Banker's Algorithm, proposed by Dijkstra, is a deadlock avoidance strategy. Before granting a resource request, it simulates the allocation to check if the system would remain in a 'safe state' — meaning all processes can still complete. If the allocation would lead to an unsafe state, the request is denied.
Question 5: Which of the following best describes thrashing in an operating system?
- A process running at maximum CPU utilization
- The system spending most of its time swapping pages in and out of memory rather than executing processes (Correct answer)
- A deadlock between multiple processes
- Excessive use of CPU cache
Correct answer: The system spending most of its time swapping pages in and out of memory rather than executing processes
Thrashing occurs when the system is overcommitted on memory, causing processes to continuously generate page faults. The OS spends almost all its time swapping pages between RAM and disk, and very little time doing actual useful computation. CPU utilization drops drastically during thrashing.
Question 6: What is the difference between preemptive and non-preemptive scheduling?
- Preemptive scheduling does not use a timer; non-preemptive scheduling does
- In preemptive scheduling, a running process can be interrupted and moved to ready state; in non-preemptive, a process runs until it voluntarily yields or completes (Correct answer)
- Non-preemptive scheduling is always faster than preemptive scheduling
- Preemptive scheduling only works with single-core processors
Correct answer: In preemptive scheduling, a running process can be interrupted and moved to ready state; in non-preemptive, a process runs until it voluntarily yields or completes
In preemptive scheduling, the OS can forcibly interrupt a running process (e.g., when a higher-priority process arrives or a time quantum expires) and place it back in the ready queue. In non-preemptive scheduling, a process keeps the CPU until it terminates or voluntarily enters a waiting state.
Which page replacement algorithm is known as the optimal algorithm but is impractical for real-time use?