OS & Hardware
Why do typical operating systems prevent applications from directly reading and writing device registers?
- AApplication programs cannot contain instructions that access registers
- BIf multiple programs operated devices freely, device state could be corrupted and protection broken
- 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.