阻塞,非阻塞,同步,异步

来源:互联网 发布:java怎么上传图片 编辑:程序博客网 时间:2024/06/05 03:15

对于一个network IO (这里我们以read举例),它会涉及到两个系统对象,一个是调用这个IO的process (or thread),另一个就是系统内核(kernel)。当一个read操作发生时,它会经历两个阶段:
1 等待数据准备 (Waiting for the data to be ready)
2 将数据从内核拷贝到进程中 (Copying the data from the kernel to the process)

内核阶段准备数据,可以阻塞或非阻塞,取决于进程查询时是否阻塞。
这里有个io多路复用,进程监控多个io,select

从内核拷贝出来的阶段,可以阻塞或非阻塞,阻塞的叫同步synchronous ,非阻塞叫异步asynchronous

A synchronous I/O operation causes the requesting process to be blocked until that I/O operation completes;
An asynchronous I/O operation does not cause the requesting process to be blocked;

原创粉丝点击