Advanced IO for Linux Learning: Five IO Models

Cola_Forever 2022-08-06 19:07:14 阅读数:241


Block IO (wait until it's good)

insert image description here

Non-blocking IO (keep saying hello or not)

insert image description here

Signal drives IO (you can copy it and send me a signal)

insert image description here

IO multiplexing (you can wait for multiple IOs at the same time, as long as one can be copied, call me)

insert image description here

Asynchronous IO (call me after copying)

insert image description here

Synchronous communication vs asynchronous communication (synchronous communication/ asynchronous communication)

Synchronous and asynchronous focus on the message communication mechanism.
1. The so-called synchronization means that when a call is issued, the call will not return until the result is obtained. But once the call returns, theThe return value is returned; in other words, the caller actively waits for the result of the call;
2. 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 made, the caller does not get the result immediately; instead, after the call is made, the callee notifies the caller through status, notification, or handles the call through a callback function.

In addition, we recall that when we talked about multi-process and multi-threading, we also mentioned synchronization and mutual exclusion. The synchronous communication and synchronization between processes here are completely unwanted concepts.
1. Process/Thread synchronization is also a direct constraint relationship between processes/threads. It is two or more threads established to complete a certain task. This thread needs to coordinate their work order at certain positions to wait and transmit information.Constraints. Especially when accessing critical resources

Blocking vs non-blocking

Blocking and non-blocking focus on the state of the program while waiting for the call result (message, return value).
Blocking call means that the current thread will be suspended before the call result is returned. The calling thread only hasIt will not return until the result is obtained.
A non-blocking call means that the call will not block the current thread until the result is not immediately available.

copyright:author[Cola_Forever],Please bring the original link to reprint, thank you.