Comparison of several I/O models in Linux

Source: Internet
Author: User

There are five I/O models in Unix/Linux:

1) blocking I/O

2) non-blocking I/O

3) I/O multiplexing (select and poll)

4) signal-driven I/O (sigio)

5) asynchronous I/O (posix.1 AIO _ series functions)

These models sometimes make me confused. I will summarize and compare them today:

Blocking I/O:

ApplicationProgramCalling an IO function causes application blocking and waits for data to be ready. If the data is not ready, keep waiting .... The data is ready. copy the data from the kernel to the user space. The IO function returns a successful instruction.

Non-blocking I/O:

When we set a set of interfaces to non-blocking, we will tell the kernel that when the requested I/O operation cannot be completed, do not sleep the process, but return an error. In this way, our I/O operation functions will continuously test whether the data is ready. If not, continue the test until the data is ready. In this continuous testing process, it will take a lot of CPU time.

I/O multiplexing (select and poll ):

The I/O reuse model uses select or poll functions. These two functions can also block the process, but they are different from those that block I/O, these two functions can block Multiple I/O operations at the same time. In addition, I/O functions of multiple read operations and write operations can be detected at the same time. I/O operation functions can be called only when data is readable or writable.

Signal-driven I/O (sigio ):

First, we allow the set of interfaces for signal-driven I/O, and install a signal processing function, the process continues to run without blocking. When the data is ready, the process receives a sigio signal and can call the I/O operation function in the signal processing function to process the data.

Asynchronous I/O (posix.1 AIO _ series functions ):

When an asynchronous process is called, the caller cannot obtain the result immediately. After the call is completed, the caller's input and output operations are notified through status, notification, and callback.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.