The three classes of devices and modules
2010-05-13 08:44
375 查看
Character
devices
A
character (char) device is one that can be
accessed as a stream of bytes (like a file); a
char
driver is in charge of implementing this
behavior. Such a driver usually implements at least the open
, close
, read
, and write
system
calls. The text console (/dev/console
) and the serial ports
(/dev/ttyS0
and friends) are examples of char devices, as they are well
represented by the stream abstraction. Char devices are accessed by means of
filesystem nodes, such as /dev/tty1
and /dev/lp0
. The only relevant difference between a char
device and a regular file is that you can always move back and forth in the
regular file, whereas most char devices are just data channels, which you can
only access sequentially. There exist, nonetheless, char devices that look like
data areas, and you can move back and forth in them; for instance, this usually
applies to frame grabbers, where the applications can access the whole acquired
image using mmap
or lseek
.
Block devices
Like char devices,
block devices are accessed by filesystem
nodes in the /dev
directory. A block device is a device (e.g., a disk)
that can host a filesystem. In most Unix systems, a block device can only handle
I/O operations that transfer one or more whole blocks, which are usually 512
bytes (or a larger power of two) bytes in length. Linux, instead, allows the
application to read and write a block device like a char device
—it permits the
transfer of any number of bytes at a time. As a result, block and char devices
differ only in the way data is managed internally by the kernel, and thus in the
kernel/driver software interface. L
ike a char device, each block device is
accessed through a filesystem node, and the difference between them is
transparent to the user. Block drivers have a completely different interface to
the kernel than char drivers.
Network
interfaces
Any network transaction is
made through an interface, that is, a
device that is able to exchange data with other hosts. Usually, an
interface
is a hardware device, but it might also be a pure software
device, like the loopback interface. A network interface is in charge of sending
and receiving data packets, driven by the network subsystem of the kernel,
without knowing how individual transactions map to the actual packets being
transmitted. Many network connections (especially those using TCP) are
stream-oriented, but network devices are, usually, designed around the
transmission and receipt of packets.
A network driver knows nothing about
individual connections; it only handles packets.
devices
A
character (char) device is one that can be
accessed as a stream of bytes (like a file); a
char
driver is in charge of implementing this
behavior. Such a driver usually implements at least the open
, close
, read
, and write
system
calls. The text console (/dev/console
) and the serial ports
(/dev/ttyS0
and friends) are examples of char devices, as they are well
represented by the stream abstraction. Char devices are accessed by means of
filesystem nodes, such as /dev/tty1
and /dev/lp0
. The only relevant difference between a char
device and a regular file is that you can always move back and forth in the
regular file, whereas most char devices are just data channels, which you can
only access sequentially. There exist, nonetheless, char devices that look like
data areas, and you can move back and forth in them; for instance, this usually
applies to frame grabbers, where the applications can access the whole acquired
image using mmap
or lseek
.
Block devices
Like char devices,
block devices are accessed by filesystem
nodes in the /dev
directory. A block device is a device (e.g., a disk)
that can host a filesystem. In most Unix systems, a block device can only handle
I/O operations that transfer one or more whole blocks, which are usually 512
bytes (or a larger power of two) bytes in length. Linux, instead, allows the
application to read and write a block device like a char device
—it permits the
transfer of any number of bytes at a time. As a result, block and char devices
differ only in the way data is managed internally by the kernel, and thus in the
kernel/driver software interface. L
ike a char device, each block device is
accessed through a filesystem node, and the difference between them is
transparent to the user. Block drivers have a completely different interface to
the kernel than char drivers.
Network
interfaces
Any network transaction is
made through an interface, that is, a
device that is able to exchange data with other hosts. Usually, an
interface
is a hardware device, but it might also be a pure software
device, like the loopback interface. A network interface is in charge of sending
and receiving data packets, driven by the network subsystem of the kernel,
without knowing how individual transactions map to the actual packets being
transmitted. Many network connections (especially those using TCP) are
stream-oriented, but network devices are, usually, designed around the
transmission and receipt of packets.
A network driver knows nothing about
individual connections; it only handles packets.
相关文章推荐
- How to create fully custom Role, User, Event, Resource classes for use with the Security and Scheduler modules
- The Rule of Big Three and half: Copy-and-swap Idiom
- Effective Java 13 Minimize the accessibility of classes and members
- Development and remote installation of Java service for the Android Devices
- Representing and Recognizing the Visual Appearance of Materials using Three-dimensional Textons部分翻译
- Nasm Intro - The Three Kinds of Operands & Conditional Instructions
- Bob Tarr: Some Object-Oriented Design Principles(1): Minimize The Accessibility of Classes and Members
- The Game API package provides a series of classes that enable the development of rich gaming content for wireless devices.
- Effective Java 英文 第二版 读书笔记 Item 13:Minimize the accessibility of classes and members
- CXF报错[1 counts of IllegalAnnotationExceptions]and[Two classes have the same XML type name]and[Use @XmlType.name and @XmlType.namespace to assign different names to them]
- Define a procedure that takes three numbers as arguments and returns the sum of the squares of the two larger numbers
- the dependency of sysgen variables, and how to map sysgen to modules
- DropBand:A Simple and Effective Method for Promoting the VHR Scene Classification Accuracy of CNN
- A Christmas Carol——2、The first of the three spirits
- OpenCv,EmguCv及.net之间的互动(The Interaction of OpenCv, EmguCv AND .net)
- Comparison of Germany and China, the industry 4.0 strategy and approach for China 中德比较以及中国工业4.0策略和手段
- Heap Verifier Stops in Appverifier and The Structure of a Page Heap Block
- The City of Death and Life
- 【笔记】Inception-v4, Inception-ResNet and the Impact of Residual Connections on Learning
- Step by Step Installation of the Subversion 1.x Server for Linux and Solaris 8/9/10 (English)