当前位置:网站首页>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
边栏推荐
- Application of JDBC in performance test
- The first exposure of Alibaba cloud's native security panorama behind the only highest level in the whole domain
- Final review and key points of software process and project management
- 2021-03-16 COMP9021第九节课笔记
- OpenCV get(propId) 常用的值
- Introduction to software engineering - Chapter 2 - feasibility study
- 问题4 — DatePicker日期选择器,2个日期选择器(开始、结束日期)的禁用
- VR is destined to reappear in the Jianghu?
- transformers PreTrainedTokenizer类
- 自动化测试的未来趋势
猜你喜欢

List of Li Bai's 20 most classic poems

根据网络上的视频的m3u8文件通过ffmpeg进行合成视频

2022茶艺师(中级)上岗证题库及在线模拟考试

2021-03-09 COMP9021第七节课笔记

C language_ Love and hate between string and pointer

OC extension detects whether an app is installed on the mobile phone (source code)

Question 3 - MessageBox pop-up box, modify the default background color

2021-03-16 comp9021 class 9 notes

一文带你了解Windows操作系统安全,保护自己的电脑不受侵害

The first exposure of Alibaba cloud's native security panorama behind the only highest level in the whole domain
随机推荐
软件过程与项目管理期末复习与重点
Utilisation de la fermeture / bloc de base SWIFT (source)
对于flex:1的详细解释,flex:1
Simple summary of lighting usage
Swift 基础 闭包/Block的使用(源码)
工控机防破解
pyQt 常用系统的事件
【点云数据集介绍】
Question bank and simulation examination for operation certificate of refrigeration and air conditioning equipment in 2022
App Startup
Chart list Performance Optimization: minimum resource consumption in the visualization area
一文带你了解Windows操作系统安全,保护自己的电脑不受侵害
All you know is the test pyramid?
MAYA重新拓布
487. 最大连续1的个数 II ●●
pyQt 中 QMenu 响应
Swift 基礎 閉包/Block的使用(源碼)
JVM underlying principle analysis
2021-03-16 COMP9021第九节课笔记
Écouter le réseau d'extension SWIFT (source)