Character and Block Mode Devices
Many devices which are attached to the system which is running on Linux are treated as a device by the OS. That does not matter whether the device is a terminal, a hard disk, a printer, a modem, or a CD-ROM drive. Everything that accepts or sends data to the operating system is a device.
The concept of treating anything on the system as a device is one of the advantage of the UNIX architecture. Every device has a special section in the kernel, known as a device driver that involves all the instructions necessary for Linux to communicate with the device. Whenever a new device is developed, that device can be used with Linux through writing a device driver that is commonly a set of instructions which explains about ways to send and receive data.
Device drivers permit the Linux kernel to involve only the operating system and support software. Through having the instructions for talking to devices inside a set of files, they can be loaded as required (in the case of infrequently-used devices), or kept in memory all the time when the OS boots. As refinements are made to a peripheral, small modifications to the device driver file can be linked to the kernel to keep the OS informed of the new characteristics and capabilities.
The Linux kernel goes by the request to the device driver and permits it to handle the communications when an application instructs a device to perform an action.
Linux keeps device files in the /dev directory convention and by default. It is permissible to keep device files wherever on the file system, but keeping them all in /dev makes it obvious in which they are device files.
Every category of device on the Linux system communicates in one of the two ways: character via character or as a set of data in a predefined chunk or block. Asynchronous modems, printers, and Terminals are character devices, by using characters sent one at a time and echoed through the other end. A Hard drives and most tape drives, alternatively, use blocks of data, since this is the fastest way to send huge chunks of information. These peripherals are known as either character mode or block mode devices those are based on the mode of communication.
Note: Another way to make different among character and block mode devices is through the way in that buffering to the device is handled. A Character mode device does there own buffering. Block mode devices that commonly communicate in 1,024 bytes or chunks of 512, have the kernel perform the buffering. A few devices can be both character and block mode devices. Some tape drives, for instance, can handle both character and block modes, and thus have two variant device drivers. The device driver which is used depends on how the user needs to write data to the device.
The device file has all the details about whether the device is a character mode or block mode device. There is a simple way to search out the type of device of a peripheral. The output of the listing command displays file permissions (such as ls -l). If the first character is a b, the device is a block mode device; a c denotes a character mode device.
Device files are commonly named to denote the category of device. Most terminals, for instance, have a device driver within the name tty followed through two or more letters or numbers, like as tty1, tty1A, or tty04. The letters tty identify the file as a terminal (tty stands for teletype) and the numbers or letters recognized the specific terminal referred to. Whenever coupled with the directory name /dev, the full device driver name should /dev/tty01.