The editor in this article will introduce in detail the types of devices in the linux system. The content is detailed, the steps are clear, and the details are handled properly. I hope this article on the types of devices in the linux system can help you solve your doubts. Follow the editor's instructions below Slowly deepen your thinking, let's learn new knowledge together.
The devices in the Linux system are divided into three categories: 1. Character devices are devices that can be accessed like byte streams. Request, the corresponding IO operation occurs immediately; 2, block device, is the device that must be accessed in units of blocks when performing TO operations in the Linux system, and the block device can install the file system; 3, network device, by the network subsystem of Linux The driver is responsible for the sending and receiving of data packets, rather than stream-oriented devices, so there are no nodes for network devices in the Linux system file system.
Devices in the Linux system
The devices in the Linux system can be divided into three categories: character devices, block devices and network devices.
(1) Character device
A character device is a device that can be accessed like a byte stream. When a read or write request is made to a character device, the corresponding The IO operations happen immediately. Many devices in the Linux system are character devices, such as character terminals, serial ports, keyboards, and mice. In the development of embedded Linux, character devices and drivers are the most contacted.
(2) Block device
A block device is a device that must be accessed in units of blocks when performing TO operations in the Linux system. Block devices can be installed File system. The block device driver will use a piece of system memory as a buffer, so issuing read and write access to the block device does not necessarily generate hardware I/O operations immediately. Common block devices in Linux systems include hard disks, floppy drives, and so on.
(3) Network device
A network device can be a hardware device such as a network card, or a pure software device such as a loopback device. Network devices are driven by the Linux network subsystem, which is responsible for sending and receiving data packets, rather than stream-oriented devices, so there are no nodes for network devices in the Linux system file system. Access to network devices is generated through socket calls, rather than common file operations such as open/closc and read/write.
The status of the driver in linux
The driver is the bridge between the device and the user in the Linux system. In the Linux system, access to the device must be through the device driverManual operation, the user program cannot directly operate the device. The relationship between hardware, drivers and user programs in the Linux system is shown in Figure 2.2.
The driver program runs in the kernel space, the user program can only access and operate the hardware through the system call provided by the kernel, and the data transmitted by the hardware device It must go through the driver, VFS and system calls before it can be received by the user program. Therefore, device drivers are bridges and channels for applications to access system devices and transmit data.
Copyright Description：No reproduction without permission。
Knowledge sharing community for developers。
Let more developers benefit from it。
Help developers share knowledge through the Internet。