IO - synchronous, asynchronous, blocking, non-blocking, AIO

IO - Synchronous, asynchronous, blocking, non-blocking

blocking and non-blocking (whether the process is suspended)
Blocking and non-blocking focus on the state of the program when it is waiting for the call result (message, return value). (That is, whether the process is suspended or not A

blocking call means that the current thread will be suspended before the call result returns. The calling thread does not return until it has the result.
A non-blocking call means that the call will not block the current thread until the result is not immediately available.


Synchronous and asynchronous (whether the call waits for the return result)
Synchronous and asynchronous focus on the message communication mechanism (whether the call gets the result (what you want), not the return of the set state and operation state) The

so-called synchronization is to send A *call* does not return until the result is obtained. But once the call returns, you get the return value.
In other words, *caller* actively waits for the result of this *call*.

Asynchronous is the opposite. After the *call* is issued, the call returns directly, so no result is returned. In other words, when an asynchronous procedure call is issued, the
caller does not get the result immediately. Rather, after the *call* is issued, the *callee* notifies the caller through status, notification, or handles the call through a callback function.


Blocking I/O model (synchronous blocking)



The characteristic of blocking IO is that both stages of IO execution are blocked


Non-blocking



IO model (synchronous non-blocking) The second stage of IO execution is blocked


IO multiplexing model (synchronous Blocking (but can handle multiple IOs at the same time))



Both stages are blocked


Signal



-driven IO (asynchronous) The second stage is blocked


Asynchronous IO model (asynchronous non-blocking)



The second stage is not blocked, but it takes up a lot of memory space (because the data space needs to be prepared for the kernel to copy data to user space)


Comparison of 5 I/O models





AIO (asynchronous non-blocking IO):
is doing IO When calling, prepare the space for data storage. When calling, tell the kernel the address of this space. When data arrives, the kernel will get data in this
space or write data to this space, and the kernel will send a notification or callback after reading/writing. Make the process aware of this.



Reference original document: http://www.cnblogs.com/renxs/p/3683189.html

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326472899&siteId=291194637