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. 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
  3. 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
  4. 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
  5. 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
  6. Given a segment table, how do you translate the logical address (1, 500)?

    Look up segment 1, compare the offset with its limit, and add the offset to its base. If the offset is not below the limit the hardware traps. With limit 400 here, (1, 500) is invalid; (0, 500) maps to 1900.

    IntermediateQuick answer1 min read
  7. 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
  8. 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