Friday, October 3, 2008

What is the benefit of representing device as file?

Devices are represented as special files in UNIX under /dev.  Representing devices as files simplifies the programming model such that all devices can be controlled consistently by 5 system calls - open, close, read, write and ioctl.

Block devices are those that have characteristics similar to disk.  They typically allow random access.  Data are access in unit of blocks.

On the other hands, charcter devices have characteristics similar to terminal.  Access is sequential and data is represented as a stream of bytes.

No comments: