Normally user programs are prevented from handling I/O directly by I/O…
2018
Normally user programs are prevented from handling I/O directly by I/O instructions in them. For CPUs having explicit I/O instructions, such I/O protection is ensured by having the I/O instructions privileged. In a CPU with memory mapped I/O, there is no explicit I/O instruction. Which one of the following is true for a CPU with memory mapped I/O ?
- A.
I/O protection is ensured by operating system routines.
- B.
I/O protection is ensured by a hardware trap.
- C.
I/O protection is ensured during system configuration.
- D.
I/O protection is not possible.
Attempted by 345 students.
Show answer & explanation
Correct answer: A
Answer: I/O protection is ensured by operating system routines.
Explanation:
In a memory-mapped I/O system, device registers are accessed using normal memory read/write instructions. Because there are no special privileged I/O instructions, the operating system must prevent user programs from directly accessing device addresses.
The OS maps device physical addresses only into kernel (privileged) virtual address space.
User processes do not have those mappings, so any attempt to access device addresses from user mode will fault (for example, a page fault) and be handled by the OS.
Consequently, user programs must request I/O through OS routines (system calls), which perform the necessary privileged memory accesses on their behalf.
Note: Hardware (the MMU) provides the fault mechanism that stops invalid accesses, but the OS configures and controls the mappings. Hence protection is implemented by the OS using memory protection mechanisms rather than by a separate privileged I/O instruction.
A video solution is available for this question — log in and enroll to watch it.