Input / Output Systems MCQs for the NSCT

By the NSCT Exam Editorial Team · Updated 2026-11-24 · Facts checked against official sources on 2026-11-24

Input/output (I/O) systems are the part of the operating system that moves data between the CPU, memory and devices such as disks, keyboards and network cards. The core question is how the CPU learns that a device is ready and who moves the data. The three answers are polling, interrupts and DMA, and buffering smooths out the speed differences. This is topic 11 of the 12 in the Operating Systems area, which carries 5% of the NSCT according to HEC's Areas of Competencies.

Operating Systems was the weakest area in 2026: candidates averaged 33.8%, the lowest of all ten areas, per the HEC NSCT report. I/O questions mix definitions with short overhead calculations, so learn the formulas below. This page follows Silberschatz's chapter on I/O systems, with Stallings's buffering model where noted.

Polling

In polling (programmed I/O with busy-waiting), the CPU repeatedly reads the device controller's status register until the busy bit clears, then writes the command and data itself.

Polling costs CPU time = polls per second × cycles per poll ÷ clock rate. Polling 1,000 times a second at 500 cycles a poll on a 1 GHz CPU uses 0.05% of the CPU.

Exam angle: polling is not always bad. If the device is ready within a few microseconds, a short busy-wait costs less than handling an interrupt.

Interrupts

With interrupts, the device raises a signal on the interrupt-request line when it is ready. After the current instruction, the CPU saves its state, looks up the handler in the interrupt vector and runs it. Some key terms:

Each interrupt costs a fixed overhead, so fast devices with one interrupt per byte or word can swamp the CPU. For example, a device sending 200,000 bytes/s with one 4-microsecond interrupt per byte uses 200,000 × 4 µs = 0.8 s of every second: 80% of the CPU.

Exam angle: the fraction of CPU time is interrupts per second × handler time. If it comes out above 100%, interrupt-driven I/O cannot keep up.

DMA

Direct memory access (DMA) hands block transfers to a DMA controller. The CPU writes a command block (source, destination, byte count), the controller moves the data over the bus, and the CPU gets one interrupt per block.

Method Who moves the data Interrupts Best for
Polling CPU, busy-waiting None Very fast, short operations
Interrupt-driven CPU, per byte or word One per byte or word Slow devices, such as keyboards
DMA DMA controller One per block Disks, network cards, bulk data

Take the same 200,000 bytes/s device with DMA and 4,096-byte blocks, at 20 µs of CPU time per block. That is about 48.8 blocks a second × 20 µs, roughly 0.1% of the CPU instead of 80%. While the controller uses the bus, the CPU may briefly lose memory cycles. This is called cycle stealing. Scatter-gather DMA moves data to or from several non-contiguous memory areas with one command.

Exam angle: DMA does not remove the CPU entirely. The CPU still sets up the transfer and handles the completion interrupt.

Buffering

A buffer is memory that holds data in transit. Silberschatz gives three reasons for buffering: a speed mismatch between producer and consumer, different transfer sizes between devices, and copy semantics (the data written is the data as it was at the time of the write() call).

Stallings models the time per block with T for input, C for processing and M for copying from the system buffer to the user area:

Scheme Time per block
No buffering T + C
Single buffer max(C, T) + M
Double buffer max(C, T)

Related kernel services:

Exam angle: with double buffering, the slower of T and C sets the pace. Speeding up the faster one gains nothing.

Common traps

Worked examples

1. Understanding. Is a keyboard a block device or a character-stream device, and why? Answer: a character-stream device. It delivers one byte at a time through get and put operations, with no seeking. Disks are block devices with random access.

2. Application. A network card raises 40,000 interrupts per second, each costing 15 µs. What share of CPU time do they use? Answer: 40,000 × 15 µs = 0.6 s per second, which is 60%. The card is a candidate for interrupt coalescing or polling under load.

3. Analysis. Using Stallings's model with T = 50 µs, C = 80 µs and M = 5 µs, what is the time per block with single buffering, and does double buffering help? Answer: single buffering takes max(80, 50) + 5 = 85 µs. Double buffering takes max(80, 50) = 80 µs. The job is CPU-bound, so only a faster CPU would help much.

Practise

The quiz below has 100 input/output systems questions, filterable by tier and difficulty.

Practise: 100 questions

