The basic concept of I / O

The basic concept of I / O

⼀次完整的I/O是⽤⼾空间的进程数据与内核空间的内核数据的报⽂的完整交换,但是由于内核空间与⽤⼾空间是严格隔离的,所以其数据交换过程中不能由⽤⼾空间的进程直接调⽤内核空间的内存数据,⽽是需要经历⼀次从内核空间中的内存数据copy到⽤⼾空间的进程内存当中,所以简单说I/O就是把数据从内核空间中的内存数据复制到⽤⼾空间中进程的内存当中。

⽹络通信就是⽹络协议栈到⽤⼾空间进程的IO就是⽹络IO

磁盘I/O是进程向内核发起系统调⽤,请求磁盘上的某个资源⽐如是⽂件或者是图⽚,然后内核通过相应的驱动程序将⽬标图⽚加载到内核的内存空间,加载完成之后把数据从内核内存再复制给进程内存,如果是⽐较⼤的数据也需要等待时间。

Synchronous / asynchronous: Focus is a message communication mechanism event handling, that while waiting for the processing result ⼀ matter, whether the offer is adjusted Using completion notification.

同步:synchronous,调⽤者等待被调⽤者返回消息后才能继续执⾏,如果被调⽤者不提供消息返回则为同步,同步需要调⽤者主动询问事情是否处理完成。 
异步:asynchronous,被调⽤者通过状态、通知或回调机制主动通知调⽤者被调⽤者的运⾏状态

Obstruction / blockage comes in handy: Using the state's attention tone before waiting for the results which the return

阻塞:blocking,指IO操作需要彻底完成后才返回到⽤⼾空间,调⽤结果返回之前,调⽤者被挂起,⼲不了别的事情。 
⾮阻塞:nonblocking,指IO操作被调⽤后⽴即返回给⽤⼾⼀个状态值,⽆需等到IO操作彻底完成,最终的调⽤结果返回之前,调⽤者不会被挂起,可以去做别的事情。

Through a simple example to understand how the asynchronous and synchronous blocking and non-blocking

I ordered 10 buns
synchronous and asynchronous:
I cook buns after point whether told me:
Sync: chef would do after the buns into the specified location, but do need to own before buns - times and do not see the bun, chef in buns do not
notice me after good.
Asynchronous: cook the buns do tell me where to put the buns do.

Blocking and non-blocking:
I state the point buns:
blocking: During baking cook - waiting straight in front of the bun tray, can not do anything else.
Non-blocking: End point buns can do otherwise, such as mortar shopping or buy buy buy.

I0 model portfolio:
synchronous blocking: I can not do anything else after the end point of buns, buns and do not know there is no good, need he has been waiting for a time of the chef and do
not.
Non-blocking synchronization: After the end point of buns can do something else, but you can not do anything else for a long time, because I still do not know buns have not done, but also
that he has been waiting for a time and time again and asked the chef to do well no, you can only find time to do something else.
Asynchronous blocking: I can not point to go do something else after you buns, but after doing bun chef will tell me, that I do not have time to cook the buns again
there is no ready.
Asynchronous non-blocking: After I finish point buns can do something else, but also a - go straight at other things to do, because after doing bun chef will tell me.

Guess you like

Origin www.cnblogs.com/luck-pig/p/12132856.html
Recommended