Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the five IO models in linux

2025-01-14 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly explains "what are the five IO models in linux". The content of the explanation is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn what the five IO models in linux are.

What is the IO model

For an IO operation, the data is copied to kernel space first, and then from kernel space to user space, so a read operation goes through two phases:

(1) wait for data preparation

(2) data is copied from kernel space to user space.

Based on the above two stages, there are five different IO modes.

Blocking IO

Initiate an IO operation from the process, waiting for the above two phases to complete.

The two stages block together.

Non-blocking IO

The process keeps asking IO if it is ready, then initiates a read operation when it is ready, and then copies the data from kernel space to user space.

The first stage is not blocking but polling is required, and the second stage is blocking.

Multiplexing IO

Multiple connections use the same select to ask whether the IO is ready. If so, return that the data is ready, and then the corresponding connection initiates a read operation to copy the data from kernel space to user space.

The two stages are blocked separately.

Signal driven IO

The process initiates a read operation and immediately returns, and when the data is ready, it will tell the process in the form of a notification, and the process will initiate a read operation to copy the data from kernel space to user space.

There is no blocking in the first stage and blocking in the second stage.

Asynchronous IO

The process initiates a read operation and returns immediately, waiting for the data to be ready and copied to user space before informing the process to get the data.

There is no blocking in both stages.

Comparison of IO modes

The various IO models are as follows:

The difference between synchronous and asynchronous is whether it blocks when calling the operating system's recvfrom (), so you can see that everything except the final asynchronous IO is synchronous IO.

Select poll epoll

Select has the limit of maximum file descriptors. Only a few file descriptors can be detected, so you have to traverse all the file descriptors to get the ready IO.

Poll does not have the limit of the maximum file descriptor, and like select, you can only listen to how many file descriptors are ready, and you have to traverse all the file descriptors to get the ready IO.

Epoll has no maximum file descriptor limit, but through the callback mechanism, once a file descriptor is ready, it quickly activates the file descriptor and is notified the next time the process calls epoll_wait ().

Therefore, epoll is much more efficient when there are a large number of free connections.

Thank you for your reading, the above is the content of "what are the five IO models in linux". After the study of this article, I believe you have a deeper understanding of what the five IO models in linux are, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report