OS & Hardware

Why do typical operating systems prevent applications from directly reading and writing device registers?

  1. AApplication programs cannot contain instructions that access registers
  2. BIf multiple programs operated devices freely, device state could be corrupted and protection broken
  3. CDevice registers can be accessed only right after power-up
Show answer and explanation

Answer: B. If multiple programs operated devices freely, device state could be corrupted and protection broken

The addresses of device registers are marked inaccessible from user mode in the page tables, so only OS drivers can operate them. If multiple programs manipulated the same device freely, their intermediate states would mix and the device would malfunction, and protection could be broken, for example by using DMA to overwrite arbitrary memory. Applications ask the OS through system calls instead. The instructions can be written; protection forbids them.

  • A. The instructions can be written but are forbidden by page-table protection.
  • B. Correct. It prevents corrupted device state and broken protection.
  • C. Registers can be accessed at any time.
Practice this topic Back to topic

More OS & Hardware questions

  1. What is the software called that runs multiple operating systems simultaneously on one computer, each as an independent virtual machine?
  2. Which correctly describes the types of hypervisors?
  3. In virtualization with nested paging (two-stage address translation), which describes what the hardware does?
  4. 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?
  5. 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?