当前位置:网站首页>Principle of device driver
Principle of device driver
2022-06-30 03:08:00 【Where is the autumn wind sad painting fan】
Principle of device driver
Linux And Unix
Linux yes Unix A variant of the operating system , stay Linux The principle and idea of writing driver under is completely similar to other Unix System . stay Linux Environment design driver , Concise thought , It is easy to operate , It's also powerful , But there are few support functions , Can only rely on kernel The function in , Some common operations should be written by yourself , And debugging is not convenient .
Device driver
system call yes Operating system kernels and applications Between Interface , Device driver yes Operating system kernel and machine hardware Between Interface . The device driver is an application Shielding the hardware details , So in the eyes of the application , A hardware device is just a device file , Applications can operate on hardware devices as if they were ordinary files . Device drivers are part of the kernel , Running in a nuclear mindset , It performs the following functions :
- Initialize and release the device .
- Transferring data from the kernel to the hardware and reading data from the hardware .
- Read the data sent by the application to the device file and send back the data requested by the application .
- Detect and handle errors in the device .
Device file type
stay Linux There are three main types of device files under the operating system ︰ Character device 、 Block device and Network interface .
Character device It means in I/O A device that transmits characters during transmission , For example, keyboard , Printers, etc . stay UNIX In the system , The character device occupies a position in the file directory tree in the form of a special file and has corresponding nodes . The character device can use the same file operation command as the normal file to operate the character device file , For example, open 、 close 、 read 、 Writing, etc .
Block device yes I/O One of the devices , Is to store information in fixed size blocks , Each block has its own address , You can also read a certain length of data at any position of the device , For example, hard disk ,U disc ,SD Card, etc .
Network interface Refers to various interfaces of network equipment , The network interfaces we are using today are all Ethernet interfaces . Common Ethernet interface types are RJ-45 Interface ,RJ-11 Interface ,SC Fiber optic interface ,FDDI Interface ,AUI Interface ,BNC Interface ,Console Interface .
Character device and block device The main difference yes : Sending a read to a character device / When writing a request , Actual hardware I/O It usually happens immediately , Block devices are not . It uses a block of system memory as a buffer , When the user process requests the device to meet the user's requirements , Return the requested data . If not , Just call the request function to do the actual I/O operation . Block devices are mainly designed for slow devices such as disks , So as not to consume too much CPU Time to wait .
As mentioned above , User processes interact with actual hardware through device files . Each device file has its file attributes (c/b), Indicates whether it is a character device or a block device . In addition, each file has two device numbers , The first is the main equipment number , Identify the driver . The second is the slave device number , Identify different hardware devices that use the same device driver , For example, there are two floppy disks , They can be distinguished by the slave device number . The master device number of the device file must be consistent with the master device number applied by the device driver at the time of registration , Otherwise, the user process will not be able to access the driver .
Finally, it must be mentioned that , When the user process calls the driver , The system goes into a nuclear mindset , It is no longer preemptive scheduling . in other words , The system must wait until your driver's child functions return .
边栏推荐
- How can redis+aop customize annotations to achieve flow restriction
- Threejs mirror case reflector create mirror + house construction + small ball movement
- Data set preparation and arrangement
- Azure developer news flash list of events of developers in June
- 2. 成功解决 BUG:Exception when publishing, ...[Failed to connect and initialize SSH connection...
- Uniapp address translation latitude and longitude
- 怎么利用Redis实现点赞功能
- 2. successfully solved bug:exception when publishing [Failed to connect and initialize SSH connection...
- HOOK Native API
- Simple custom MVC optimization
猜你喜欢

怎么利用Redis实现点赞功能

prompt learning 一个空格引发的血案

Use of custom MVC

Mysql提取表字段中的字符串

HTA introductory basic tutorial | GUI interface of vbs script HTA concise tutorial, with complete course and interface beautification

What is the concept of string in PHP

GTK interface programming (I): Environment Construction

What are outer chain and inner chain?

General paging (2)

High paid programmers & interview questions series 63: talk about the differences between sleep (), yield (), join (), and wait ()
随机推荐
MySQL extracts strings from table fields
Simulate activity startup mode in compose
可视化HTA窗体设计器-HtaMaker 界面介绍及使用方法,下载 | HTA VBS可视化脚本编写
Mysql表数据比较大情况下怎么修改添加字段
设备驱动程序的原理
GTK interface programming (II): key components
How to set password complexity and timeout exit function in Oracle
Use of custom MVC
Auto. JS learning notes 15:ui interface basics of autojs Chapter 2
在php中字符串的概念是什么
Servlet面试题
备忘一下es6的export/import和类继承的用法
List of development tools
简单自定义mvc
Raki's notes on reading paper: discontinuous named entity recognition as maximum clique discovery
Link garbled escape character
Problem record: FEL_ lib. c:26:10: fatal error: libusb. h: There is no such file or directory
Software testing skills, JMeter stress testing tutorial, transaction controller of logic controller (25)
链接乱码转义符
自定义JvxeTable的按钮及备注下$set的用法