Three types of devices in LINUX

Source: Internet
Author: User
Three types of LINUX devices-general Linux technology-Linux programming and kernel information. For more information, see the following. LInux-based devices can be divided into three basic device types. each module can be categorized into character modules, block modules, or network modules. this way of dividing modules into different types or categories is not fixed; programmers can choose to build a huge module with different drivers in a large block of code. however, good programmers often create different modules for each of them to implement new features, because decomposition is a key factor in scalability and scalability.

Character Device

A character (char) device is a device that can be accessed as a byte stream (like a file). A character driver is responsible for such behavior. such drivers often implement at least open, close, read, and write system calls. the text console (/dev/console) and serial port (/dev/ttyS0 and their friends) are examples of character devices because they demonstrate stream abstraction well. character devices are accessed through file system nodes. For example,/dev/tty1 and/dev/lp0. the only difference between a character device and a common file is that, you can often move in common files, but most character devices are only data channels, and you can only access them in sequence. however, there are character devices that look like data areas. You can move them in. for example, frame grabber is often used in this way, applications can use mmap or lseek to access the entire requested image.

Block Device

Like character devices, Block devices are accessed through file system nodes in the/dev directory. A block device (such as a disk) should be resident in a file system. in most Unix systems, a block device can only process such I/O operations, and transmits one or more 512 bytes (or a larger 2 power). linux, on the contrary, allows an application to read and write a block device like a character device-it allows a single transmission of any number of bytes. the result is that the difference between a block and a character device is only in the way the kernel manages data internally, and therefore it is different in the kernel/driver software interface. like a character device, each block device is accessed through a file system node, and the difference between them is transparent to users. compared with the character driver, the block driver is completely different from the kernel interface.

Network Interface

Any network transaction is performed through an interface, that is, a device that can exchange data with other hosts. generally, an interface is a hardware device, but it may also be a pure software device, such as a loopback interface. A network interface is used to send and receive data packets. Driven by the kernel network subsystem, you do not have to know how a single transaction maps to the actually sent packets. many network connections (especially those using TCP) are stream-oriented, but network devices are often designed to send and receive packets. A network driver knows nothing about a single connection; it only processes packets.
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.