Saturday, March 23, 2013

UNIX Files

Regular files contain byte of data, organized in a linear array called a byte stream.  There is no further structure (e.g. record) imposed on the top of the stream.

Special files are kernel onkects that are represented as files.  Linux supports 4 special files - block device files, character device files, named pipes, and UNIX domain sockets.  Special files are a way to let certain abstractions fit into the filesystem.

Device access in UNIX is performed via device files which look like a file residing in filesystem.  Character device is accessexd as a linear queue of bytes.  The device driver places bytes onto the queue for user process to read in same order.  Block devices are accessed as am array of bytes and can be access by random order.

Named pipes (aka FIFO) are IPC mechanism to provide a communication channel over a file descriptor accessed via a special file.

Sockets are an advanced form of IPC that allow communication within a machine or across machines.  UNIX domain sockets ises a special file (called socket file) residing in filesystem.

UNIX uses a unified name space (root = /) while other OS use separate name space (e.g. C:, D:)

No comments: