Interview Q&A / Operating Systems

INTERVIEW Q&A · 42 QUESTIONS

Operating Systems interview questions

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

  1. What is a deadlock and how can you prevent it?

    A deadlock is when two or more processes wait for each other forever, each holding something the other needs. It needs four conditions together; breaking any one of them, for example always taking locks in the same order, prevents it.

    IntermediateIn-depth2 min read
  2. How can you detect a deadlock using a resource allocation graph?

    Draw processes and resources as nodes, with request and assignment edges. A cycle means deadlock if every resource has a single instance; with multiple instances a cycle is necessary but not enough.

    IntermediateQuick answer1 min read
  3. What is livelock, and how is it different from deadlock?

    In deadlock, processes are blocked and make no progress. In livelock they keep running and changing state in response to each other, but still make no progress, like two people repeatedly stepping aside in a corridor.

    IntermediateQuick answer1 min read
  4. What is the dining philosophers problem and how can it be solved?

    Five philosophers sit round a table with five forks, and each needs two adjacent forks to eat. If all pick up their left fork together, everyone waits forever. Solutions include a fork ordering, a limit of four seated, or an asymmetric pickup.

    IntermediateQuick answer1 min read