Operating Systems
Difficulty Level: 1 — Recognition (MCQ, Matching, True/False with justification) Time Limit: 20 minutes Total Marks: 30
Section A — Multiple Choice (1 mark each) — 12 marks
Choose the single best answer.
Q1. When a user program executes a system call, the CPU transitions from:
- (a) kernel mode to user mode
- (b) user mode to kernel mode via a trap
- (c) user mode to kernel mode via an interrupt from a device
- (d) kernel mode to kernel mode
Q2. Which of the following is NOT saved during a context switch?
- (a) Program counter
- (b) CPU registers
- (c) The contents of the hard disk
- (d) Stack pointer
Q3. A fork() call in a parent process returns:
- (a) 0 to both parent and child
- (b) the child's PID to the parent and 0 to the child
- (c) 0 to the parent and the child's PID to the child
- (d) −1 to both on success
Q4. In the Coffman conditions for deadlock, which is NOT one of the four?
- (a) Mutual exclusion
- (b) Hold and wait
- (c) Preemption
- (d) Circular wait
Q5. For processes with burst times, which scheduling algorithm gives the provably minimum average waiting time (non-preemptive)?
- (a) FCFS
- (b) Round Robin
- (c) SJF
- (d) Priority (non-preemptive)
Q6. Internal fragmentation occurs primarily in:
- (a) contiguous allocation with variable partitions
- (b) fixed-size partitioning / paging
- (c) linked file allocation
- (d) segmentation only
Q7. RAID level that provides striping with no redundancy:
- (a) RAID 0
- (b) RAID 1
- (c) RAID 5
- (d) RAID 6
Q8. A test-and-set instruction is useful for building a mutex because it:
- (a) disables all interrupts permanently
- (b) atomically reads and sets a memory word in one indivisible step
- (c) is faster than any load instruction
- (d) never causes busy waiting
Q9. The main difference between a container and a virtual machine is that a container:
- (a) runs its own full guest kernel
- (b) shares the host OS kernel using namespaces and cgroups
- (c) requires a type-1 hypervisor
- (d) cannot isolate processes
Q10. A page fault occurs when:
- (a) the page table is full
- (b) a referenced page is valid and present in a frame
- (c) a referenced page is not currently in physical memory
- (d) the CPU is in user mode
Q11. In C-SCAN disk scheduling, after reaching the end of the disk the head:
- (a) reverses direction servicing requests
- (b) jumps back to the beginning and continues in the same direction
- (c) stops
- (d) services the nearest request regardless of direction
Q12. Journaling in a file system primarily improves:
- (a) read throughput
- (b) crash consistency / recovery
- (c) internal fragmentation
- (d) CPU utilization
Section B — Matching (1 mark each) — 8 marks
Q13. Match each item in Column X to the correct description in Column Y.
| Column X | Column Y |
|---|---|
| 1. Microkernel | A. Table mapping virtual pages to physical frames |
| 2. PCB | B. Minimal kernel; services run in user space |
| 3. Page table | C. Multiple hard links point to one file's data |
| 4. Inode | D. Stores per-process state, registers, PID |
| 5. Copy-on-write | E. Structure holding file metadata + block pointers |
| 6. Hard link | F. Parent and child share pages until one writes |
7. Semaphore P() |
G. Distributes threads across CPUs |
| 8. Load balancing | H. Decrement/wait operation |
Write answers as 1→_, 2→_, …
Section C — True/False WITH Justification (2 marks each) — 10 marks
1 mark for correct T/F, 1 mark for a correct justification. No justification = max 1 mark.
Q14. "Round Robin scheduling with a very large time quantum behaves like FCFS."
Q15. "The Banker's algorithm is a deadlock detection technique used after deadlock has occurred."
Q16. "A user-level threading library that maps many threads to one kernel thread can run those threads truly in parallel on a multicore CPU."
Q17. "Best-fit memory allocation always eliminates external fragmentation."
Q18. "In demand paging, a valid–invalid bit in the page table is used to detect that a page is not in memory."
Answer keyMark scheme & solutions
Section A (1 mark each)
Q1 — (b). A system call issues a software trap that switches the CPU into kernel mode so privileged code can run. (Not (c): a device interrupt is asynchronous, unrelated to a program's syscall.)
Q2 — (c). Context switch saves the volatile CPU state (PC, registers, stack pointer) into the PCB. Disk contents are persistent storage, not part of CPU context.
Q3 — (b). fork() returns the child's PID to the parent and 0 to the child, letting each branch identify itself.
Q4 — (c). The four Coffman conditions are mutual exclusion, hold-and-wait, no preemption, and circular wait. "Preemption" is the opposite of the actual condition.
Q5 — (c). Shortest Job First minimizes average waiting time among non-preemptive schedules (classic optimality result).
Q6 — (b). Fixed-size blocks/pages waste space inside the last allocated block ⇒ internal fragmentation. Variable partitions cause external fragmentation.
Q7 — (a). RAID 0 stripes for performance/capacity with zero redundancy.
Q8 — (b). Test-and-set is atomic: it reads the old value and writes 1 indivisibly, so only one thread sees the "was 0" result and enters the critical section.
Q9 — (b). Containers share the host kernel, isolating via namespaces (visibility) and cgroups (resource limits); VMs run full guest kernels on a hypervisor.
Q10 — (c). A page fault = referenced page absent from physical memory; the OS then fetches it (demand paging).
Q11 — (b). C-SCAN sweeps one direction, jumps to the start, and repeats — giving more uniform wait times than SCAN.
Q12 — (b). The journal records intended changes first, so after a crash the FS replays/rolls back to a consistent state.
Section B (1 mark each)
Q13: 1→B, 2→D, 3→A, 4→E, 5→F, 6→C, 7→H, 8→G
- Microkernel = minimal kernel, services in user space (B)
- PCB = per-process state/registers/PID (D)
- Page table = virtual page → frame map (A)
- Inode = file metadata + block pointers (E)
- Copy-on-write = shared pages until a write (F)
- Hard link = multiple names → same data (C)
P()= wait/decrement (H)- Load balancing = spread threads across CPUs (G)
Section C (2 marks each: 1 T/F + 1 justification)
Q14 — TRUE. With a quantum larger than every burst, no process is ever preempted, so each runs to completion in arrival order — identical to FCFS.
Q15 — FALSE. Banker's algorithm is a deadlock avoidance method: it checks whether granting a request leaves the system in a safe state before deadlock occurs; detection is a separate technique.
Q16 — FALSE. Many-to-one mapping means the kernel schedules only one kernel thread, so at most one user thread runs at a time — no true parallelism on multicore.
Q17 — FALSE. Best-fit chooses the smallest adequate hole to reduce waste, but leftover holes still accumulate; external fragmentation remains (and best-fit tends to leave many tiny unusable holes). Compaction is needed to eliminate it.
Q18 — TRUE. Each page-table entry has a valid–invalid (present) bit; a reference to an invalid-marked page triggers a trap so the OS handles the page fault.
[
{"claim": "SJF minimizes avg waiting time: for bursts 6,8,7,3 SJF order 3,6,7,8 gives lower avg wait than FCFS order 6,8,7,3",
"code": "bursts_fcfs=[6,8,7,3]\n\ndef avg_wait(order):\n t=0; total=0\n for b in order:\n total+=t\n t+=b\n return total/len(order)\nfcfs=avg_wait([6,8,7,3])\nsjf=avg_wait(sorted([6,8,7,3]))\nresult = (sjf < fcfs) and (abs(sjf-7)<1e-9)"},
{"claim": "RAID 0 usable capacity fraction with n disks equals 1 (no redundancy), RAID 1 mirror equals 1/2",
"code": "raid0=1\nraid1=Rational(1,2)\nresult = (raid0==1) and (raid1==Rational(1,2))"},
{"claim": "Coffman conditions count is exactly 4",
"code": "conds={'mutual_exclusion','hold_and_wait','no_preemption','circular_wait'}\nresult = len(conds)==4"},
{"claim": "test-and-set returns old value; sequence of two calls on lock starting 0 yields (0 then 1)",
"code": "lock=[0]\n\ndef tas():\n old=lock[0]; lock[0]=1; return old\nr1=tas(); r2=tas()\nresult = (r1==0) and (r2==1)"}
]