🎓 BookMCQ
← Back to 13. I/O Systems

📝 Vectored I/O in Application I/O Interface (8 MCQs)

Gathering and Scattering Data with Vectored I/O

Vectored I/O allows an application to transfer data through multiple noncontiguous memory buffers using a single I/O operation. Read operations can scatter incoming data across several buffers, while write operations can gather data from multiple buffers for one output request. Common interfaces include readv and writev on POSIX systems, which use arrays of buffer descriptors.

Why Multiple System Calls and Buffer Copies Are Costly

Applications often store one logical message in separate header, metadata, and payload buffers. Issuing an ordinary write for every part can require repeated system calls and additional coordination. Vectored I/O combines these buffers into one operation, reducing call overhead and allowing the kernel or device path to process the segments together.

Buffer Descriptors and Transfer Ordering

The application supplies an array of iovec-style descriptors, each identifying a base address and length. A vectored write processes the buffers in array order as one logical sequence. A vectored read fills the supplied buffers in order. The kernel validates the descriptors and reports the total number of bytes transferred.

Example of Writing a Header and Payload

Suppose a network application stores a 20-byte message header and a 500-byte payload in separate buffers. A vectored write submits both descriptors in one call. The resulting byte sequence contains the header followed by the payload, avoiding the need to first copy them into one application buffer.

Reduced Call Overhead and Partial Transfer Handling

Vectored I/O is useful for network protocols, file output, logging, and applications that construct messages from separate components. It can reduce system call count, but does not guarantee zero-copy transfer or a single physical device operation. Partial writes and reads remain possible, and applications must track how much data was transferred across buffer boundaries.

Misconceptions About Vectored Transfers

'Vectored I/O uses multiple system calls for multiple buffers' is false because one vectored call describes several buffers. 'Vectored I/O always eliminates data copying' is incorrect because the kernel may still copy data. 'A successful vectored write guarantees every byte was written' ignores partial transfer results and possible errors.

Exam Focus: Buffer Vectors and Transfer Counts

Be able to explain how a buffer descriptor identifies a memory region and how readv and writev order the data. Given buffer lengths of 20 and 500 bytes, calculate the maximum requested total of 520 bytes. Also trace partial transfers and distinguish vectored I/O from direct memory access and scatter-gather DMA.

Key Terms of Vectored I/O

  • Vectored I/O - Transfers data through multiple buffers.
  • Scatter read - Places input across several buffers.
  • Gather write - Combines buffers into one output sequence.
  • iovec - Descriptor containing buffer address and length.
  • Partial transfer - Operation moving fewer bytes than requested.
2
Easy
4
Medium
2
Hard

📝 All Vectored I/O in Application I/O Interface MCQs

Q1. A computer has a keyboard, a network card, and a disk controller. When any device raises an interrupt, the CPU must quickly find the correct handler. Which advantage does vectored I/O provide in this situation?

A.It eliminates the need for an interrupt controller.
B.It supplies the handler address directly, avoiding polling. ✅
C.It guarantees that all devices are serviced simultaneously.
D.It reduces the CPU clock speed required for I/O.
💡 Difficulty: easy | ✅ Correct: B

📖 Explanation: The correct answer is B because vectored I/O includes the handler address in the interrupt request, allowing the CPU to jump straight to the appropriate routine without scanning or polling devices. Option A is incorrect; an interrupt controller is still required to aggregate lines. Option C is false because interrupts are serviced one at a time, not concurrently. Option D is unrelated; vectored I/O does not change the CPU clock frequency. This demonstrates how vectored I/O speeds up device handling in a multi‑device environment.

Q2. In a server handling 200 peripheral devices, which method most effectively minimizes interrupt latency when using vectored I/O?

A.Poll each device sequentially after every instruction.
B.Use a single global interrupt handler that checks a status register.
C.Assign each device a unique priority level but use non‑vectored interrupts.
D.Provide each device its own vector entry so the CPU jumps directly to its handler. ✅
💡 Difficulty: medium | ✅ Correct: D

📖 Explanation: The correct answer is D because giving each device a distinct vector entry lets the CPU immediately branch to the correct service routine, cutting the time spent searching for the source of the interrupt. Option A would cause huge overhead due to constant polling. Option B still requires the CPU to examine status bits, adding delay. Option C mixes priority with non‑vectored handling, which does not remove the need to identify the device. Thus, per‑device vectors are the most efficient way to reduce latency.

Q3. Assume the interrupt vector table starts at memory address 0x80000x8000. Each vector entry occupies 4 bytes. What address will the CPU jump to for vector number 12?

A.0x80300x8030 ✅
B.0x80100x8010
C.0x80280x8028
D.0x80400x8040
💡 Difficulty: hard | ✅ Correct: A

