Skip to main content

Device-independent I/O software with example

Short answer

Device-independent I/O software provides uniform driver interface, buffering, naming, protection, and error handling so applications work unchanged across devices. Example: UNIX read() works identically for disk files, terminals, and pipes.

Explain about device independent I/O software with example.

Device-independent I/O software is the layer of the OS above the device drivers. It performs the I/O functions common to all devices and gives user programs a uniform interface, so programs need not change when the device changes.

Functions

FunctionMeaning
Uniform interfacing for driversAll drivers present the same set of functions (open, read, write) to the kernel
BufferingData is held in kernel buffers to match device and process speeds
NamingDevices get path names, e.g. /dev/tty0, /dev/sda
ProtectionPermissions decide who may use a device
Device-independent block sizeDisks with different sector sizes appear to have one logical block size
Error reportingErrors that drivers cannot handle are reported to upper layers
Allocating/releasing dedicated devicesDevices such as printers and tapes are given to one process at a time (open fails if busy)
Storage allocationFree blocks are tracked for block devices

Example

In UNIX, a program calling read(fd, buf, n) works the same whether fd refers to a disk file, a terminal or a pipe. The OS maps the name /dev/lp0 to a major device number (which selects the driver, here the printer driver) and a minor device number (which selects the unit). The same write() call writes to a file, a printer or a USB drive; only the driver changes. Likewise, a sort program can read from the keyboard or from a file, because input can be redirected (sort < data.txt).

Benefit

New devices can be added just by writing a driver; application programs and the rest of the OS stay unchanged.

✓ Answer checked by Claude Opus 5.5 (high effort)

All Operating System chapter 6 questions →