OS & Hardware

Learn the boundary between operating systems and hardware with multiple-choice questions: interrupts and exceptions, privilege modes and system calls, page tables and page faults, context switches and virtualization.

—Your accuracy
0 / 50Questions answered
Practice this topicAll questions in this topic, in random order Weak questionsRetry only the questions you last got wrong

OS & Hardware: key points

An operating system (OS) is software that lets many programs share hardware such as CPUs, memory and I/O devices safely. To support it, CPUs provide privileged modes usable only by the OS, interrupt and exception mechanisms, and hardware that walks page tables for virtual memory.

Applications ask the OS for services through system calls; the OS switches between programs on timer interrupts (context switches) and responds to page faults by bringing the needed pages into memory. From device drivers and memory-mapped I/O to virtualization with hypervisors, this topic covers how hardware and software cooperate.

All OS & Hardware questions (50)

  1. What is the main purpose of giving a CPU a privileged (kernel) mode and a user mode?
  2. What is the mechanism by which applications ask the OS to perform tasks such as file I/O?
  3. What happens when the ecall instruction at the end of the RISC-V code above executes?
  4. Which is the usual distinction between interrupts and exceptions?
  5. Which of the following is asynchronous, occurring at unpredictable times unrelated to the instruction being executed?
  6. What is the usual sequence when a CPU accepts an interrupt?
  7. What is the role of an interrupt vector table?
  8. What should you keep in mind when temporarily disabling (masking) interrupts during a critical section?
  9. Why is interrupt handling split into a short part done immediately and the remainder done later in a normal context?
  10. What is the role of a page table?
  11. When does a page fault occur?
  12. When a page fault occurs on a page that was evicted to disk, what does the OS do?
  13. What is the main reason for using multilevel (hierarchical) page tables instead of a single level?
  14. With 32-bit virtual addresses, 4 KB pages and 4-byte page-table entries, how large is a single-level page table?
  15. With 48 virtual address bits in use, 4 KB pages and 512-entry (9-bit) tables at each level, how many levels must a multilevel page table walk?
  16. Which combination of information does a page-table entry usually contain?
  17. What is the advantage of using copy-on-write when duplicating a process?
  18. Which describes demand paging?
  19. In the clock (second-chance) page-replacement algorithm, what is each page's reference bit used for?
  20. With FIFO page replacement, adding physical pages can sometimes increase page faults. What is this phenomenon called?
  21. What is the state called in which physical memory is so short that pages are constantly evicted and reloaded and little work gets done?
  22. Memory access time is 100 ns and handling a page fault takes 8 ms. If a page fault occurs once per million accesses, what is the average access time approximately?
  23. During a context switch, what must be saved for the process being switched out?
  24. Why can a process context switch degrade performance more than the time spent saving and restoring registers would suggest?
  25. What is the advantage of tagging each TLB entry with an ASID (address space identifier)?
  26. What mechanism mainly lets the OS reclaim the CPU at regular intervals, even from programs that never give it up voluntarily, and switch to other processes?
  27. When reading a device status register via memory-mapped I/O as above, why is it declared volatile and the region configured as uncached?
  28. When is polling, in which the CPU repeatedly checks device status instead of using interrupts, advantageous?
  29. In a system where hardware does not keep caches coherent, what must software do before the CPU reads data a device wrote to main memory via DMA?
  30. What is the main role of an IOMMU?
  31. What is the role of a device driver?
  32. Why do typical operating systems prevent applications from directly reading and writing device registers?
  33. What is the software called that runs multiple operating systems simultaneously on one computer, each as an independent virtual machine?
  34. Which correctly describes the types of hypervisors?
  35. In virtualization with nested paging (two-stage address translation), which describes what the hardware does?
  36. In nested paging where both guest and host use 4-level page tables, how many memory accesses can a TLB miss require in the worst case?
  37. What is it called when a guest OS executes a privileged instruction, control passes to the hypervisor, and the hypervisor reproduces the instruction's effect on its behalf?
  38. Which describes paravirtualization?
  39. Which correctly distinguishes containers from virtual machines?
  40. Many OSes map the kernel into part of every process's address space (for example the upper range) and forbid user-mode access through page-table protection bits. What is the main advantage of this layout?
  41. With a 4 KB page size, how many virtual address bits represent the position within a page (the offset)?
  42. With 4 KB pages, which pair gives the page number and offset of the 32-bit virtual address 0x00403ABC?
  43. Which set of operating modes is defined by the RISC-V privileged architecture?
  44. When returning from an interrupt or exception handler, why is a dedicated return instruction (such as RISC-V's sret or mret) used instead of an ordinary function return?
  45. In a system requiring real-time behavior, which factor most increases interrupt latency, the time from an interrupt occurring until its handler starts?
  46. Which describes an NMI (non-maskable interrupt)?
  47. On a multicore system, when the OS modifies a page-table entry to revoke a mapping, what must be done?
  48. What generally happens when a program accesses an address the OS has not allocated?
  49. In a mechanism that maps a file into memory (such as mmap), what happens when the file's contents are read?
  50. When writing small data one byte at a time, why is accumulating it in a user-space buffer and writing in bulk faster than calling a system call each time?

Other topics in Computer systems