BSCS Bachelor of Science in Computer Science: Operating Systems Concepts 5 — Questions and Answers
Question 1: What is thrashing in a virtual memory system?
- Excessive CPU usage caused by too many runnable processes
- A state where processes spend more time paging than executing (Correct answer)
- Disk fragmentation that slows I/O operations
- A condition where the TLB hit rate drops below 50%
Correct answer: A state where processes spend more time paging than executing
Thrashing occurs when processes collectively demand more frames than are available, causing constant page faults and nearly all CPU time spent on paging.
Question 2: Which file allocation method provides the fastest direct (random) access but suffers from external fragmentation?
- Linked allocation
- Indexed allocation
- Contiguous allocation (Correct answer)
- FAT-based allocation
Correct answer: Contiguous allocation
Contiguous allocation stores all blocks of a file adjacently, enabling O(1) random access, but free space becomes fragmented over time as files are created and deleted.
Question 3: In the context of CPU scheduling, what does the term 'convoy effect' describe?
- High-priority processes blocking all low-priority ones indefinitely
- Short processes queuing behind one long CPU-bound process in FCFS, increasing average wait time (Correct answer)
- Multiple threads competing for the same lock simultaneously
- A cache miss that causes a cascade of page faults
Correct answer: Short processes queuing behind one long CPU-bound process in FCFS, increasing average wait time
The convoy effect in FCFS scheduling happens when many short processes wait behind a single long-running process, leading to poor average waiting time.
Question 4: Which synchronization construct allows multiple readers to access a shared resource concurrently but gives exclusive access to writers?
- Counting semaphore
- Readers-writers lock (Correct answer)
- Spinlock
- Condition variable
Correct answer: Readers-writers lock
A readers-writers lock (rwlock) permits concurrent reads for performance while ensuring that a writer has exclusive access with no concurrent readers or other writers.
Question 5: What is the purpose of the 'nice' value in Unix/Linux process scheduling?
- It sets the hard real-time priority of a process
- It adjusts the scheduling priority, with higher nice values yielding lower priority (Correct answer)
- It limits the CPU time a process can consume per second
- It determines which CPU core the process is pinned to
Correct answer: It adjusts the scheduling priority, with higher nice values yielding lower priority
The nice value ranges from -20 (highest priority) to +19 (lowest priority); a process with a higher nice value is more 'generous,' yielding CPU time to others.
Question 6: In a system with demand paging, what happens when a process references a page that is not currently in physical memory?
- The OS terminates the process with a segmentation fault
- A page fault exception is raised and the OS loads the page from backing store (Correct answer)
- The reference is silently ignored
- The MMU remaps the address to an available page without OS intervention
Correct answer: A page fault exception is raised and the OS loads the page from backing store
A page fault trap transfers control to the OS page-fault handler, which locates the page on disk, loads it into a free frame, updates the page table, and resumes the process.
Question 7: What is the key difference between a process and a thread?
- Threads have their own separate address space; processes share one
- Threads within a process share the same address space, while processes have separate address spaces (Correct answer)
- Processes are scheduled by the CPU; threads are not
- Threads cannot perform I/O operations directly
Correct answer: Threads within a process share the same address space, while processes have separate address spaces
Threads (lightweight processes) within the same process share code, data, heap, and open files, while separate processes each have their own private virtual address space.
What is thrashing in a virtual memory system?