当前位置:网站首页>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 .
边栏推荐
- [ue4] material and shader permutation
- Dllexport and dllimport
- [opengl] pre bake using computational shaders
- Zzuli: sum of 1051 square roots
- To improve efficiency or increase costs, how should developers understand pair programming?
- C language dup2 function
- Special research report on the market of lithium battery electrolyte industry in China (2022 Edition)
- [ue4] HISM large scale vegetation rendering solution
- tonybot 人形机器人 红外遥控玩法 0630
- 表单文本框的使用(一) 选择文本
猜你喜欢

Amazon, express, lazada, shopee, eBay, wish, Wal Mart, Alibaba international, meikeduo and other cross-border e-commerce platforms evaluate how Ziyang account can seize traffic by using products in th

The latest M1 dedicated Au update Adobe audit CC 2021 Chinese direct installation version has solved the problems of M1 installation without flash back!

puzzle(016.3)千丝万缕

adc128s022 ADC verilog设计实现

tonybot 人形机器人 红外遥控玩法 0630

tonybot 人形机器人 查看端口并对应端口 0701

B2020 分糖果
![Luogu p4047 [jsoi2010] tribal division solution](/img/7f/3fab3e94abef3da1f5652db35361df.png)
Luogu p4047 [jsoi2010] tribal division solution

Showmebug entered Tencent conference, opening the era of professional technical interview

Detailed explanation of four modes of distributed transaction (Seata)
随机推荐
To improve efficiency or increase costs, how should developers understand pair programming?
C language STR function
Detailed explanation of four modes of distributed transaction (Seata)
Devaxpress: range selection control rangecontrol uses
Rasterization: a practical implementation (2)
Tailing rushes to the scientific and Technological Innovation Board: it plans to raise 1.3 billion, and Xiaomi Changjiang is the shareholder
1017 a divided by B (20 points)
[ue4] HISM large scale vegetation rendering solution
My QT learning path -- how qdatetimeedit is empty
Some concepts about agile
406. 根据身高重建队列
Zhonggan micro sprint technology innovation board: annual revenue of 240million, net loss of 17.82 million, proposed to raise 600million
[graphics] adaptive shadow map
tonybot 人形机器人 首次开机 0630
C language DUP function
Déformation de la chaîne bm83 de niuke (conversion de cas, inversion de chaîne, remplacement de chaîne)
Luogu p4047 [jsoi2010] tribal division solution
7-9 one way in, two ways out (25 points)
Pyqt interface production (login + jump page)
Showmebug entered Tencent conference, opening the era of professional technical interview