
This third set of Operating System MCQs covers process synchronisation, file systems and disk scheduling. It is useful for GATE preparation, university exams and OS rounds in placement interviews, with step-by-step working for the semaphore, inode and seek-distance numericals.
How to practise: read each question and tap the option you think is correct. You will see right away whether you got it, along with a short explanation, and your score is tracked at the bottom of the screen. This set has 18 questions.
Topics covered in this set
- Critical section requirements and Peterson's solution
- Semaphores, mutex locks and monitors
- Producer-consumer, readers-writers and dining philosophers
- File allocation methods, directories and inodes
- Disk scheduling: FCFS, SSTF, SCAN, C-SCAN and LOOK
- RAID levels
Operating system MCQs with answers and explanations
Q1. Which of the following is NOT one of the three requirements for a correct solution to the critical section problem?
a) Mutual exclusion
b) Progress
c) Bounded waiting
d) All processes must run at the same relative speed
Q2. In Peterson's solution shown below, when can process Pi enter its critical section?
flag[i] = true;
turn = j;
while (flag[j] && turn == j)
; // busy wait
// critical section
flag[i] = false;
a) Only when flag[i] is false
b) When flag[j] is false or turn equals i
c) Only when both flag[i] and flag[j] are true
d) Only when turn equals j
Q3. What is the key difference between a mutex lock and a binary semaphore?
a) A mutex has an owner, so only the thread that locked it should unlock it
b) A binary semaphore can take any non-negative integer value
c) A mutex can be used only between processes on different machines
d) A binary semaphore never causes busy waiting or blocking
Q4. In a monitor, what happens when a process calls x.signal() on a condition variable x and no process is waiting on x?
a) The signal is stored and the next x.wait() returns immediately
b) The calling process is blocked
c) The signal has no effect
d) The monitor raises a deadlock error
Q5. In the bounded-buffer producer-consumer solution with a buffer of n slots, what are the initial values of the semaphores mutex, empty and full?
a) mutex = 0, empty = 0, full = n
b) mutex = 1, empty = n, full = 0
c) mutex = 1, empty = 0, full = n
d) mutex = n, empty = 1, full = 0
Q6. In the first readers-writers problem, where readers are given preference, which processes can starve?
a) Writers
b) Readers
c) Both readers and writers equally
d) Neither, because semaphores prevent starvation
Q7. Five philosophers each pick up their left fork and then their right fork, with one semaphore per fork. Which change guarantees that deadlock cannot occur?
a) Make every philosopher think for a longer time
b) Make every philosopher pick up the left fork first, as before, but faster
c) Replace the fork semaphores with counting semaphores initialised to 2
d) Allow at most four philosophers to sit at the table at the same time
Q8. Which file allocation method does not support efficient direct (random) access to the k-th block of a file?
a) Contiguous allocation
b) Indexed allocation
c) Linked allocation without a FAT
d) Contiguous allocation with extents
Q9. Which directory structure allows a file or subdirectory to be shared through links while ruling out cycles?
a) Acyclic-graph directory
b) Single-level directory
c) Two-level directory
d) Tree-structured directory without links
Q10. A counting semaphore S is initialised to 7. Then 20 wait (P) operations and 15 signal (V) operations are performed on it. What is the final value of S?
a) 12
b) 2
c) -2
d) 0
Q11. Using the blocking semaphore implementation, where wait() decrements first and blocks if the value is negative, a semaphore S starts at 3 and five processes call wait(S) with no signal in between. What is the final state?
a) S = 0 and no process is blocked
b) S = -5 and 5 processes are blocked
c) S = -2 and 2 processes are blocked
d) S = 3 and 2 processes are blocked
Q12. In the bounded-buffer problem, a programmer changes the producer to call wait(mutex) before wait(empty). What can happen when the buffer is full?
a) Nothing changes, because the order of wait calls never matters
b) The consumer will read the same item twice
c) The buffer will overflow
d) Deadlock: the producer holds mutex and blocks on empty, so the consumer can never enter to free a slot
Q13. A Unix-style inode has 12 direct block pointers and 1 single indirect pointer. The block size is 4 KB and each block pointer is 4 bytes. Using only these pointers, what is the largest file size possible?
a) 4144 KB
b) 4096 KB
c) 1072 KB
d) 48 KB
Q14. The disk head is at cylinder 60. The request queue, in arrival order, is shown below. What is the total head movement with FCFS scheduling?
25, 90, 10, 140, 75, 30
a) 210 cylinders
b) 420 cylinders
c) 380 cylinders
d) 328 cylinders
Q15. For the same queue with the head at cylinder 60, what is the total head movement with SSTF scheduling?
25, 90, 10, 140, 75, 30
a) 420 cylinders
b) 250 cylinders
c) 210 cylinders
d) 180 cylinders
Q16. The disk has cylinders 0 to 199. With the head at 60 moving towards higher cylinders, what is the total head movement with SCAN (the head goes to the last cylinder before reversing)?
25, 90, 10, 140, 75, 30
a) 210 cylinders
b) 270 cylinders
c) 368 cylinders
d) 328 cylinders
Q17. Same disk (cylinders 0 to 199), head at 60 moving towards higher cylinders. With C-SCAN, counting the return movement from 199 back to 0, what is the total head movement?
25, 90, 10, 140, 75, 30
a) 368 cylinders
b) 328 cylinders
c) 169 cylinders
d) 199 cylinders
Q18. A RAID 5 array is built from five 2 TB disks. What is its usable capacity and fault tolerance?
a) 10 TB, with no tolerance for disk failure
b) 5 TB, tolerating up to four disk failures
c) 8 TB, tolerating the failure of any one disk
d) 6 TB, tolerating any two disk failures
Quick revision notes
- Critical section solution needs mutual exclusion, progress and bounded waiting, with no speed assumptions.
- Peterson's solution uses flag[] and turn and works for two processes.
- Counting semaphore final value = initial - number of P + number of V; a negative value's magnitude = blocked processes.
- Bounded buffer: mutex = 1, empty = n, full = 0; always wait(empty/full) before wait(mutex).
- Contiguous allocation gives fast direct access but external fragmentation; linked has no direct access; indexed uses an index block.
- Inode max size = (direct + pointers per block + pointers per block^2 + ...) x block size.
- SSTF can starve far requests; SCAN goes to the disk end, LOOK reverses at the last request, C-SCAN serves in one direction only.
- RAID 0 = striping, no redundancy; RAID 1 = mirroring; RAID 5 = distributed parity, survives one disk failure.
Frequently asked questions
What is the difference between a semaphore and a monitor?
A semaphore is a low-level integer variable with wait and signal operations, and the programmer must place them correctly, so mistakes cause deadlocks or race conditions. A monitor is a higher-level construct that automatically allows only one process inside at a time and uses condition variables for waiting, which makes correct synchronisation easier.
Why is SSTF not always the best disk scheduling algorithm?
SSTF reduces average seek time by always serving the nearest request, but requests far from the head can wait indefinitely if new nearby requests keep arriving. SCAN, C-SCAN and LOOK give more uniform waiting times, which is why variants of them are preferred under heavy load.
Which RAID level should be used for a database server?
It depends on the balance of performance, capacity and safety. RAID 10 (mirroring plus striping) is popular for write-heavy databases because it is fast and survives disk failures, while RAID 5 or RAID 6 gives more usable capacity but slower writes due to parity calculation.
Comments
Post a Comment