当前位置:网站首页>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 .
边栏推荐
- NOI OPENJUDGE 1.5(23)
- 556. 下一个更大元素 III : 简单构造模拟题
- Bibit pharmaceutical rushed to the scientific innovation board: annual revenue of 970000, loss of 137million, proposed to raise 2billion
- Zzuli:1044 failure rate
- To improve efficiency or increase costs, how should developers understand pair programming?
- 表单文本框的使用(一) 选择文本
- Plane vector addition
- Tiantu investment sprint Hong Kong stocks: asset management scale of 24.9 billion, invested in xiaohongshu and Naixue
- 关于敏捷的一些概念
- Timecho of Tianmou technology completed an angel round financing of nearly 100 million yuan to create a native timing database of the industrial Internet of things
猜你喜欢

Tailing rushes to the scientific and Technological Innovation Board: it plans to raise 1.3 billion, and Xiaomi Changjiang is the shareholder

Qt development - scrolling digital selector commonly used in embedded system

PS tips - draw green earth with a brush

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

Use of constraintlayout

Happy capital new dual currency fund nearly 4billion yuan completed its first account closing

How to color ordinary landscape photos, PS tutorial

QT - draw something else

The latest M1 dedicated Au update Adobe audit CC 2021 Chinese direct installation version has solved the problems of M1 installation without flash back!
![[graphics] real shading in Unreal Engine 4](/img/8d/53775c7570c5578f4fe985592bb305.jpg)
[graphics] real shading in Unreal Engine 4
随机推荐
Zzuli:1046 product of odd numbers
adc128s022 ADC verilog设计实现
Table of mathematical constants by q779
[qingniaochangping campus of Peking University] in the Internet industry, which positions are more popular as they get older?
Tonybot humanoid robot infrared remote control play 0630
tonybot 人形机器人 查看端口并对应端口 0701
Zzuli:1058 solving inequalities
556. The next larger element III: simple construction simulation questions
retrofit
Luogu p3065 [usaco12dec]first! G problem solution
Pyqt interface production (login + jump page)
Zzuli: cumulative sum of 1050 factorials
Get permissions dynamically
Address book sorting
【微信小程序】WXSS 模板样式
创业团队如何落地敏捷测试,提升质量效能?丨声网开发者创业讲堂 Vol.03
Zzuli:1054 monkeys eat peaches
Mongodb index
Detailed explanation of four modes of distributed transaction (Seata)
洛谷P4047 [JSOI2010]部落划分 题解