Thank you, Mark. That is a very helpful explanation.
From: Mark Rivers <email@example.com>
Sent: Monday, April 30, 2018 4:44 PM
To: Gregory, Ray <firstname.lastname@example.org>; email@example.com
Subject: RE: Are Stream Device protocol clauses atomic?
- I would like to know if protocol clauses for Stream Device protocols are atomic.
I believe they are atomic with certain caveats:
- Before the “out” command is executed the input stream is flushed. This should remove any stale input.
- The asyn port is locked so that the complete protocol is executed without releasing the lock. This ensures that 2 records cannot interfere.
A problem can occur however if the previous command “in” timed out but the device does eventually send the response. If it sends its response after the flush before the next “out” command then the response to that “out” command will be
the previous response, not the expected response. You should set the timeout long enough to prevent this.
If you are using any stream device records with SCAN=I/O Intr you must be sure that your protocol consumes all of the input from the device. If not that input could mistakenly be used for another protocol.
I would like to know if protocol clauses for Stream Device protocols are atomic. For example, if one thread is processing clause
# /// Read the input curve number
out "INCRV? \$1";
and another thread is simultaneously processing (in the same IOC) clause
out "INCRV? \$2";
can these collide and interfere with each other? Or is there a blocking mechanism to help ensure that the ‘in’ of one clause is really the response to the preceding ‘out’ of the same clause?