📝 I/O protection in Kernel I/O Subsystem (8 MCQs)
Controlling Access to Devices and I/O Operations
I/O protection prevents unauthorised processes from controlling devices or accessing resources through privileged hardware interfaces. The kernel regulates device access through permissions, system calls, driver interfaces, and privilege checks. It ensures that ordinary applications request operations through controlled services rather than directly manipulating controller registers or disrupting other users' device activity.
Why Unrestricted Device Access Is Dangerous
Direct device access may allow a process to interfere with another process's input or output, corrupt storage, bypass file permissions, or disrupt system operation. Some devices also expose privileged commands that affect the entire machine. Protection therefore separates user-level requests from privileged device control and restricts access to sensitive resources.
Kernel Mode and Permission Checkpoints
An application requests a device operation through a system call or authorised interface. The kernel checks the caller's credentials, requested operation, and object permissions before dispatching it to a driver. Device registers are generally accessed through privileged code or controlled mappings. Hardware privilege modes prevent ordinary user instructions from directly executing restricted operations.
Example of Restricting Raw Disk Access
Suppose an ordinary user process attempts to write directly to a protected disk device. The operating system checks the process permissions and denies access when it lacks the required authority. The user may still modify an authorised file through the file system, which performs its own checks and controls the underlying disk updates.
Security Boundaries and Device Sharing
I/O protection limits damage from malicious programs and accidental misuse while allowing legitimate sharing through controlled interfaces. It is essential for storage, network interfaces, memory-mapped devices, and system control hardware. Incorrect permissions or unsafe device mappings can bypass protection, while excessive restrictions may prevent legitimate diagnostic or administrative operations.
Misconceptions About I/O Protection
'User programs can freely access every device register' is false because privileged access is controlled by the kernel and hardware. 'File permissions alone protect every device operation' ignores device-specific and system-level checks. 'Kernel mode automatically makes every driver operation safe' is incorrect because privileged software can contain bugs or be compromised.
Exam Focus: Privileged Access and Device Permissions
Explain why device controllers require controlled access and how system calls provide a protected path to hardware. Distinguish user mode from kernel mode and identify where permission checks occur. Scenario questions may ask why raw disk writes are restricted or how unsafe memory-mapped device access could compromise system integrity.
Key Terms of I/O Protection
- User mode - Restricted execution privilege for applications.
- Kernel mode - Privileged execution for operating system code.
- Device permission - Authority to access a device.
- System call - Controlled entry into kernel services.
- Register mapping - Address access to device registers.
📝 All I/O protection in Kernel I/O Subsystem MCQs
Q1. Why are vectors 0–31 designated as non‑maskable in the Intel interrupt architecture?
📖 Explanation: The first 32 vectors correspond to events such as divide error, page fault, and machine check, which indicate conditions that the CPU must handle immediately to maintain correct operation. Because masking them could allow a serious fault to go unnoticed, the architecture makes them non‑maskable. This ensures the operating system is forced to service these critical errors right away, whereas lower‑priority or device‑generated interrupts can be masked or delayed.
Q2. How do interrupt priority levels improve system responsiveness compared to simply masking all interrupts?
📖 Explanation: Priority levels assign a rank to each interrupt source, so when a low‑priority handler is executing, a higher‑priority interrupt can interrupt it and be serviced immediately. If the system only used a global mask, every interrupt would be delayed until the mask is cleared, degrading responsiveness. By using priorities, the OS can defer only less important work while still reacting quickly to urgent events, keeping the system interactive and reliable.
Q3. A driver installs an interrupt handler for vector 45. While this handler runs, a higher‑priority interrupt with vector 20 occurs. What does the CPU do?
📖 Explanation: Vector 20 falls in the non‑maskable range (0‑31) and has a higher priority than vector 45, which is maskable. The CPU’s priority scheme allows the higher‑priority interrupt to pre‑empt the lower‑priority routine, saving the current context and branching to the handler for vector 20. This behavior prevents critical errors from being delayed, while the lower‑priority handler resumes once the high‑priority work completes.
Q4. During operation a device raises an interrupt with vector 70. How does the operating system decide which routine to run?
📖 Explanation: The interrupt‑vector table is a data structure that maps each possible vector number to a specific handler address. When the CPU receives vector 70, the OS indexes this table, retrieves the stored address, and transfers control to that routine. This direct mapping is fast and deterministic, unlike searching device IDs or consulting the BIOS, which would add unnecessary latency and complexity to interrupt handling.
Q5. A page‑fault exception (vector 14) occurs while a process accesses an unmapped page. Why is this interrupt maskable, and what steps should the OS take?
📖 Explanation: Page faults are caused by normal memory accesses and can be handled without stopping the entire system, so they are maskable. The OS records the faulting virtual address, allocates a physical page, updates the page table, and then restarts the instruction that caused the fault. By handling the event in software, the OS maintains program continuity while protecting memory integrity, illustrating how maskable exceptions enable graceful recovery.
Q6. After boot, a new peripheral is added to the system. What must the operating system do to ensure its interrupts are serviced correctly?
📖 Explanation: When a new device appears, the OS assigns it a free vector number and records the address of its handler in the interrupt‑vector table. This dynamic update allows the CPU to route future interrupts from the device to the correct routine without requiring a full system restart. Ignoring the new device or reusing a vector would cause conflicts or missed interrupts, leading to unreliable I/O behavior.
Q7. What is the primary distinction between a double‑fault (vector 8) and a general‑protection fault (vector 13)?
📖 Explanation: A double‑fault signals that an exception occurred while the CPU was already processing a different exception, indicating a failure in the exception‑handling mechanism itself. This makes it a higher‑severity condition than a general‑protection fault, which simply indicates an illegal memory or privilege access and can be handled normally. Understanding this difference helps OS designers prioritize recovery actions and maintain system stability.
Q8. Which vector number is assigned to the divide‑error exception?
📖 Explanation: The Intel interrupt architecture defines vector 0 for the divide‑error exception, which is raised when a program attempts to divide by zero or when the quotient is too large to fit in the destination register. Recognizing this mapping allows developers to install a specific handler at vector 0 to catch arithmetic errors early, preventing undefined behavior and ensuring the operating system can safely terminate or correct the offending process.