I / O How to understand the blocking non-blocking asynchronous and synchronous difference?

"Blocking" and "non-blocking" and "synchronous" and "asynchronous" not simply from the literal understanding, provides an answer from the perspective of a distributed system.
1. synchronous and asynchronous
  synchronous and asynchronous concerned that the message communication mechanism (synchronous communication / asynchronous communication)
  when the so-called synchronous, is issuing a call * * Before not getting the results that * not * call to return. But once the call returns, the return value is obtained.
  In other words, the caller * * * * Call waiting for this initiative results.

  The induction is the opposite, * * After issuing the call, the call will return directly, so no results are returned . In other words, when an asynchronous procedure call is issued, the caller will not immediately get results. But after calling * issue *, * is * the caller to notify the caller by the state, notification, or to deal with this by calling the callback function.

  A typical asynchronous programming model such as Node.js

For popular example:
  You call to ask Bookseller there is no "distributed systems" This book, if it is synchronous communication mechanism, bookstore owner would say, you wait, "I'll check," and then began to check ah investigation, well, check, etc. (probably five seconds, it could one day) tell you the result (return result).
The asynchronous communication mechanism, the bookstore owner to tell you that I check ah, good call your check, and then directly to hang up (does not return a result). Then check Well, he will take the initiative to call you. Here the boss callback through the "call back" in this way.

2. blocking and non-blocking
  blocking and non-blocking concern is the state of the program while waiting for the result of the call (the message, the return value) of.

  Blocking call refers to the results before the call returns, the current thread is suspended. Only the calling thread does not return until after the result.
  Before non-blocking call refers not get the results immediately, the call does not block the current thread.

Using the example above,
  you are asked to call the bookstore owner there is no "distributed systems" This book, if you are blocking calls, you will always put their "pending" until the results of the book there, if is a non-blocking calls, no matter you have no boss to tell you, yourself first side to play, of course, you have a few minutes to check your boss occasionally have returned no results.
  Here blocking and non-blocking has nothing to do with whether synchronous asynchronous. It has nothing to do with the boss to answer your results by what means.

 

Blocking and non-blocking means can not be performed when the read (write time / space-time NIC card full read) time, I / O operations return immediately, or blocked;
Synchronous Asynchronous means that when the data has been ready when read and write operations are synchronous or asynchronous read to read, just different stages.

 

 

Guess you like

Origin www.cnblogs.com/myseries/p/11756335.html