What is synchronous and asynchronous I/O?
Synchronous I/O, the initiator of the operation must wait until the receiver finishes processing the I/O
asynchronous I/O, the initiator of the operation does not wait for the receiver to finish processing I/O
Blocking I/O, the receiver of the operation must wait until the sender sends I/O
Non-blocking I/O, the receiver of the operation does not wait for the sender to send I/O
Note: In the following, the pair uses synchronous/blocking (Blocking), asynchronous/non-blocking (non-blocking), which is not differentiated.
Why are there two I/O models?
The synchronous I/O model is easy to understand and easy to use, but requires waiting for I/O operations to execute, so performance is severely limited.
The basic motivation for asynchronous I/O is high performance . In fact, it is based on a two-point premise hypothesis:
- I/O operations are time-consuming, and during I/O, there is plenty of timing for the CPU to perform other task instructions.
- When the results returned by an I/O operation are not available, a large number of instructions can be executed.
If these two prerequisites are not met, program performance may not be improved even with an efficient asynchronous I/O model.
I/O model