written 3.1 years ago by |
I/O management in Unix
There are two main categories of I/O units in UNIX, block devices and character devices.
In addition, there are sockets that are used for network communication.
Block devices
• Devices that address blocks of a fixed size, usually disk memories.
• Data blocks are buffered in the buffer cache.
• Block devices are usually called via the file system, but are also available as special files (for example /dev/hde1).
Character devices
• Terminals and printers, but also everything else (except sockets) that do not use the block buffer cache.
• There are for example /dev/mem that is an interface to physical memory.
• Device drivers are called via a switch table.
• There is one switch table for block devices and one for character devices.
• A hardware device is identified by its type (block or character) and a device number.
• Device numbers consist of two parts: major device number and minor device number.
• Major device number is used as an index in the switch table to locate the correct device driver.
• Minor device number is forwarded to the device driver and used to select the correct subunit. (For example correct file system partition if the disk is divided into several partitions).