📖 Explanation: The correct answer is A because the address is calculated as base + (vector number × entry size): 0x8000+12×4=0x8000+48=0x80300x8000 + 12 \times 4 = 0x8000 + 48 = 0x8030. Option B uses only 16 bytes offset, which would correspond to vector 4. Option C gives an offset of 40 bytes (vector 10). Option D adds 64 bytes, matching vector 16. Understanding this arithmetic is essential for designing interrupt‑vector tables and for the CPU to locate the proper service routine.

Q4. A real‑time process is updating a shared data structure and must not be interrupted. Which feature of modern interrupt controllers should the OS use to temporarily block interrupts from lower‑priority devices?

A.Interrupt nesting
B.Interrupt masking ✅
C.Interrupt vectoring
D.Interrupt polling
💡 Difficulty: medium | ✅ Correct: B

📖 Explanation: The correct answer is B because interrupt masking allows the operating system to disable (mask) lower‑priority interrupt lines while a critical section runs, preventing unwanted pre‑emption. Option A, nesting, permits higher‑priority interrupts to occur during an interrupt, which does not protect the critical region. Option C, vectoring, only provides the address of the handler and does not control whether an interrupt is delivered. Option D, polling, is a software technique that would still expose the process to interrupts. Masking is the standard way to defer lower‑priority interrupts safely.

Q5. Why does vectored I/O typically generate less overhead than non‑vectored (polling) interrupt handling?

A.It uses DMA to transfer data without CPU involvement.
B.It provides the handler address in the interrupt request, eliminating extra I/O reads. ✅
C.It allows multiple interrupts to be processed in parallel.
D.It disables caching during interrupt handling.
💡 Difficulty: medium | ✅ Correct: B

📖 Explanation: The correct answer is B because the interrupt request carries a vector that points directly to the appropriate service routine, so the CPU does not need to perform additional I/O reads to discover the source device. Option A describes DMA, which is unrelated to vector delivery. Option C is incorrect; interrupts are still serialized, not parallel. Option D is false; caching policies are independent of vectored I/O. This reduction in extra bus transactions is why vectored I/O is more efficient.

Q6. How does the CPU determine the correct interrupt‑service routine when a device raises an interrupt in a vectored I/O system?

A.It reads a status register to identify the device.
B.It executes a fixed routine that then queries the device.
C.The interrupt controller sends the program counter value of the next instruction.
D.The interrupt request includes a vector that indexes into a table of handler addresses. ✅
💡 Difficulty: medium | ✅ Correct: D

📖 Explanation: The correct answer is D because in a vectored system the interrupt request contains a vector number that the CPU uses as an index into a predefined table of handler addresses, enabling an immediate jump to the right routine. Option A describes a polling approach, not vectored I/O. Option B implies a two‑step process, which adds latency. Option C is unrelated; the program counter is not part of the interrupt request. Thus, the vector mechanism provides the direct mapping needed for fast handling.

Q7. In a system with multilevel interrupt priorities, how does vectored I/O interact with priority handling to ensure high‑priority devices are serviced first?

A.All vectors are stored in a single table, and the CPU always selects the highest address.
B.The interrupt controller masks lower‑priority vectors until higher‑priority interrupts are cleared.
C.Each priority level has its own separate vector table, and the CPU jumps to the table corresponding to the highest pending priority. ✅
D.Vectored I/O ignores priority, always servicing devices in the order they raise interrupts.
💡 Difficulty: hard | ✅ Correct: C

📖 Explanation: The correct answer is C because many architectures maintain separate vector tables for each priority level; when an interrupt occurs, the controller first determines the highest pending priority and then provides the vector from that level’s table, ensuring the most urgent device is handled first. Option A is incorrect; a single table does not convey priority. Option B describes masking, which can prevent lower‑priority interrupts but does not explain how the correct handler is selected. Option D is false; vectored I/O works together with priority schemes rather than ignoring them. This relationship is key to deterministic interrupt response.

Q8. What is the name of the line that the CPU continuously monitors to detect an interrupt request from a device controller?

A.interrupt‑request line ✅
B.data‑bus line
C.address‑bus line
D.control‑signal line
💡 Difficulty: easy | ✅ Correct: A

📖 Explanation: The correct answer is A because the CPU watches the interrupt‑request line for a signal indicating that a device needs service. Option B, the data‑bus line, carries data between components and is not used for signaling interrupts. Option C, the address‑bus line, carries memory addresses, not interrupt signals. Option D, control‑signal line, is a generic term that does not specifically refer to interrupt requests. Recognizing the interrupt‑request line is fundamental to understanding how hardware signals the CPU for I/O processing.

🔗 Related Topics (MCQs)