📝 Kernel data structures in Kernel I/O Subsystem (8 MCQs)
Data Structures for Managing I/O Resources
The kernel I/O subsystem uses data structures to represent devices, drivers, open requests, buffers, queues, and completion states. These structures allow the operating system to track which operations are pending, which resources are available, and how requests relate to processes and hardware. Their organisation supports efficient lookup, coordination, error handling, and device-independent management.
Why I/O State Must Be Represented in the Kernel
Several processes may request the same device, and one operation can remain active while others wait. The kernel must preserve request parameters, transfer progress, buffer locations, and completion status. Without organised structures, it would be difficult to coordinate concurrent operations, resume interrupted work, or identify the process that should receive a result.
Device Tables, Request Queues and Buffer Records
Device tables describe registered devices and their associated drivers or status. Request queues hold pending operations, while per-request structures record details such as the operation type, target address, buffer, and state. Buffer and cache metadata track memory areas containing transfer data. Completion handlers update these records before waking waiting tasks or signalling results.
Example of Two Requests Waiting for One Device
Suppose process P1 requests block 40 and P2 requests block 85 from the same disk. The kernel creates separate request records and places them in the device queue. The scheduler selects a request for execution. When it completes, the kernel updates its status, notifies P1, and processes the remaining request.
Concurrency, Lookup Costs and Memory Use
Well-designed structures support quick request lookup, controlled queue updates, and efficient buffer management. Linked lists, trees, hash tables, and arrays may be used according to workload and implementation needs. Concurrent updates require synchronisation, while excessive metadata increases memory use. Real operating systems use more complex structures than a simplified textbook device table.
Misconceptions About Kernel I/O Structures
'A device table stores all transferred file contents' confuses device metadata with data buffers and caches. 'Every I/O request is stored in one universal queue' is false because systems maintain queues at different layers and for different devices. 'Queue entries never change after submission' ignores updates to progress, completion, and error state.
Exam Focus: Tracking Requests and Device Metadata
Identify the purpose of device tables, request queues, buffer descriptors, and completion records. Trace how two processes create and update separate requests for one device. Questions may ask which fields must be preserved during an I/O operation or how synchronisation prevents concurrent queue updates from corrupting kernel state.
Key Terms of Kernel I/O Data Structures
- Device table - Records registered device information.
- Request queue - Holds operations awaiting execution.
- Request record - Stores details of one I/O operation.
- Buffer descriptor - Identifies a memory transfer area.
- Completion state - Records the outcome of a request.
📝 All Kernel data structures in Kernel I/O Subsystem MCQs
Q1. What is the range of vector numbers reserved for non‑maskable interrupts in the Intel Pentium processor?
📖 Explanation: The correct answer is A because non‑maskable interrupts occupy vectors 0 through 31, as defined by the processor architecture. Option B describes the maskable range, while C and D are incorrect sub‑ranges. Knowing the correct range helps the OS place critical exception handlers, ensuring that fatal errors are caught immediately without being disabled.
Q2. Why does the interrupt priority level mechanism allow a high‑priority interrupt to preempt a low‑priority one without masking all interrupts?
📖 Explanation: The correct answer is B because the priority system lets the CPU mask only those interrupts whose priority is lower than the current level, leaving higher‑priority requests able to interrupt. Option A is wrong because low‑priority interrupts are not ignored; they are delayed. Option C describes a different mechanism (queueing) not used here. Option D would halt all interrupts, defeating responsiveness.
Q3. How does the operating system use the interrupt vector during boot time?
📖 Explanation: The correct answer is B. During boot, the OS probes buses to discover devices and writes the address of each device’s service routine into the appropriate vector slot, ensuring that later interrupts are dispatched correctly. Option A confuses error detection with vector usage. Option C would prevent any interrupt handling. Option D is not a standard practice and would break deterministic interrupt routing.
Q4. A disk controller raises interrupt vector 46 indicating data ready. The current interrupt service routine is handling vector 12 (a low‑priority timer). Which action should the CPU take?
📖 Explanation: The correct answer is B because vector 46 has a higher priority than the timer’s vector 12, so the CPU preempts the low‑priority routine to service the urgent I/O request. Option A would delay data processing, risking buffer overflow. Option C would discard the interrupt. Option D would treat it as low priority, which contradicts the priority scheme.
Q5. If a high‑priority interrupt with vector 20 occurs while the CPU is servicing a maskable interrupt at vector 60, what will the CPU do?
📖 Explanation: The correct answer is B. Vector 20 belongs to the non‑maskable range (0–31) and has higher priority, so the CPU aborts the current maskable service routine (vector 60) and jumps to the higher‑priority handler. Option A ignores priority rules. Option C is impossible because non‑maskable interrupts cannot be masked. Option D is not feasible; the CPU handles one interrupt at a time.
Q6. An OS mistakenly registers a page‑fault handler at a maskable vector (e.g., vector 50). What is the most likely outcome when a page fault occurs?
📖 Explanation: The correct answer is C because page faults are defined as non‑maskable exceptions (vector 14). Placing the handler at a maskable slot means the CPU will not invoke it for a fault; instead, the mismatch triggers a general protection fault, often leading to a system crash. Option A is wrong because the CPU looks for the handler at the predefined vector. Option B misstates the CPU behavior; non‑maskable faults cannot be treated as maskable. Option D is inaccurate; the interrupt is not silently discarded.
Q7. What is the primary purpose of maskable interrupts (vectors 32–255) in an operating system’s I/O subsystem?
📖 Explanation: The correct answer is B because maskable interrupts let the OS enable or disable specific device interrupts, controlling I/O flow without disabling all interrupts. Option A describes non‑maskable exceptions. Option C confuses interrupts with system call vectors. Option D is false; polling is an alternative technique, not replaced by maskable interrupts.
Q8. Why is it important for the operating system to install interrupt handlers before any device generates an interrupt?
📖 Explanation: The correct answer is B because without a valid handler, the CPU would jump to an undefined address, causing a crash or undefined behavior. Option A is incorrect; the CPU cannot simply ignore a pending interrupt. Option C is unrelated to handler installation. Option D misrepresents the role of the handler; resetting the device is not the purpose of the interrupt vector.