当前位置:网站首页>NIO、BIO、AIO
NIO、BIO、AIO
2022-06-24 22:20:00 【Nice2cu_ Code】
IO Model
List of articles
One 、 Sync 、 asynchronous
- Sync : The thread initiates the request itself , To get the results ( One thread )
- asynchronous : The thread initiates the result itself , But don't get the results , Instead, other threads get the results and send them to this thread ( At least two threads )
Two 、 The process of reading data
When the user thread calls channel.read or stream.read after , Will switch to the operating system kernel state to complete the real data reading , Reading is divided into two stages , Respectively :
- Waiting for the data phase
- Copy data phase

3、 ... and 、 Synchronous blocking 、 Synchronous nonblocking 、 Synchronous multiplexing 、 Asynchronous non-blocking
Blocking IO( Sync )(BIO)
- The user thread is blocked , call read After the method , Waiting for kernel space to read data , No other operation , Can only wait for

Non blocking IO( Sync )
- User threads are not blocked , call read After the method , Even if kernel space does not read data , Returns the 0, The user thread loop calls
readMethod , It won't block , It is not blocked until the replication phase - The data replication phase is still blocked

- User threads are not blocked , call read After the method , Even if kernel space does not read data , Returns the 0, The user thread loop calls
Multiplexing ( Sync , Single thread cooperation selector Use )(NIO)
- Block until the event occurs
- Blocking occurs during both the wait phase and the copy phase ( Single channel From the perspective of , It's blocked )
- Multiple channel From the perspective of , It's non blocking , One channel No data in , It won't block , Can handle other channel

Asynchronous non-blocking ( asynchronous IO)(AIO)
- The user calls read After method , Kernel space returns immediately , Inform to get the user's request , After the kernel space completes the corresponding operation , The result is returned by another thread
- After the kernel space completes the operation , The callback method will be called to return data
- Because return immediately , therefore Asynchronous must not be blocking , So asynchronous must be non blocking

Blocking IO vs Multiplexing ( All synchronous )
- Blocking IO, When processing one connection, you cannot process another connection , If you want to handle a new connection , You must wait until the last connection is completely processed before you can process a new connection
- Multiplexing , One selector Can process multiple at the same time channel Events , Some channel When there is no data in , Threads do not need to wait , Can handle other things

边栏推荐
- 01--- conditions for interference of two trains of waves at the meeting place
- Redis+caffeine two-level cache enables smooth access speed
- PostMan工具介绍及安装使用
- Two implementation methods of stack
- 虚拟人的产业发展现状
- Minimum spanning tree based on Kruskal
- Embedded development: tips and tricks -- clean jump from boot loader to application code
- EasyBypass
- 专科出身,2年进苏宁,5年跳阿里,论我是怎么快速晋升的?
- 60 个神级 VS Code 插件!!
猜你喜欢

Detailed installation and use of performance test tool wrk

CV2 package guide times could not find a version that satisfies the requirement CV2 (from versions: none)

985 test engineer is hanged. Who is more important in terms of education and experience?
![leetcode:45. Jumping game II [classic greed]](/img/69/ac5ac8fe22dbb8ab719d09efda4a54.png)
leetcode:45. Jumping game II [classic greed]

C language - keyword 1

关于自动控制原理资料更新

Junior college background, 2 years in Suning, 5 years in Ali. How can I get promoted quickly?

leetcode-201_ 2021_ 10_ seventeen

Multithreaded finalization

理想L9,智能座舱新潮流
随机推荐
Balanced binary search tree
leetcode:55. Jumping game [classic greed]
PyCharm 中出现Cannot find reference ‘imread‘ in ‘__init__.py‘
干货丨产品的可行性分析要从哪几个方面入手?
Flutter: Unsupported value: false/true
Docker 安装 Redis-5.0.12,详细步骤
Object. Defineproperty and reflect Fault tolerance of defineproperty
TCP RTT measurement tips
Publicity of the second batch of shortlisted enterprises! Annual Top100 smart network supplier selection
CV2 package guide times could not find a version that satisfies the requirement CV2 (from versions: none)
linq查询集合类入门 案例武林高手类
产业互联网时代,并不存在传统意义上的互联网
Maximum flow problem
系统测试主要步骤
EasyBypass
Common voting governance in Dao
TCP RTT测量妙计
为什么有的程序员能力一般却能拿到好offer?
[200 opencv routines] 209 Color image segmentation in HSV color space
Réduire le PIP à la version spécifiée (mettre à jour le PIP avec pycharm avant de le réduire à la version originale)