当前位置:网站首页>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
边栏推荐
- 2021-03-11 comp9021 class 8 notes
- The applet reads more than 20 data, and the cloud function reads more than 100 restrictions
- Qt导出PDF文件的两种方法
- How to use the virtual clock of FPGA?
- 2021-03-04 COMP9021第六节课笔记
- Optimization and practice of Tencent cloud EMR for cloud native containerization based on yarn
- 3D数学基础[十七] 平方反比定理
- Installation and use of selenium IDE
- 搜索与推荐那些事儿
- PAT 1157:校庆
猜你喜欢

小样本故障诊断 - 注意力机制代码 - BiGRU代码解析实现

Swift 基础 闭包/Block的使用(源码)

For a detailed explanation of flex:1, flex:1

12-- merge two ordered linked lists

2021-03-11 comp9021 class 8 notes

2021-03-11 COMP9021第八节课笔记

独立站运营中如何提升客户留存率?客户细分很重要!

Swift 基础 Swift才有的特性

Pagoda panel installation php7.2 installation phalcon3.3.2

2022 tea artist (intermediate) work license question bank and online simulation examination
随机推荐
[teacher zhaoyuqiang] use the Oracle tracking file
June 27, 2021: given a positive array arr, it represents the weight of several people
Opening chapter of online document technology - rich text editor
[acnoi2022] I have done it, but I can't
Swift 基礎 閉包/Block的使用(源碼)
Small sample fault diagnosis - attention mechanism code - Implementation of bigru code parsing
LabVIEW finds prime numbers in an array of n elements
1279_VMWare Player安装VMWare Tools时VSock安装失败解决
Dart development server, do I have a fever?
Écouter le réseau d'extension SWIFT (source)
RCNN、Fast-RCNN、Faster-RCNN介绍
List of Li Bai's 20 most classic poems
51单片机_外部中断 与 定时/计数器中断
Four models of iPhone 13 series have been exposed, and indeed, they are 13 fragrant!
The article takes you to understand the security of Windows operating system and protect your computer from infringement
5分钟,客服聊天处理技巧,炉火纯青
Introduction to software engineering - Chapter 3 - Requirements Analysis
12-- merge two ordered linked lists
2021-03-16 COMP9021第九节课笔记
C语言_字符串与指针的爱恨情仇