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 virtual memory, and how does paging work?

    Virtual memory gives every process its own private address space that looks large and continuous, while the OS maps it onto real RAM in fixed-size blocks called pages (often 4 KB). A page table translates each virtual page to a physical frame, and pages not in RAM can be kept on disk and loaded on demand through a page fault.

    IntermediateIn-depth4 min read
  2. A system has 32-bit logical addresses and 4 KB pages. How many bits are the page number and offset, and how large is the page table?

    4 KB = 2^12, so the offset is 12 bits and the page number is 32 - 12 = 20 bits. That gives 2^20 entries; at 4 bytes each, the page table is 4 MB per process.

    IntermediateQuick answer1 min read
  3. If a TLB lookup takes 10 ns, memory access 100 ns and the hit ratio is 90%, what is the effective access time?

    EAT = 0.9 x (10 + 100) + 0.1 x (10 + 100 + 100) = 99 + 21 = 120 ns. A TLB hit needs one memory access; a miss needs two, one for the page table and one for the data.

    IntermediateQuick answer1 min read
  4. What does a page table entry contain besides the frame number?

    Besides the frame number, an entry holds control bits: valid/present, read/write/execute permissions, a user/supervisor bit, a dirty (modified) bit and an accessed (reference) bit.

    IntermediateQuick answer2 min read
  5. Why do operating systems use multi-level page tables?

    A single flat page table needs an entry for every possible page, even unused ones. A multi-level table splits it into pieces and only allocates the pieces for regions actually in use, saving a large amount of memory.

    IntermediateQuick answer1 min read