Five I/O models

Source: Internet
Author: User

1.Five KindsI/O model 
A. Blocking I/O
B. Non-blocking I/O
c. I/O multiplexing (SELECT and poll)
d. Signal-driven I/O (SIGIO)
E. Asynchronous I/O (Aio_ series functions for posix.1)
1). Blocking I/O model 
the application calls an IO function that causes the application to block and wait for the data to be ready.
If the data is not ready, wait ....  data ready, copy from kernel to user space
I/O function returns success indication

650) this.width=650; "Src=" Http://s3.51cto.com/wyfs02/M01/82/9F/wKiom1ddCxWRDzO9AACeRAfPD_k756.jpg-wh_500x0-wm_3 -wmp_4-s_3095079813.jpg "title=" block. jpg "width=", "height=" 259 "border=" 0 "hspace=" 0 "vspace=" 0 "style=" width:500px; height:259px; "alt=" Wkiom1ddcxwrdzo9aacerafpd_k756.jpg-wh_50 "/>

2). Non-blocking I/O model
We set up a set of interfaces to non-blocking is to tell the kernel, when the requested I/O operation cannot be completed, do not sleep the process, but return an error. This way our I/O operations function will constantly test whether the data is ready, and if not, continue testing until the data is ready. In this continuous testing process, the CPU will be a lot of time.

650) this.width=650; "Src=" Http://s1.51cto.com/wyfs02/M01/82/9F/wKiom1ddC1XgVliMAAD5MHNIIww159.jpg-wh_500x0-wm_3 -wmp_4-s_519160713.jpg "title=" non-blocking. jpg "alt=" wkiom1ddc1xgvlimaad5mhniiww159.jpg-wh_50 "/>

3). I/O multiplexing model
The I/O multiplexing model uses the Select or poll function, which also blocks the process, but unlike blocking I/O, these two functions can block multiple I/O operations at the same time. I/O functions can be detected at the same time for multiple read operations, multiple write operations, and I/O operation functions are not actually invoked until there is data readable or writable.
650) this.width=650; "Src=" Http://s1.51cto.com/wyfs02/M01/82/9E/wKioL1ddDHbj_SD4AADtbAydQTs755.jpg-wh_ 500x0-wm_3-wmp_4-s_3330872364.jpg "title=" multiplexing. jpg "alt=" wkiol1dddhbj_sd4aadtbaydqts755.jpg-wh_50 "/>
4). Signal-driven I/O model
First we allow the socket interface to drive the signal-driven I/O and install a signal processing function, and the process continues to run without blocking. When the data is ready, the process receives a sigio signal that can be called by the I/O operation function in the signal processing function to process the data.

650) this.width=650; "Src=" Http://s2.51cto.com/wyfs02/M01/82/9E/wKioL1ddDIWSmtvJAADcIOLMYyQ358.jpg-wh_ 500x0-wm_3-wmp_4-s_3792622180.jpg "title=" signal. jpg "alt=" wkiol1dddiwsmtvjaadciolmyyq358.jpg-wh_50 "/>
5). Asynchronous I/O model 
Call the Aio_read function, tell the kernel description word, buffer pointer, buffer size, file offset, and how to notify, and then immediately return. Notifies the application when the kernel copies the data to the buffer.

650) this.width=650; "Src=" Http://s3.51cto.com/wyfs02/M02/82/9F/wKiom1ddC4_ycRgqAAC_SeYXOOw211.jpg-wh_ 500x0-wm_3-wmp_4-s_1394482096.jpg "title=" yibu.jpg "alt=" wkiom1ddc4_ycrgqaac_seyxoow211.jpg-wh_50 "/>
2. Comparison of several I/O models 
The first four models are basically the same, the second phase is basically the same, and the data is copied from the kernel to the caller's buffer. The two phases of asynchronous I/O are different from the first four models.

650) this.width=650; "Src=" Http://s2.51cto.com/wyfs02/M02/82/9E/wKioL1ddDL6C1RhlAAEgjXvlnck392.jpg-wh_500x0-wm_3 -wmp_4-s_643702307.jpg "title=" bijiao.jpg "alt=" Wkiol1dddl6c1rhlaaegjxvlnck392.jpg-wh_50 "/>

3.synchronous I/O and asynchronous I/O
A. Synchronous I/O operations cause the request process to block until the I/O operation is complete.
asynchronous I/O operations do not cause the request process to block.
B. Our top four models are synchronous I/O, and only the last asynchronous I/O model is asynchronous I/O.


Five I/O models

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.