0

From http://haifux.org/lectures/86-sil/kernel-modules-drivers/node10.html

A Character ('c') Device is one with which the Driver communicates by sending and receiving single characters (bytes, octets).

A Block ('b') Device is one with which the Driver communicates by sending entire blocks of data.

Examples for Character Devices: serial ports, parallel ports, sounds cards.

Examples for Block Devices: hard disks, USB cameras, Disk-On-Key.

Do "serial ports, parallel ports" mean serial communication and parallel communication over wires?

Do "serial ports" or "parallel ports" apply to character devices only, but not to block devices?

Thanks.

  • in the days from before USB,a serial port was what you attached modems or terminals with. Parallel ports were the common way to attach printers to a system. They both dealt with characters one at atime – infixed Oct 2 '18 at 18:09
  • Thanks. What about nowadays or after USB? – Tim Oct 2 '18 at 18:10
  • There have been a lots of serialized buses taking over functions that used to be parallel buses. Things like I2C, SATA, or PCI/e as well as USB. But your quote is really referring to the older sort of serial port. a character by character I/O device – infixed Oct 2 '18 at 18:16
  • And just to add to the confusion, you can get USB serial ports that allows one to talk to the older type serial devices from a USB port – infixed Oct 2 '18 at 18:17
  • Yes, I am confused even more. – Tim Oct 2 '18 at 18:25
2

A "character device" and "block device" are abstractions, usually used in Unix-style systems in classifying various devices. A Unix-style device node (/dev/<something>) is usually classified as either a character device or a block device.

Basically, a character device can meaningfully process data even a single byte at a time, but a block device works with blocks of specific size (often 512, 1024 or 4096 bytes). If you supply an incomplete block to a block device, you may have to pad it with zeroes or other suitable padding to complete the block, or else the block device may not be able to complete its operation.

Disks are usually represented as block devices in Unix-style systems. However, in a traditional Unix system, a single disk may be represented as two devices: a block device for regular filesystem access, and another device for "raw access" and other special operations: the raw access device is often a character device.

In modern Linux, raw access can be achieved by opening the regular block device using an O_DIRECT flag, but if an application that is ported from another Unix-style system specifically requires a dedicated raw device, one can be set up as needed using the raw command.

Serial and parallel ports, on the other hand, usually refer to physical connection tehcnologies.

In PC hardware, serial port or COM port normally refers to a RS232 port (usually with a National Semiconductor 8250-compatible UART chip driving it). Since it does not need a fixed block size, it is normally classified as a character device in Unix systems. As the name serial port implies, this port transfers data serially, one bit at a time. The most modern specifications for this port are known as EIA/TIA-232.

Likewise in PC hardware, parallel port, printer port, LPT port or Centronics port all refer to a type of port whose most modern implementation is standardized as IEEE 1284. It is also represented as a character device in Unix-style systems, since it requires no fixed block size. As the name implies, it transfers data in parallel: it has 8 data lines, one for each bit in a byte.

Unlike the serial port, the parallel port in its oldest form is basically one-way: the computer can send data out one byte at a time, but the device on the other end has only a few fixed-meaning status lines it can use to communicate back to the computer. (An invalid state combination of these status lines was reported by early versions of Linux kernels as a semi-humorous lp<n> on fire error message.) Bi-directional communication modes were implemented as later enhancements.

Before the introduction of USB, the parallel port was probably the fastest general-purpose external connector on a typical PC. If external devices with faster data transfer speeds were needed, it often meant adding a dedicated interface card, or a SCSI adapter card with an external connector to the system. For example, a professional flatbed image scanner was likely to require a SCSI connection.

  • Thanks. "A "character device" and "block device" are abstractions, usually used in Unix-style systems in classifying various devices." Is block device a concept of purely hardware (either device or device controller), independent of file system or operating system? Or is it a concept of both hardware and either filesystem or operating system? – Tim Oct 4 '18 at 3:23
  • You probably should post that as a separate question. – telcoM Oct 4 '18 at 7:21
3

While there are often several kinds of interconnects on modern computers, such as USB, SATA, and PCI/e that are technically serial (even when controlling block style devices), the text you quote is more in the context of parallel and serial as it was first used in 20th century computing.

They refer to methods used to interconnect computers to peripherals, or sometimes, other computers.

While there are many variations, the most common 'serial port' was a I/O device that sent and/or received one character at a time, commonly using asynchronous protocol at a fixed baud rate. Usually via a RS232 cable. The terms serial port and RS232 port were sometimes used interchangeably, although a misnomer because RS-232 is actual an electrical standard. A common application was to attach user terminals to a computer, or modems that users could dial-in on and connect remote terminals with. There can date back to electro-mechanical days, such as the 110 baud ASR-33 teletype, the source of the string 'tty' often seen in unix commands and device file names.

Serial ports were fairly slow, so for uses that needed a higher character rate, it was possible to use a parallel port that wasn't serialized. This was sometimes referred to a printer manufacturer who made it popular as a "Centronix" port.

Not to say there weren't printers that used a serial connection.

But as used in your quote, serial port and parallel port refers to these two peripheral connection schemes.

So even though block style devices may be technically connected at some low level with a serial data method, that's not what that writer is referring to,

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.