Interview Q&A / Operating Systems

INTERVIEW Q&A · 42 QUESTIONS

Operating Systems interview questions

Processes, threads, scheduling, memory and deadlocks, in plain words.

  1. A system has 4 KB pages. Translate logical address 20000 if page 4 is stored in frame 9.

    20000 = 4 x 4096 + 3616, so page number 4 and offset 3616. Frame 9 starts at 9 x 4096 = 36864, so the physical address is 36864 + 3616 = 40480.

    BeginnerQuick answer1 min read
  2. For burst times 24, 3 and 3 (all arriving at time 0), what is the average waiting time under non-preemptive SJF?

    SJF runs the shortest burst first: P2, P3, then P1. Waiting times are P2 0, P3 3, P1 6, so the average is (0 + 3 + 6) / 3 = 3 ms, which is the minimum possible.

    BeginnerQuick answer1 min read
  3. Three processes with burst times 24, 3 and 3 arrive together. What is the average waiting time under FCFS?

    Run in arrival order P1, P2, P3. Waiting times are 0, 24 and 27, so the average is (0 + 24 + 27) / 3 = 17 ms. Waiting time is the time a process spends in the ready queue before it gets the CPU.

    BeginnerQuick answer1 min read
  4. What are the states of a process in its life cycle?

    A process moves through new, ready, running, waiting (blocked) and terminated. The scheduler moves it between ready and running; I/O or events move it between running and waiting.

    BeginnerQuick answer1 min read
  5. What do threads of the same process share, and what does each thread keep private?

    Threads in one process share code, global data, the heap and open files. Each thread has its own stack, program counter, registers and thread ID.

    BeginnerQuick answer1 min read
  6. What does fork() return, and how does a program use that value?

    fork() creates a copy of the calling process. It returns 0 in the child, the child's PID in the parent, and -1 if creation failed. Programs branch on that value to run different code in each.

    BeginnerQuick answer1 min read
  7. What is a counting semaphore and when would you use one?

    A counting semaphore holds a non-negative integer that tracks how many units of a resource are free. wait() takes one unit (blocking at zero) and signal() returns one. It limits how many threads use a pool at once.

    BeginnerQuick answer1 min read
  8. What is a Process Control Block (PCB) and what does it store?

    A PCB is the kernel data structure holding everything the OS needs to manage one process: its ID, state, saved registers, program counter, memory information, open files and scheduling data.

    BeginnerQuick answer1 min read
  9. What is the difference between a logical address and a physical address?

    A logical (virtual) address is what the program generates; a physical address is the real location in RAM. The Memory Management Unit translates one into the other at run time.

    BeginnerQuick answer1 min read
  10. What is the difference between a zombie process and an orphan process?

    A zombie has finished running but still has an entry in the process table because its parent has not collected its exit status. An orphan is still running but its parent has died; init adopts it.

    BeginnerQuick answer1 min read
  11. What is the difference between paging and segmentation?

    Paging divides memory into fixed-size pages invisible to the programmer; segmentation divides it into variable-size logical units like code, stack and heap. Paging causes internal fragmentation, segmentation causes external.

    BeginnerQuick answer1 min read
  12. What is the difference between turnaround time, waiting time and response time?

    Turnaround time is completion minus arrival. Waiting time is turnaround minus burst, the total time spent in the ready queue. Response time is the time from arrival to the first time the process gets the CPU.

    BeginnerQuick answer1 min read