📝 Error handling in Kernel I/O Subsystem (8 MCQs)
Detecting and Reporting Device Operation Failures
Error handling in the kernel I/O subsystem detects, records, and responds to failures that occur during device operations. Errors may arise from hardware faults, unavailable devices, invalid requests, transfer timeouts, media defects, or communication problems. The kernel and device drivers cooperate to report failures, preserve system consistency where possible, and return meaningful status to applications.
Why I/O Operations Require Fault Detection
Devices operate outside the CPU's direct control and may fail independently or respond unpredictably. A read may encounter an unreadable sector, a network transfer may time out, or a controller may report a hardware fault. Without error detection, incomplete or corrupted data could be treated as valid and passed to applications.
Status Reporting, Retries and Recovery Actions
A controller may report errors through status registers, completion codes, or interrupts. The driver interprets device-specific information and may retry a transient operation, reset a device, or report failure. The kernel updates request state and translates the result into an error status or return value that the application can inspect.
Example of a Failed Disk Read
Suppose an application requests a disk block, but the controller reports an uncorrectable read error. The driver records the failure and may attempt an appropriate recovery procedure. If recovery fails, the I/O request completes with an error rather than supplying invalid data as though the read had succeeded.
Reliability, Recovery and Error Propagation
Effective error handling prevents device faults from silently corrupting application results and helps systems recover from temporary failures. Retrying can resolve transient errors but may increase latency or repeat an operation with side effects. Drivers must distinguish recoverable and unrecoverable conditions, while applications need to handle error returns and partial completion correctly.
Misconceptions About I/O Error Handling
'Every device error can be fixed by retrying' is false because permanent faults may persist. 'A successful system call proves data reached permanent storage' ignores caching and write-back policies. 'The kernel always hides device failures from applications' is incorrect because errors are commonly reported through status codes or exceptions.
Exam Focus: Error Codes, Retries and Failure States
Trace how a controller reports an error and how a driver communicates the result to the kernel. Distinguish transient from permanent failures and explain when retries are appropriate. Questions may examine timeouts, partial transfers, error codes, device resets, and why an application must not assume that every I/O request succeeds completely.
Key Terms of I/O Error Handling
- Timeout - Operation exceeded its allowed duration.
- Retry - Repetition after a recoverable failure.
- Status code - Reports an operation's result.
- Uncorrectable error - Failure that recovery cannot repair.
- Recovery - Actions restoring operation after failure.
📝 All Error handling in Kernel I/O Subsystem MCQs
Q1. Which interrupt vector numbers are reserved for nonmaskable exceptions?
📖 Explanation: The correct answer is A because nonmaskable exceptions occupy vectors 0 through 31, allowing the CPU to handle critical errors that cannot be ignored. Option B describes maskable interrupts, which are optional and can be disabled. Option C limits the range incorrectly to 0–15, missing many nonmaskable vectors. Option D starts at 16, omitting the lower half of the nonmaskable range. Understanding these ranges helps OS designers map handlers to the proper vectors, ensuring reliable error processing.
Q2. Why does the CPU implement interrupt priority levels?
📖 Explanation: Option A is correct because priority levels let the CPU postpone less urgent interrupts without disabling all interrupts, and let urgent ones interrupt current handling. Option B is unrelated to priority; clock speed is hardware‑controlled. Option C concerns power management, not interrupt handling. Option D suggests parallel execution, which the CPU does not support for interrupts. Recognizing this mechanism is key for OS scheduling and responsiveness.
Q3. How does a maskable interrupt differ from a nonmaskable interrupt when handling critical errors?
📖 Explanation: The correct choice is A: maskable interrupts (vectors 32–255) can be turned off by setting appropriate flags, whereas nonmaskable exceptions (vectors 0–31) are always processed. Option B is false; priority is independent of maskability. Option C oversimplifies; maskable interrupts can also signal errors, not just I/O. Option D is inaccurate because both types may trigger context switches. This distinction guides OS developers in protecting critical sections.
Q4. A disk controller signals that a write operation has completed. Which type of interrupt is most likely generated?
📖 Explanation: Option B is correct because device‑generated events like I/O completion use maskable interrupts (vectors 32–255), allowing the OS to enable or disable them as needed. Nonmaskable exceptions are reserved for CPU‑internal faults, not peripheral signals. Software interrupts are invoked by the CPU itself, not external hardware. Trap exceptions are a subclass of nonmaskable exceptions used for debugging. Recognizing the correct category ensures the OS installs the appropriate handler for device readiness.
Q5. When a user‑mode program attempts to execute a privileged instruction, which interrupt vector number is invoked?
📖 Explanation: The correct answer is B because executing a privileged instruction from user mode triggers a General Protection Fault, which resides at vector 13. Vector 0 handles divide‑by‑zero errors, not privilege violations. Vector 6 signals an invalid opcode, unrelated to privilege levels. Vector 14 deals with page faults caused by memory access errors. Knowing the specific vector helps the OS pinpoint the cause of a protection violation and respond appropriately.
Q6. The CPU is servicing a low‑priority interrupt from vector 45 when a high‑priority interrupt from vector 14 arrives. What will the CPU do?
📖 Explanation: Option B is correct: the CPU’s priority scheme forces the high‑priority interrupt (vector 14) to pre‑empt the ongoing low‑priority service routine, ensuring urgent conditions are addressed first. Option A would violate priority rules, potentially delaying critical response. Option C incorrectly suggests the CPU cannot pre‑empt, which defeats the purpose of priority levels. Option D is impossible because interrupt handlers are distinct. This behavior is essential for maintaining system stability under concurrent interrupt loads.
Q7. Why is the page‑fault vector (14) classified as maskable even though it signals a memory‑management error?
📖 Explanation: The correct answer is C: marking the page‑fault vector as maskable lets the CPU defer its handling when higher‑priority interrupts demand immediate attention, while still guaranteeing eventual service. Option A is incorrect; OSs generally keep page‑fault handling enabled. Option B mischaracterizes severity; page faults can be critical. Option D confuses the source; page faults arise from hardware memory‑access violations. Understanding this classification helps OS designers balance responsiveness with correct memory management.
Q8. During system boot, the OS installs an interrupt handler for vector 8 (double fault). Which action is essential to ensure proper handling of a double fault?
📖 Explanation: Option C is correct: a double fault occurs when an exception happens while trying to invoke another exception handler, so the OS must disable all maskable interrupts to prevent recursive faults and ensure a controlled response. Option A would allow user‑mode code to invoke the handler, which is unsafe. Option B is unnecessary because the double‑fault handler uses a known stack. Option D would obscure the distinct nature of a double fault. Properly disabling interrupts during this critical condition is vital for system reliability.