Skip to content
dronacharya.ai

Operating systems interview questionswith answers and explanations

23 original operating systems questions of the kind asked in technical MCQ rounds and interviews, each with the answer and a short explanation. To answer them yourself first, open the CS fundamentals practice.

questions
23
easy
12
medium
8
hard
3
  1. Question 1

    Easy

    Which CPU scheduling algorithm can starve long processes when short jobs keep arriving?

    1. AFirst come, first served
    2. BRound robin
    3. CShortest job firstAnswer
    4. DMultilevel queue with ageing

    Explanation

    Shortest job first always picks the shortest waiting job, so a long job can wait forever if short jobs keep arriving. Ageing exists to prevent exactly this.

  2. Question 2

    Easy

    Which of these is NOT one of the four necessary conditions for deadlock?

    1. AMutual exclusion
    2. BHold and wait
    3. CPreemptionAnswer
    4. DCircular wait

    Explanation

    The four conditions are mutual exclusion, hold and wait, no preemption and circular wait. Preemption itself breaks deadlock.

  3. Question 3

    Easy

    Thrashing happens when:

    1. Athe CPU is fully busy with computation
    2. Bthe system spends most of its time moving pages in and out of memoryAnswer
    3. Ctwo processes share the same memory segment
    4. Dcache hits are too frequent

    Explanation

    With too little memory for the working sets, processes page-fault constantly and the system does almost no useful work.

  4. Question 4

    Easy

    Which of these is NOT shared by the threads of one process?

    1. AThe stackAnswer
    2. BHeap memory
    3. CGlobal variables
    4. DOpen files

    Explanation

    Each thread has its own stack, registers and program counter. The heap, global data and open file descriptors belong to the process and are shared by all its threads.

  5. Question 5

    Easy

    What is a context switch?

    1. ASaving the state of the running process and loading the saved state of anotherAnswer
    2. BMoving a page from disk into memory
    3. CSwitching from user mode to kernel mode for a system call
    4. DCompiling a program into machine code

    Explanation

    On a context switch the OS saves the CPU state (registers, program counter and so on) of the current process in its PCB and restores another's. A system call alone changes the mode, not the process.

  6. Question 6

    Easy

    Which page replacement algorithm can suffer from Belady's anomaly, where adding frames increases page faults?

    1. AFIFOAnswer
    2. BLRU
    3. COptimal
    4. DNone of these

    Explanation

    FIFO can fault more with more frames. LRU and Optimal are stack algorithms: the pages held with n frames are always a subset of those held with n + 1, so they cannot show the anomaly.

  7. Question 7

    Medium

    Processes P1, P2 and P3 arrive at time 0, in that order, with CPU bursts of 5, 3 and 1 ms. Under round robin with a time quantum of 2 ms, when does P1 finish?

    1. A8 ms
    2. B7 ms
    3. C5 ms
    4. D9 msAnswer

    Explanation

    P1 runs 0 to 2, P2 2 to 4, P3 4 to 5 (done), P1 5 to 7, P2 7 to 8 (done), and P1 8 to 9. P1 finishes at 9 ms.

  8. Question 8

    Medium

    A counting semaphore S starts at 3. These operations run in order: P, P, V, P, P, V, P (P is wait, V is signal). What is the value of S at the end?

    1. A0Answer
    2. B1
    3. C2
    4. D−1

    Explanation

    Each P subtracts 1 and each V adds 1: 3 → 2 → 1 → 2 → 1 → 0 → 1 → 0. The value never needed to go below 0, so no process blocked, and S ends at 0.

  9. Question 9

    Medium

    How does the Banker's algorithm deal with deadlock?

    1. AIt lets deadlocks happen and then kills processes to break them
    2. BIt grants a request only if the system stays in a safe state afterwardsAnswer
    3. CIt forbids a process from holding one resource while waiting for another
    4. DIt runs the process with the shortest burst first

    Explanation

    The Banker's algorithm is deadlock avoidance: before granting a request it checks that some order still exists in which every process can finish (a safe state). Detection and recovery, and breaking hold and wait, are different strategies.

  10. Question 10

    Medium

    A system uses 32-bit logical addresses and 4 KB pages. How many entries does a single-level page table for one process have?

    1. A2²⁰Answer
    2. B2¹²
    3. C2³²
    4. D2²²

    Explanation

    A 4 KB page needs 12 offset bits (2¹² = 4096). The remaining 32 − 12 = 20 bits give the page number, so there are 2²⁰ pages and 2²⁰ entries.

  11. Question 11

    Easy

    What does the TLB (translation lookaside buffer) store?

    1. ARecently used disk blocks
    2. BInstructions fetched from memory
    3. CProcess control blocks
    4. DRecently used page-to-frame translationsAnswer

    Explanation

    The TLB is a small, fast cache of page table entries. On a TLB hit the CPU gets the frame number without walking the page table in memory.

  12. Question 12

    Easy

    A child process has finished, but its parent has not yet called wait() to collect its exit status. What is the child called?

    1. AA zombie processAnswer
    2. BAn orphan process
    3. CA daemon
    4. DAn idle process

    Explanation

    A finished child whose entry stays in the process table until the parent reads its exit status is a zombie. An orphan is a running child whose parent has already exited.

  13. Question 13

    Easy

    Which of these CPU scheduling algorithms is non-preemptive?

    1. ARound robin
    2. BFirst come, first servedAnswer
    3. CShortest remaining time first
    4. DPreemptive priority scheduling

    Explanation

    Under FCFS a process keeps the CPU until it finishes or blocks. Round robin preempts on a timer, and SRTF and preemptive priority preempt when a better process arrives.

  14. Question 14

    Easy

    When does internal fragmentation happen?

    1. AWhen free memory is split into many small holes that are not next to each other
    2. BWhen two processes map the same page
    3. CWhen a fixed-size block given to a process is bigger than it needs, wasting the space left inside the blockAnswer
    4. DWhen the page table is larger than one page

    Explanation

    Internal fragmentation is wasted space inside an allocated block, as with the unused end of a process's last page. Scattered free holes between allocations are external fragmentation.

  15. Question 15

    Medium

    Which of these is NOT a requirement for a correct solution to the critical-section problem?

    1. AMutual exclusion
    2. BProgress
    3. CBounded waiting
    4. DAll processes must have the same priorityAnswer

    Explanation

    A correct solution needs mutual exclusion (one process inside at a time), progress (a free section is not held up) and bounded waiting (no process waits forever). Priorities are not part of it.

  16. Question 16

    Medium

    P1, P2 and P3 all arrive at time 0 with CPU bursts of 8, 4 and 2 ms. What is the average waiting time under non-preemptive shortest job first?

    1. A6.67 ms
    2. B2.67 msAnswer
    3. C4.67 ms
    4. D3.33 ms

    Explanation

    SJF runs P3 (0 to 2), then P2 (2 to 6), then P1 (6 to 14). The waits are 0, 2 and 6 ms, so the average is 8/3 ≈ 2.67 ms. FCFS in arrival order would average 6.67 ms.

  17. Question 17

    Easy

    Which Unix system call creates a new process?

    1. Aexec()
    2. Bwait()
    3. Cfork()Answer
    4. Dexit()

    Explanation

    fork() creates a child that is a copy of the caller. exec() replaces the current process's program with a new one, without creating a process.

  18. Question 18

    Hard

    Assuming every fork() succeeds, how many processes exist in total, including the original, after this C code runs?

    if (fork() == 0) {
        fork();
    }
    1. A4
    2. B3Answer
    3. C2
    4. D8

    Explanation

    The first fork() makes one child. In the parent it returns the child's id, so the parent skips the block. In the child it returns 0, so the child forks once more. Original, child and grandchild: 3 processes.

  19. Question 19

    Easy

    What does virtual memory allow?

    1. ARAM to run faster than its rated speed
    2. BA process to use an address space larger than physical RAM, with parts kept on diskAnswer
    3. CPrograms to run without any page table
    4. DThe CPU cache to replace main memory

    Explanation

    Virtual memory gives each process its own address space and keeps only the pages in use in RAM, bringing others in from disk on a page fault.

  20. Question 20

    Hard

    With 3 page frames, initially empty, and LRU page replacement, how many page faults does this reference string cause? 5, 2, 7, 5, 3, 5, 6, 2, 5, 7

    1. A8
    2. B6
    3. C7Answer
    4. D5

    Explanation

    Faults on 5, 2, 7 (frames fill). 5 hits. 3 replaces 2 (least recently used). 5 hits. 6 replaces 7. 2 replaces 3. 5 hits. 7 replaces 6. That is 7 faults. (FIFO would give 8 and the optimal policy 6.)

  21. Question 21

    Medium

    Under round robin scheduling, a running process moves to the ready state when:

    1. Ait requests disk I/O
    2. Bit finishes executing
    3. Cit waits for a child process
    4. Dits time quantum runs outAnswer

    Explanation

    A timer interrupt at the end of the quantum preempts the process and puts it back in the ready queue. Requesting I/O or waiting for a child moves it to the waiting (blocked) state instead.

  22. Question 22

    Medium

    Which statement about mutexes and semaphores is true?

    1. AA semaphore can only take the values 0 and 1
    2. BA mutex lets any number of threads into the critical section
    3. CA mutex is released by the thread that locked it, while a counting semaphore can let several threads in at onceAnswer
    4. DSemaphores work only between threads of the same process

    Explanation

    A mutex has an owner and admits one thread at a time. A counting semaphore holds a count and admits up to that many, which suits a pool of identical resources. Only a binary semaphore is limited to 0 and 1.

  23. Question 23

    Hard

    A disk head is at cylinder 100. The queue holds requests for cylinders 45, 130, 10, 160, 90 and 115. Using shortest seek time first (SSTF), what is the total head movement?

    1. A505 cylinders
    2. B240 cylinders
    3. C230 cylindersAnswer
    4. D210 cylinders

    Explanation

    SSTF always goes to the nearest pending request: 100 → 90 (10) → 115 (25) → 130 (15) → 160 (30) → 45 (115) → 10 (35). Total = 230 cylinders. Serving in queue order (FCFS) would take 505.

companies
222
rounds described
1,432
pieces of advice
3,771

Your next drive is closer than you think.

Start with the 15-minute mixed test: 13 questions that show where you stand in every section.