当前位置:网站首页>A preliminary study of IO model
A preliminary study of IO model
2022-06-24 08:25:00 【MrPeng1991】
1. What is? IO
The operating system is responsible for computer resource management and process scheduling . Applications need to go through the operating system , To do some special operations , Such as disk read / write , Memory read / write, etc .
Applications write data to disk , It can only be opened by calling the operating system API To operate .
Applications in user space , There is no real io The process , real io Execute on the operating system , The application initiates once IO The operation consists of two phases :
- IO call : Applications make calls to the operating system kernel
- IO perform : The operating system kernel is complete IO operation
The operating system kernel is complete IO The operation also includes two processes :
- Data preparation stage : Kernel wait I/O Equipment preparation number data
- Copy data phase : Remove data from the kernel buffer , Copy to user process buffer

Actually io Is to transfer the internal data of the process to the external device , Or migrate the data of external devices to the inside of the process . External equipment generally refers to Hard disk ,socket Communication network card . A complete io The process includes these steps
- The application initiates to the operating system io Call request
- The operating system prepares data , hold io Data from external devices , Load into kernel buffer
- The operating system copies data , About the data in the kernel buffer , Copy to user process buffer
3. IO Model
3.1 Blocking io
Know what is io 了 , What is blocking io Well ?
Application process initiation io call , If the kernel data is not ready , The application process has been blocking and waiting , Wait until the kernel data is ready , Copy from kernel to user space , Before returning the success prompt , this io operation , Call it blocking io

shortcoming : Kernel data is never ready , The user process has been blocked , Waste performance ,
3.2 Non blocking io
Kernel data is not ready , You can first return an error message to the user process , So he doesn't have to wait , Instead, request again by polling , This is non blocking io

Non blocking IO The process is as follows :
Application processes to the operating system kernel , launch recvfrom Reading data .
The operating system kernel data is not ready , Return immediately EWOULDBLOCK Error code .
Application process polling calls , Continue to launch... To the operating system kernel recvfrom Reading data .
The operating system kernel data is ready , Copy from kernel buffer to user space .
Completion of invocation , Return to success .
namely NIO, namely non-blocking io,
shortcoming : Relative to blocking io, Although the performance is greatly improved , Frequent polling , Cause frequent system calls , Colleagues consume a lot of cpu resources , You can get zero io Reuse model .
3.3 io Multiplexing
since nio Invalid polling results in cpu resource consumption , When our kernel data is ready , Take the initiative to inform the application process to make system calls again
File descriptor fd File Descriptor, Is a term of computer science , Formally, it is a nonnegative integer , When the program opens an existing file or creates a new file , The kernel returns a file descriptor to the process .
io The core idea of reuse model : The system provides us with a class of functions (select poll epoll), You can monitor multiple fd operation . Any one that returns kernel data is ready , The application process is restarted recvfrom system call
3.3.1 Multiplexing select
The application process calls select function , You can monitor multiple fd, Again
3.4 Signal driven io Model
3.5 io Model asynchronous io
3.6 Blocking Non blocking Sync asynchronous io Divide
4 BIO NIO AIO
https://baijiahao.baidu.com/s?id=1718409483059542510&wfr=spider&for=pc
边栏推荐
- 问题4 — DatePicker日期选择器,2个日期选择器(开始、结束日期)的禁用
- How to use the virtual clock of FPGA?
- Pat 1157: school anniversary
- Nodejs redlock notes
- 12-- merge two ordered linked lists
- 2022 tea artist (intermediate) work license question bank and online simulation examination
- 2021-03-09 comp9021 class 7 Notes
- Swift foundation features unique to swift
- Swift Extension ChainLayout(UI的链式布局)(源码)
- 2022年流动式起重机司机特种作业证考试题库及在线模拟考试
猜你喜欢

2022 mobile crane driver special operation certificate examination question bank and online simulation examination

The article takes you to understand the security of Windows operating system and protect your computer from infringement

How to use the virtual clock of FPGA?

2021-03-04 COMP9021第六节课笔记

直播回顾 | 云原生混部系统 Koordinator 架构详解(附完整PPT)

JUC个人简单笔记

Small sample fault diagnosis - attention mechanism code - Implementation of bigru code parsing

2021-03-16 comp9021 class 9 notes

Longhorn installation and use

io模型初探
随机推荐
51 single chip microcomputer_ External interrupt and timer / Counter interrupt
WPS的JS宏实现图片正文在同一段落的分离方法
FPGA的虚拟时钟如何使用?
Synthesize video through ffmpeg according to m3u8 file of video on the network
【无标题】
transformers PreTrainedTokenizer类
Industrial computer anti cracking
The applet reads more than 20 data, and the cloud function reads more than 100 restrictions
2021-03-11 comp9021 class 8 notes
疫情下更合适的开发模式
The first exposure of Alibaba cloud's native security panorama behind the only highest level in the whole domain
Understanding of the concept of "quality"
Fund raising, trading and registration
新准则金融资产三分类:AMC、FVOCI和FVTPL
12--合并两个有序链表
Scénarios d'utilisation de la promesse
OC extension detects whether an app is installed on the mobile phone (source code)
Getting started with ffmpeg
Application of JDBC in performance test
Analysis of abnormal problems in domain name resolution in kubernetes