Because I drink tea tonight too much excitement suddenly remembered has been in my thinking more chaotic knowledge, remember before watching countless times synchronous, asynchronous, blocking, non-blocking direct similarities and differences, thought already mastered, tonight again think again, still is very vague, so record this article make oneself understand of description come out.
The first is a reference to this blog post: http://blog.csdn.net/historyasamirror/article/details/5778378
Synchronization: The return value of a call waiting for a function
Async: Do not wait for the return value of a function call when the function return value is ready to callback the caller's registered callback function
Blocking: The process blocks on Io, the kernel waits for IO to prepare the data (data can be the data of the socket connection or the data on the local disk) and notifies the user of the process, and the kernel returns the result to wake up the blocked process.
Non-blocking: The process makes an IO request and does not need to wait for a result to be returned immediately.
This can be synchronous or CPU-intensive, and the process in which the synchronous asynchronous call resides consumes CPU time even though the process is still waiting for data to arrive. Blocking is suspending the process until the data arrives to wake the process and does not consume CPU time.
Understanding the description of Synchronous IO and asynchronous IO is the key to understanding blocking IO, non-blocking IO, multiplexed io multiplexing
a synchronous IO operation causes the requested process to be blocked until the actual IO operation is complete .
An asynchronous IO operation does not cause the process to be blocked.
The actual process of network IO operation involves the kernel and the process of invoking this IO operation. Take read for example, the specific operation of read is divided into the following two parts:
(1) The kernel waits for data to be readable
(2) Copy the data read from the kernel to the process
Synchronous io: Blocking IO, non-blocking IO, multi-channel IO multiplexing.
Blocking IO is synchronous IO and the process is blocked.
Non-blocking IO is also synchronous, although it is non-blocking when the kernel waits for data, but the process is blocked when the kernel prepares the data to notify the process that the data is ready and the user process initiates a system call to copy the data from the kernel to the user process.
Multiple IO multiplexing: non-blocking IO based on event separators, so it is also synchronous IO.
Asynchronous IO: Asynchronous non-blocking: The process makes an IO call, and the process is not blocked to return immediately. The kernel prepares the data and copies it to the memory area specified by the user process and sends a signal informing the process that the data is ready to be used immediately.
In Java, bio is blocking Io,nio is multiplexed io, and AIO is asynchronous IO.
First summary, welcome to the big God shooting bricks
Synchronous asynchronous blocking non-blocking