In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-14 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)05/31 Report--
Today, the editor will share with you the relevant knowledge about what the linux character device is. The content is detailed and the logic is clear. I believe most people still know too much about this knowledge, so share this article for your reference. I hope you can get something after reading this article. Let's take a look at it.
Linux character devices are: 1, the mouse is a kind of external input device of the computer, and it is also an indicator of the vertical and horizontal coordinate positioning of the computer display system; 2, the keyboard is a kind of instruction and data input device used to operate the computer equipment; 3, the serial port terminal, the terminal equipment connected by the computer serial port; 4, the control terminal; 5, the console, etc.
The operating environment of this tutorial: linux5.9.8 system, Dell G3 computer.
For ease of management, the Linux system divides devices into three basic types:
Character equipment
Block equipment
Network equipment
They are all displayed as a file node in the / dev directory of the file system (crw--w---- 1 root tty 4, July 11 09:11 tty0 where c represents the character device type).
Linux character device
Character device refers to the device that can read and write directly without buffer, such as mouse, keyboard, serial port device, modem and so on. The difference between character device and block device is that the basic unit of character operation is bytes.
Classification of character devices
Character devices mainly include control terminal devices and serial terminal devices, such as console and keyboard. According to the differences in function and hardware, character terminal devices can be classified as follows:
Serial port terminal (/ dev/ttSn): a terminal device connected by a computer serial port. The data of the serial device is transmitted by 8 bit lines of the same character. Enter echo 'hello world' > / dev/ttyS0 on the command line to write the input to the corresponding device.
Pseudo terminal (/ dev/ttyp,/dev/ptyp): there is no real hardware device corresponding to the underlying layer, which is used to provide a terminal-style interface for other programs, such as the terminal interface between the network server and the shell program when the network logs in to the host.
Control terminal (/ dev/tty): the main setting number is 5, and the process control terminal is associated with the process, for example, the terminal / dev/tty is used to log in to the shell process.
Console (/ dev/ttyn,/dev/consol): a display of computer input and output that uses tty1 when the console logs in, while tty7 is used in the ubuntu graphical interface.
Other types: the current linux has many other kinds of device-specific files for many different devices, such as ISIDIN devices / dev/ttyIn devices.
The following is a schematic diagram of the structure of the character device
The nature and characteristics of character equipment
Character device is a kind of device file system, which is equivalent to the logical device file provided by the underlying hardware to the upper layer, just like docking a data port (data register) with a file, and the device driver operates on the file directly. so the port is read and written directly. Also as a file, the character device driver must also implement the basic file operations such as open (), close (), write (), read (), etc., of course, terminal redirection operations are also supported.
The read and write of character device file is in single byte, so there is no need to set up hardware buffer. The device is accessed by the operating system like a byte stream. Byte flow is like building a transmission pipeline between the hardware port and the file system, and bytes are transmitted one by one through the pipeline and presented to both the reader and the writer. This flow feature is implemented as a buffer queue in the driver. For example, the read-write buffer queue in the structure of the console
Struct tty_struct {struct termios termios;int pgrp;int stopped;void (* write) (struct tty_struct * tty); struct tty_queue read_q; / / read queue struct tty_queue write_q; / / write queue struct tty_queue secondary; / / tty auxiliary queue (store normalized characters)}
The character device is identified by the character device number. The character device number consists of a primary device number and a secondary device number, for example, the device number of / dev/ttyS0 corresponds to the driver; the primary device number identifies the device corresponding to the driver, and the kernel corresponds the device to the driver one by one through the primary device number, and the secondary number is used by the driver to distinguish the difference between device details within the driver, and the rest of the kernel does not use it.
These are all the contents of the article "what is a linux character device?" Thank you for reading! I believe you will gain a lot after reading this article. The editor will update different knowledge for you every day. If you want to learn more knowledge, please pay attention to the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.