当前位置:网站首页>5-1 blocking / non blocking, synchronous / asynchronous
5-1 blocking / non blocking, synchronous / asynchronous
2022-07-03 14:49:00 【III VII】
Blocking / Non blocking 、 Sync / asynchronous
A typical time IO What are the two stages of ? Data ready and Data reading and writing
Data ready : According to the system IO Ready state of the operation
Blocking
Non blocking
Data reading and writing : Depending on how the application interacts with the kernel
Sync
asynchronous 
Sync : After function call , After getting the program result , Immediately proceed ( It takes the time of the program );
Example : Buy air tickets , Take a taxi to the airport to get your ticket ( This action takes your own time );
Programming is relatively simple ;
asynchronous : asynchronous IO Interface (sockfd,buf, Inform the way ( It's usually sigio The signal )), Need notification , Don't wait for the program to call the function to return the result , Wait for the operating system ( kernel ) Put data into buf In , Notify the program to process the result of the function call ;
Example : After buying the ticket , The courier will send the ticket from the airport to his home ( It takes someone else's time )
A typical network IO Interface call , There are two stages , Namely “ Data ready ” and “ Data reading and writing ”, The data ready phase is divided into blocking and non blocking , The result is , Block the current thread or return directly .
Synchronization means A towards B Request to call a network IO Interface ( Or call some business logic API Interface ), The data is read and written by the requestor A Do it yourself ( Whether it's blocked or not ); Asynchronous representation A towards B Request to call a network IO Interface ( Or call some business logic API Interface ), towards B The event of the incoming request and the way of notification when the event occurs ,A You can handle other logic , When B After listening to the completion of event processing , Will be notified in advance , notice A Processing results .
边栏推荐
- Several sentences extracted from the book "leather bag"
- tonybot 人形機器人 紅外遙控玩法 0630
- Yolov5进阶之七目标追踪最新环境搭建(二)
- [graphics] real shading in Unreal Engine 4
- puzzle(016.4)多米诺效应
- Optical cat super account password and broadband account password acquisition
- Sub GHz wireless solution Z-Wave 800 Series zg23 SOC and zgm230s modules
- 关于敏捷的一些概念
- How to query the baby category of tmall on Taobao
- cpu飙升排查方法
猜你喜欢

Qt development - scrolling digital selector commonly used in embedded system

How to query the baby category of tmall on Taobao

Creation of data table of Doris' learning notes

puzzle(016.4)多米诺效应

Niuke: crossing the river

US stock listing of polar: how can the delivery of 55000 units support the valuation of more than 20billion US dollars

puzzle(016.3)千丝万缕
![[graphics] real shading in Unreal Engine 4](/img/8d/53775c7570c5578f4fe985592bb305.jpg)
[graphics] real shading in Unreal Engine 4

tonybot 人形機器人 紅外遙控玩法 0630

Tonybot humanoid robot checks the port and corresponds to port 0701
随机推荐
Sub GHz wireless solution Z-Wave 800 Series zg23 SOC and zgm230s modules
牛客 BM83 字符串变形(大小写转换,字符串反转,字符串替换)
Luogu p5536 [xr-3] core city solution
2021-10-16 initial programming
QT - draw something else
Detailed explanation of four modes of distributed transaction (Seata)
retrofit
Zzuli:1053 sine function
406. 根据身高重建队列
洛谷P4047 [JSOI2010]部落划分 题解
[opengl] advanced chapter of texture - principle of flowmap
Dllexport et dllimport
CentOS7部署哨兵Redis(带架构图,清晰易懂)
Bibit pharmaceutical rushed to the scientific innovation board: annual revenue of 970000, loss of 137million, proposed to raise 2billion
Implement Gobang with C language
Zzuli:1054 monkeys eat peaches
How to query the baby category of tmall on Taobao
远程服务器后台挂起 nohup
Zzuli:1056 lucky numbers
Zzuli:1041 sum of sequence 2