Block-Oriented Devices vs. Stream-Oriented Devices

Abstract

In computing system, data is transferred in a sequence of bytes called block. Most file systems are based on block devices where data is stored and retrieved in blocks of bytes. Since the files length (size) usually occupies multiples of block size, and as such; a single block may only contains a part of a single file, such scenario in most of the times lead to internal fragmentation. On the other hand character devices transmit data one character at a time. Such devices provide a stream of communication. Also, with such devices, buffering mechanism is not required, and such devices usually read and write character immediately (Silberschatz and Galvin, 2009).

The operating system as well as applications such as database management systems may prefer to access a block device as a simple array of blocks. Such mode of data access is sometimes called raw I/O. If such application is implementing a buffering mechanism, the file system would use an extra unnecessary buffering. Modern operating systems avoid such conflict by disabling buffering and locking when there is an operation that required access to a file. Also, memory-mapped file access can be layered on top of the device drivers to allow a memory-mapped interface, and to allow access to the disk storage via an array of bytes rather than offering the read and write operations. On the other hand, a character stream is used as linear stream bytes that can be more convenient for input devices such as modems, keyboards, mice and output devices such as printers and audio boards (Dhamdhere, 2006).

Block-Oriented devices vs. Stream-Oriented devices

Galli (1999) explained that the block devices are usually storage devices that provide reading and writing operation of data in fixed-size blocks. Some examples of such devices are: hard drives, floppy disks, and optical drives such as DVD-ROM, and CD-ROM. Blocking devices are usually reading or writing the entire block at a time. Also, most of the file systems are based on the block devices. The advantage of the block devices is the fact that it provides fewer pins to access data; however, it requires a buffering mechanism to be implemented to speed up the access during the read and write access. Also, block devices can only accept input and output in blocks (the size of such blocks vary based on the device requirements).

Silberschatz and Galvin (2009) explained that character (Stream) devices are allowed to use few bytes in its operations. Also buffering is not required for such devices, and as such; the response time and the processing speed is faster than the block devices. On the other hand, in the blocking devices, memory access is required for file access, where the files need to be mapped in memory, and the speed difference between the memory and the block devices can create performance problems. One solution for such problem is providing the kernel caching. Such caching implementation makes the block-devices almost unusable and that lead to increasing the I/O processing.

The main advantage of character devices is that the I/O can be done directly between the device and the user and as such; the kernel is saved from copying operation and the overhead of buffering mechanisms. Such process can be done through a Direct Memory Access (DMA). However, such advantage is almost impossible to be achieved since DMA is limited with 64K boundary. Also, streaming devices used less memory than the block devices, since the stream devices required less data to be processed at a time while block devices required an access to a block of data at a time (Marshall, 2001).

Finally, it’s more efficient to use the stream-oriented devices since buffering is not required, and also the efficiency problems that can be created by the buffering devices such as fragmentation, and the conflict with the operating system file system buffering mechanism can be eliminated with such devices.

Conclusion

All I/O devices are classified as either character or block devices. With block devices data is transferred in a block of bytes and required a buffering mechanism to allow faster input and output operations. Also, block devices accept input and output only in blocks. On the other hand, character devices (also called stream of bytes devices) transfer data in a few streams of bytes. Such devices don’t required buffering mechanism, and they don’t operate with a fixed block size (Marshall, 2001).

References

Dhamdhere, D. (2006) Operating Systems: A concept-based Approach. 2nd ed.London: McGraw Hill Higher Education.

Galli, D. (1999) Distributed Operating Systems: Concepts and Practice. 1st ed. NY:Prentice Hall.

Marshall, D. (2001) Multimedia Systems [Online]. Available from: http://www.cs.cf.ac.uk/Dave/Multimedia/node12.html (Accessed: 04 September 2010).

 Silberschatz, A. & Galvin, P. (2009) Operating System Concepts. 8th ed. NJ: John Wiley & Sons, Inc.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: