The difference between synchronous and asynchronous, blocking and non-blocking

1, concept analysis

I believe that many linux background in development work have contact with synchronous & asynchronous, non-blocking blocking & concepts such as, believe have all produced a misunderstanding, such as synchronization is blocked think, is a non-blocking asynchronous, let's first analyze under these What is the meaning of each concept.

Sync:
The so-called synchronous, that is, when issuing a function call, until no results, the call will not return. One thing that is a must do , such as one done before in order to do the next thing.

E.g. ordinary B / S mode (synchronous): Submit Request -> waiting for the server process -> return processing completed anything during this client browser can not do

Asynchronous:
Asynchronous and synchronous relative concept. When an asynchronous procedure call is issued, the caller can not immediately get results. The actual processing of the call after completion member, to inform the caller via a state, and a notification callback.

For example ajax request (asynchronous) : Request by event triggers -> server processing (which is the browser can still be used for other things) -> processed

Blocking:
blocking calls means before the call returns, the current thread is suspended (thread into the non-executable state, in this state, cpu will not give the thread allocation of time slices that thread pauses). Function will return only after getting results.

Maybe someone will call and synchronous call blocking equate, in fact, he is different. For synchronous calls, many times the current thread is still active, but does not return from the current function logically, it will seize the cpu to perform additional logic will automatically detect whether io ready.

Non-blocking
non-blocking and blocking concept corresponds to refer to before the results can not be obtained immediately, the function does not block the current thread, and will return immediately.

Then a simple point to understand is this:

1. synchronization, is what I call a function, that function does not end before I die, etc. results.
2. asynchronous, is what I call a function, the function does not need to know the results, I notice after the function result (callback notification)
3. obstruction, it is to call me (function), I (function) after receiving no data or not before the result, I will not return.
4. Non-blocking, is to call me (function), I (function) returns immediately, select the notification by caller

The difference between synchronous and asynchronous IO IO is that: when the data copy process is blocked

Difference between blocking and non-blocking IO IO lies: whether the calling application to return immediately

To sum up, synchronous and asynchronous, blocking and non-blocking, some mix, in fact, they are not the same thing, and they modified the object is not the same.

2 or five IO model

In the understanding of synchronous and asynchronous, blocking and non-blocking concept, we say something about linux five IO model:

1) blocking the I / O (blocking the I / O)
2) non-blocking the I / O (a nonblocking the I / O)
. 3) the I / O multiplexing (select and poll) (I / O multiplexing)
signal drives 4) I / O (Signal Driven the I / O (the SIGIO))
. 5) of asynchronous I / O (asynchronous I / O (the POSIX aio_functions))

The first four of which are synchronized, the last one is asynchronous.

Original: https://www.cnblogs.com/chaser24/p/6112071.html

 

1, concept analysis

I believe that many linux background in development work have contact with synchronous & asynchronous, non-blocking blocking & concepts such as, believe have all produced a misunderstanding, such as synchronization is blocked think, is a non-blocking asynchronous, let's first analyze under these What is the meaning of each concept.

Sync:
The so-called synchronous, that is, when issuing a function call, until no results, the call will not return. One thing that is a must do , such as one done before in order to do the next thing.

E.g. ordinary B / S mode (synchronous): Submit Request -> waiting for the server process -> return processing completed anything during this client browser can not do

Asynchronous:
Asynchronous and synchronous relative concept. When an asynchronous procedure call is issued, the caller can not immediately get results. The actual processing of the call after completion member, to inform the caller via a state, and a notification callback.

For example ajax request (asynchronous) : Request by event triggers -> server processing (which is the browser can still be used for other things) -> processed

Blocking:
blocking calls means before the call returns, the current thread is suspended (thread into the non-executable state, in this state, cpu will not give the thread allocation of time slices that thread pauses). Function will return only after getting results.

Maybe someone will call and synchronous call blocking equate, in fact, he is different. For synchronous calls, many times the current thread is still active, but does not return from the current function logically, it will seize the cpu to perform additional logic will automatically detect whether io ready.

Non-blocking
non-blocking and blocking concept corresponds to refer to before the results can not be obtained immediately, the function does not block the current thread, and will return immediately.

Then a simple point to understand is this:

1. synchronization, is what I call a function, that function does not end before I die, etc. results.
2. asynchronous, is what I call a function, the function does not need to know the results, I notice after the function result (callback notification)
3. obstruction, it is to call me (function), I (function) after receiving no data or not before the result, I will not return.
4. Non-blocking, is to call me (function), I (function) returns immediately, select the notification by caller

The difference between synchronous and asynchronous IO IO is that: when the data copy process is blocked

Difference between blocking and non-blocking IO IO lies: whether the calling application to return immediately

To sum up, synchronous and asynchronous, blocking and non-blocking, some mix, in fact, they are not the same thing, and they modified the object is not the same.

2 or five IO model

In the understanding of synchronous and asynchronous, blocking and non-blocking concept, we say something about linux five IO model:

1) blocking the I / O (blocking the I / O)
2) non-blocking the I / O (a nonblocking the I / O)
. 3) the I / O multiplexing (select and poll) (I / O multiplexing)
signal drives 4) I / O (Signal Driven the I / O (the SIGIO))
. 5) of asynchronous I / O (asynchronous I / O (the POSIX aio_functions))

The first four of which are synchronized, the last one is asynchronous.

Original: https://www.cnblogs.com/chaser24/p/6112071.html

Guess you like

Origin www.cnblogs.com/jfdwd/p/11183802.html