同步/异步与阻塞/非阻塞

同步/异步与阻塞/非阻塞

两组概念不在同一个纬度

同步/异步

同步:操作者主动完成了这件事情,需要自己完成的操作都是同步操作

异步:调用指令发出,操作马上返回,处理完成后,再通过通知的手段来告诉操作者结果,不是调用者自己完成的

阻塞/非阻塞

阻塞:从头到尾只做这一件事情,不能做其他事情:

非阻塞:无需等待在这里,反复过来检查:

总结

POSIX defines these two terms as follows: A synchronous I/O operation causes therequesting process to be blocked until that I/O operation completes. An asynchronous I/O operation does not cause the requesting process to be blocked. Using these definitions, the first four I/O modes - blocking, nonblocking, I/O multiplexing, and signal-driven I/O - are all synchronous because the actual I/O operation (recvfrom) blocks the process. Only the asynchronous I/O model mathes the asynchronous I/O definition. —- Unix Network Programming, volume

参考