Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between a blocking and non-blocking read?

Add to the above question the concept of a wait/no wait indicator as a parameter to a ReadMessage function in a TCP/IP or UDP environment.

A third party function description states that:

This function is used to read a message from a queue which was defined by a previous registerforinput call. The input wait/no wait indicator will determine if this function will block on the queue specified, waiting for the data to be placed on the queue. If the nowait option is specified and no data is available a NULL pointer will be returned to the caller. When data available this function will return a pointer to the data read from the queue.

What does it mean for a function to be blocking or non-blocking?

like image 868
user553514 Avatar asked Mar 10 '11 17:03

user553514


People also ask

What is read blocking?

Read blocking occurs when a blocker has been assigned a particular hitter to block and as the play develops they follow, or read where their assigned hitter is going to attack the ball and the read how their assigned hitter is going to contact the ball.

What is the difference between blocking and non-blocking in VHDL?

VHDL has no concept of blocking/non-blocking assignments. There are signals and variables and they are assigned differently. In your case, you need to remember that simulation runs on a series of delta cycles. 1 delta is an infinitely small space of time, but they happen sequentially.

What does non-blocking mean?

Non-Blocking: It refers to the program that does not block the execution of further operations. Non-Blocking methods are executed asynchronously. Asynchronously means that the program may not necessarily execute line by line.

What is blocking and non-blocking socket?

In blocking socket mode, a system call event halts the execution until an appropriate reply has been received. In non-blocking sockets, it continues to execute even if the system call has been invoked and deals with its reply appropriately later.


1 Answers

Blocking means that execution of your code (in that thread) will stop for the duration of the call. Essentially, the function call will not return until the blocking operation is complete.

A blocking read will wait until there is data available (or a timeout, if any, expires), and then returns from the function call. A non-blocking read will (or at least should) always return immediately, but it might not return any data, if none is available at the moment.

like image 179
Matti Virkkunen Avatar answered Sep 21 '22 05:09

Matti Virkkunen