Interactive quiz loading. The first 10 questions are shown below.

  1. In polling (programmed I/O with busy-waiting), how does the CPU find out that a device controller is ready?

    1. It repeatedly reads the busy bit in the controller's status register until the bit clears
    2. The controller raises a signal on the interrupt-request line
    3. The DMA controller writes a completion record to memory
    4. The OS waits for a fixed timer interval and assumes the device is ready
    Show answer

    Answer: A. It repeatedly reads the busy bit in the controller's status register until the bit clears

    With polling, the host loops reading the status register until the busy bit is clear, then writes the command and data. Silberschatz calls this busy-waiting. Interrupts and DMA completion notices are the alternatives that free the CPU from looping.

  2. When a device raises an interrupt, what does the CPU do after finishing the current instruction?

    1. Discards the current process and starts the device driver as a new process
    2. Keeps executing and checks the device on the next timer tick
    3. Saves its state and jumps to the interrupt handler found through the interrupt vector
    4. Copies the device's data directly into the user's buffer
    Show answer

    Answer: C. Saves its state and jumps to the interrupt handler found through the interrupt vector

    The CPU senses the interrupt-request line after each instruction. If it is raised, the CPU saves the current state, uses the interrupt number to index the interrupt vector, and jumps to that handler. When the handler returns, the saved state is restored.

  3. What is the main benefit of direct memory access (DMA)?

    1. The CPU copies each byte faster than with programmed I/O
    2. A DMA controller moves a whole block between device and memory, and the CPU is interrupted only once at the end
    3. Devices no longer need device drivers
    4. It removes the need for any interrupts at all
    Show answer

    Answer: B. A DMA controller moves a whole block between device and memory, and the CPU is interrupted only once at the end

    With DMA the CPU writes a command block (source, destination, byte count) and lets the DMA controller run the transfer over the bus. The CPU is free for other work and receives a single interrupt when the whole block is done.

  4. Which is one of the main reasons the kernel buffers I/O data?

    1. To encrypt data before it reaches the disk
    2. To reduce the number of device drivers needed
    3. To cope with a speed mismatch between a data producer and a data consumer
    4. To translate virtual addresses into physical addresses
    Show answer

    Answer: C. To cope with a speed mismatch between a data producer and a data consumer

    Silberschatz gives three reasons for buffering: coping with a speed mismatch between producer and consumer (for example a modem and a disk), adapting between devices with different data-transfer sizes, and supporting copy semantics for application I/O.

  5. Which pair correctly classifies a hard disk and a keyboard?

    1. Disk: character-stream device; keyboard: block device
    2. Both are block devices
    3. Disk: block device; keyboard: character-stream device
    4. Both are network devices
    Show answer

    Answer: C. Disk: block device; keyboard: character-stream device

    A block device (such as a disk) transfers fixed-size blocks and supports random access through read, write and seek. A character-stream device (such as a keyboard) delivers bytes one at a time through get and put, with no seeking.

  6. What is the difference between maskable and nonmaskable interrupts?

    1. Maskable interrupts come from software and nonmaskable ones from hardware
    2. Nonmaskable interrupts have the lowest priority
    3. The CPU can disable a maskable interrupt before running critical code; a nonmaskable interrupt cannot be turned off and is kept for events such as unrecoverable memory errors
    4. Maskable interrupts are used only by DMA controllers
    Show answer

    Answer: C. The CPU can disable a maskable interrupt before running critical code; a nonmaskable interrupt cannot be turned off and is kept for events such as unrecoverable memory errors

    Most CPUs have two interrupt lines. The maskable line, used by device controllers, can be switched off while the CPU runs code that must not be interrupted. The nonmaskable line is reserved for events like unrecoverable memory errors and cannot be ignored.

  7. A system has more devices than entries in its interrupt vector. How does Silberschatz say this is usually handled?

    1. Interrupt chaining: each vector entry points to a list of handlers, which are called in turn until one services the request
    2. Extra devices are switched to polling permanently
    3. Two devices share a handler, which services both every time
    4. The CPU enlarges the interrupt vector at boot
    Show answer

    Answer: A. Interrupt chaining: each vector entry points to a list of handlers, which are called in turn until one services the request

    Interrupt chaining is a compromise between a huge vector table and searching every handler. Each vector element points to the head of a list of handlers, and they are tried one by one until the right one is found.

  8. While a DMA controller holds the memory bus, the CPU may be briefly unable to reach main memory. What is this called?

    1. Busy-waiting
    2. Interrupt chaining
    3. Spooling
    4. Cycle stealing
    Show answer

    Answer: D. Cycle stealing

    When the DMA controller seizes the bus to move a word, the CPU cannot use main memory for that moment, though it can still use its caches. Silberschatz calls this cycle stealing. It slows the CPU slightly, but DMA still usually improves overall performance.

  9. In double buffering, what happens while the process works on the data in one buffer?

    1. The device waits until the process empties the buffer
    2. The process copies the data to a third buffer
    3. The device fills the other buffer
    4. The device is switched to polling mode
    Show answer

    Answer: C. The device fills the other buffer

    Double buffering uses two buffers in turn. While the consumer processes one buffer, the producer (the device) fills the other, so input and processing overlap. When both are done, the roles swap.

  10. Why does an OS spool output for a printer?

    1. Spooling speeds up the printer's mechanical parts
    2. Spooling compresses the output to save paper
    3. A printer can serve only one job at a time, so each job's output is saved to a file and queued so jobs are printed whole, not interleaved
    4. Spooling lets several printers print one page together
    Show answer

    Answer: C. A printer can serve only one job at a time, so each job's output is saved to a file and queued so jobs are printed whole, not interleaved

    A spool is a buffer that holds output for a device that cannot accept interleaved data streams. Each application's output is written to a separate spool file, and the spooling system copies queued files to the printer one at a time.

FAQs

When is polling better than interrupts?

Polling is better when the device responds very quickly, so the busy-wait is shorter than the cost of an interrupt (saving state, running the handler, rescheduling). It also helps under very heavy load, as with network cards, where per-packet interrupts would swamp the CPU. Interrupts are better for slow or unpredictable devices.

What is the difference between memory-mapped and port-mapped I/O?

In memory-mapped I/O, device registers sit in the ordinary address space and are read and written with normal load and store instructions. In port-mapped (isolated) I/O, devices have a separate address space reached through special instructions, such as x86 IN and OUT. Memory-mapped registers must not be cached.

What are blocking, nonblocking and asynchronous I/O?

A blocking call suspends the process until the I/O completes. A nonblocking call returns at once with whatever data is ready, possibly none. An asynchronous call also returns at once, but the full transfer finishes later and the process is notified, for example by a signal or a callback.

Why does the OS spool printer output?

A printer can print only one job at a time. Spooling writes each process's output to its own file on disk and queues the files, so the printer handles complete jobs one after another instead of interleaving lines from several programs.

Next step

Continue to Protection & Security MCQs, the last OS topic. The previous topic is Secondary Storage Management. Revisit the Operating Systems MCQs hub or test yourself in an NSCT mock test.