---
title: "Device-independent I/O software with example"
subject: "Operating System"
chapter: 6
key: "semester_6/operating_system:device-independent-io-software-example"
source: https://www.bctengineer.com/q/semester_6/operating_system/device-independent-io-software-example
site: BCT Engineering
---

# Device-independent I/O software with example

Operating System · Chapter 6: I/O Management and Disk Scheduling

- Asked in: year not given
- Video: [6.04 - Device Independent IO Software](https://www.youtube.com/watch?v=sA_m4F7Fhpc) — Darshan University
- Answer checked by Claude Opus 5.5 (high effort) on 2026-10-14
- Page: https://www.bctengineer.com/q/semester_6/operating_system/device-independent-io-software-example
- Whole chapter: https://www.bctengineer.com/md/semester_6/operating_system/chapter-6

## Question

Explain about 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.

## Answer

**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
| Function | Meaning |
|---|---|
| Uniform interfacing for drivers | All drivers present the same set of functions (open, read, write) to the kernel |
| Buffering | Data is held in kernel buffers to match device and process speeds |
| Naming | Devices get path names, e.g. `/dev/tty0`, `/dev/sda` |
| Protection | Permissions decide who may use a device |
| Device-independent block size | Disks with different sector sizes appear to have one logical block size |
| Error reporting | Errors that drivers cannot handle are reported to upper layers |
| Allocating/releasing dedicated devices | Devices such as printers and tapes are given to one process at a time (open fails if busy) |
| Storage allocation | Free 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.

## Check yourself

The answer's key points as multiple-choice questions, with the correct option and why.

1. What does uniform interfacing for drivers allow?
   A. Drivers need no code
   B. A new device can be added by writing only a driver, without changing the OS
   C. Applications must be rewritten for each device
   D. Only one driver can exist
   Answer: B. All drivers present the same functions, so the rest of the OS stays unchanged. (Key point: Uniform interfacing)

2. In UNIX, what do major and minor device numbers do?
   A. Major selects the driver; minor selects the unit
   B. Major selects the unit; minor selects the driver
   C. Both select the file system
   D. Major sets permissions; minor sets block size
   Answer: A. /dev/lp0 maps to the printer driver (major) and a particular printer (minor). (Key point: Major and minor numbers)

3. Why provide a device-independent block size?
   A. To make all disks the same physical size
   B. To avoid buffering
   C. To hide different sector sizes by presenting one logical block size
   D. To speed up interrupts
   Answer: C. Higher layers see uniform logical blocks regardless of disk sectors. (Key point: Device-independent block size)

4. Why can sort read from a keyboard or from a file?
   A. sort has separate code for each
   B. Keyboards are files on disk
   C. sort rewrites the driver
   D. Redirection works because I/O is device independent
   Answer: D. sort < data.txt shows the same program works with different devices. (Key point: Redirection)

## Related in Operating System

- [Programmed I/O, DMA, device-independent software](https://www.bctengineer.com/question.md?key=semester_6%2Foperating_system%3Aprogrammed-io-dma-device-independent) — Operating System, chapter 6
- [Disk scheduling; device-independent I/O software](https://www.bctengineer.com/question.md?key=semester_6%2Foperating_system%3Adisk-scheduling-device-independent-io) — Operating System, chapter 6
