Five common I/O models in Linux

Source: Internet
Author: User

In general, the process of input operation has two steps: ET, relocation.

Under Linux, there are five I/O models, each of which is described below:

1>. Blocking I/O (wide use)

The application calls an I/O function, and if the data is ready, it causes the application to block until the data is ready to be copied from the kernel to the user space (the process cache) and the I/O function returns successfully.

If a process calls Recvform, then the system call does not return until a packet arrives on the local system, and then the data copy is completed.

650) this.width=650; "src="/e/u261/themes/default/images/spacer.gif "style=" Background:url ("/e/u261/lang/zh-cn/ Images/localimage.png ") no-repeat center;border:1px solid #ddd;" alt= "Spacer.gif"/>650 "this.width=650;" src= "http ://s4.51cto.com/wyfs02/m02/82/b3/wkiol1dexdkabn-naabymbagxfu706.png "title=" 1.png "alt=" Wkiol1dexdkabn-naabymbagxfu706.png "/>

2>: Non-blocking I/O (very wasteful CPU resources, infrequently used)

We set up a set of interfaces to be non-blocking, that is, to tell the kernel, when the requested I/O operation cannot be completed, do not sleep the process, but return an error. The I/O operation function continuously tests whether the data is ready, and if the wood is ready to continue testing (polling) until the data is ready and copied from the kernel to the user space, the I/O function returns successfully.

650) this.width=650; "src="/e/u261/themes/default/images/spacer.gif "style=" Background:url ("/e/u261/lang/zh-cn/ Images/localimage.png ") no-repeat center;border:1px solid #ddd;" alt= "Spacer.gif"/>650 "this.width=650;" src= "http ://s2.51cto.com/wyfs02/m02/82/b3/wkiol1dexejaflo4aacwk6ibypi472.png "title=" 2.png "alt=" Wkiol1dexejaflo4aacwk6ibypi472.png "/>

3>. I/O multiplexing (Utility server program)

Using the Select, poll, Epoll L functions also causes the process to block, but unlike blocking I/O, these functions can block multiple I/O operations at the same time, and can detect multiple I/O operation functions at the same time for several read and write operations, until the data is readable and writable, to actually invoke i/ O operation function, copy from kernel to user space, I/O function returns success.

650) this.width=650; "src="/e/u261/themes/default/images/spacer.gif "style=" Background:url ("/e/u261/lang/zh-cn/ Images/localimage.png ") no-repeat center;border:1px solid #ddd;" alt= "Spacer.gif"/>650 "this.width=650;" src= "http ://s3.51cto.com/wyfs02/m00/82/b5/wkiom1dew0_ybjppaacjgxtiofe572.png "title=" 3.png "alt=" wKiom1dew0_ Ybjppaacjgxtiofe572.png "/>

4> signal-driven I/O (SIGIO)

We allow the socket interface for signal-driven I/O, and register a signal processing function, the process continues to run without blocking, when the data is ready, the process will receive a sigio signal, you can call the I/O operation function in the signal processing function to process the data.

650) this.width=650; "src="/e/u261/themes/default/images/spacer.gif "style=" Background:url ("/e/u261/lang/zh-cn/ Images/localimage.png ") no-repeat center;border:1px solid #ddd;" alt= "Spacer.gif"/>650 "this.width=650;" src= "http ://s4.51cto.com/wyfs02/m00/82/b3/wkiol1dexhxd7brmaachxuzvx2g627.png "title=" 4.png "alt=" Wkiol1dexhxd7brmaachxuzvx2g627.png "/>

5>. asynchronous I/O

Notify us when the kernel copy is complete.

650) this.width=650; "src="/e/u261/themes/default/images/spacer.gif "style=" Background:url ("/e/u261/lang/zh-cn/ Images/localimage.png ") no-repeat center;border:1px solid #ddd;" alt= "Spacer.gif"/>650 "this.width=650;" src= "http ://s1.51cto.com/wyfs02/m01/82/b5/wkiom1dew3-qo6_gaabnagtet9q858.png "title=" 5.png "alt=" wKiom1dew3-Qo6_ Gaabnagtet9q858.png "/>


This article is from "GREEN" blog, please make sure to keep this source http://green906.blog.51cto.com/10697569/1788943

Five common I/O models in Linux

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.