O que é um dispositivo de caractere?

7

Eu estava tentando fazer uma partição na minha unidade USB quando me deparei com alguns arquivos / entidades em /dev/ que pareciam não familiares (como hidraw2 ). Quando abri / dev no gerenciador de arquivos e examinei suas propriedades, ele diz que eles são character devices . Enquanto pesquisava sobre eles, encontrei mensagens que explicam o que são 'dispositivos de bloqueio', mas até agora não há postagens para dispositivos de caracteres.

Eu gostaria de saber o que é um dispositivo de personagem e o que ele faz. Também me pergunto por que eles são chamados de dispositivos.

    
por NurShomik 02.04.2018 / 20:44

1 resposta

10

Esta é uma explicação simples:

  • 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.
  • For the user, the type of the Device (block or character) does not matter - you just care that this is a hard disk partition or a sound card.
  • Driver programmers, however, do care.

Aqui está mais:

16.1.4.2 Block and Character Devices A block device is one that is designed to operate in terms of the block I/O supported by Digital UNIX. It is accessed through the buffer cache. A block device has an associated block device driver that performs I/O by using file system block-sized buffers from a buffer cache supplied by the kernel. Block device drivers are particularly well-suited for disk drives, the most common block devices.

A character device is any device that can have streams of characters read from or written to it. A character device has a character device driver associated with it that can be used for a device such as a line printer that handles one character at a time. However, character drivers are not limited to performing I/O a single character at a time (despite the name ''character'' driver). For example, tape drivers frequently perform I/O in 10K chunks. A character device driver can also be used where it is necessary to copy data directly to or from a user process. Because of their flexibility in handling I/O, many drivers are character drivers. Line printers, interactive terminals, and graphics displays are examples of devices that require character device drivers.

Fontes:

link

link

    
por George Udosen 02.04.2018 / 21:01