📝 Network devices in Application I/O Interface (8 MCQs)
Network Interfaces as Application Communication Devices
Network devices allow applications to exchange data with processes and systems across connected networks. Unlike ordinary block or character device access, networking commonly uses socket interfaces that represent communication endpoints. The operating system manages network protocols, packet buffers, interface drivers, and transmission hardware, while applications work with connections, addresses, and data streams or datagrams.
Why Network Communication Needs Endpoint Abstraction
Applications cannot assume that a remote host behaves like a locally attached storage device. Networks introduce addressing, routing, protocol rules, delays, packet loss, and connection failures. Socket abstractions provide a standard programming interface while the kernel handles protocol processing and communication with the network interface hardware.
Socket Operations and Packet Transmission
An application creates a socket, selects an address family and communication type, then binds, connects, sends, or receives data as appropriate. The kernel processes protocol headers, manages buffers, and passes packets to a network driver. The driver prepares hardware transmission, while received packets are delivered through the network stack to the appropriate socket.
Example of Sending Data Through a TCP Socket
A client creates a TCP socket and connects to a server at a specified IP address and port. It writes 500 bytes to the socket. The kernel's TCP implementation handles segmentation, sequencing, and retransmission as necessary, while the network driver transmits packets through the network interface.
Network Protocol Costs and Application Behaviour
Socket interfaces support web applications, remote services, file transfer, and real-time communication. TCP provides a reliable ordered byte stream, while UDP supports datagram communication without TCP's delivery guarantees. Network latency, congestion, packet loss, and buffer limits affect performance. Applications must handle partial transfers, timeouts, disconnects, and protocol-specific behaviour.
Misconceptions About Network I/O
'A socket is a physical network card' is incorrect because it is a software communication endpoint. 'TCP preserves application message boundaries' is false because TCP provides an ordered byte stream. 'Sending data successfully means the remote application has processed it' is misleading because local acceptance or transmission does not confirm remote application-level completion.
Exam Focus: Sockets, TCP and UDP Interfaces
Trace socket creation, connection establishment, data transfer, and closure. Distinguish stream sockets using TCP from datagram sockets commonly using UDP. Questions may test the roles of IP addresses and ports, kernel protocol processing, network drivers, packet buffers, and why a successful write does not guarantee remote application processing.
Key Terms of Network I/O
- Socket - Software endpoint for network communication.
- TCP - Reliable ordered byte-stream protocol.
- UDP - Connectionless datagram transport protocol.
- Port - Identifies a transport service endpoint.
- Packet - Formatted unit of network transmission.
📝 All Network devices in Application I/O Interface MCQs
Q1. Which instruction restores the CPU state after handling an interrupt?
📖 Explanation: The correct answer is A because the return‑from‑interrupt instruction tells the CPU to restore the registers and program counter saved when the interrupt occurred, allowing execution to continue where it left off. Option B describes the initial jump to the handler, not the restoration step. Option C is part of the entry sequence, not the exit. Option D merely disables further interrupts and does not recover the saved context. Restoring state ensures the interrupted program resumes correctly, which is essential for reliable I/O processing.
Q2. Why are multilevel interrupts important in modern operating systems?
📖 Explanation: Multilevel interrupts let the system assign different priority levels to interrupt sources, so urgent events like timer ticks can pre‑empt less critical ones such as background network traffic. Option A is unrelated to priority handling. Option B describes IRQ sharing, which is a separate concept. Option D might be a side effect but does not capture the main benefit. Prioritization improves responsiveness and ensures time‑critical tasks are serviced promptly.
Q3. A kernel critical section must defer interrupts from a network card until it finishes updating a shared buffer. Which mechanism should the OS use?
📖 Explanation: Masking only the network card’s interrupt line (option B) isolates the critical section from that specific device while allowing other interrupts to be processed, preserving overall system responsiveness. Option A would halt all interrupt activity, unnecessarily degrading performance. Option C raises the CPU priority but does not specifically block the network card’s line, potentially still allowing its interrupt. Option D replaces interrupt handling with inefficient polling, contradicting the goal of deferral during a critical region.
Q4. When an interrupt occurs, which hardware component allows the CPU to quickly determine which device raised it without scanning all devices?
📖 Explanation: The programmable interrupt controller (PIC) consolidates interrupt signals and provides the CPU with a vector that identifies the originating device, eliminating the need for exhaustive polling. Option A, the DMA controller, moves data but does not identify interrupt sources. Option B, the interrupt vector table, stores handler addresses but relies on the PIC to supply the correct index. Option D, the MMU, manages virtual memory and is unrelated to interrupt identification. Hence, the PIC is the key component for rapid source determination.
Q5. How does the CPU detect an interrupt request?
📖 Explanation: The CPU’s control unit samples the interrupt‑request line after each instruction, so any pending request is noticed immediately (option B). Option A limits detection to program start, missing asynchronous events. Option C mischaracterizes the hardware behavior; interrupts can occur regardless of device idle state. Option D describes a software polling technique, not the hardware‑level detection mechanism. Continuous monitoring ensures timely response to asynchronous device signals.
Q6. A server receives both a high‑priority timer interrupt and a low‑priority network packet interrupt simultaneously. Which handling order maximizes system responsiveness?
📖 Explanation: Serving the high‑priority timer interrupt first (option C) guarantees that time‑critical tasks are not delayed, preserving system timing guarantees. Option A would postpone the timer, potentially causing missed deadlines. Option B unnecessarily stalls all processing, reducing throughput. Option D assumes parallel CPUs, which may not be available and adds synchronization complexity. Prioritizing the timer aligns with multilevel interrupt design, delivering the most responsive behavior.
Q7. Given 200,000 interrupts per second and a handler execution time of 0.3 µs, what percentage of CPU time is consumed by interrupt handling?
📖 Explanation: Each interrupt consumes 0.3 µs, so total time per second is 200,000 × 0.3 µs = 60 ms, which is 0.06 s. Dividing 0.06 s by the 1‑second interval yields 0.06 = 6 % of CPU time (option B). Option A underestimates the cost, option C doubles it, and option D vastly overestimates. Knowing the CPU overhead helps designers decide whether additional interrupt coalescing or faster handlers are needed to keep the system efficient.
Q8. What is the primary purpose of saving the CPU state at the start of an interrupt?
📖 Explanation: Saving the CPU state preserves the registers, program counter, and flags of the currently running task, so the interrupt handler can run and later restore the original context (option B). Option A is unrelated to state saving. Option C describes a reset, which would discard the current task. Option D concerns device operation, not CPU context. Maintaining the saved state ensures the interrupted program resumes correctly after the handler finishes.