LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Something like an FGV but that allows parallel read access?

I've had the FGV drilled into me since probably the first hour I ever started a Labview vi. It's been my go-to for the typical FGV use case scenario since day 1.

 

Right now I'm thinking of a situation where I'd really prefer parallel read access to a value. The value will only be written once at initialization so I'm not concerned about the usual reason one would use an FGV for.

 

In fact, this value I'm talking about is the time out value for an acquire semaphore which seems to defeat the purpose of the semaphore if various VIs are waiting to just access the time out value.

 

The semaphore basically keeps abstracted user commands, that are basically a series of multiple requests to the low level driver of hardware, atomic in nature. For instance, in order to run a procedure, you need to check whether the procedure is open in a 3rd party app, make it the active procedure, set simulation flag to whatever, then specify the step to run. I've abstracted those steps to just a simple run procedure step. However, I don't want various background processes that poll the app to sneak in between any sub steps, so its designed that all communication to the instrument has to acquire a certain semaphore to do it.

 

I just don't know yet what sort of time out I want, so I want it configurable from a central source. FGV seems like a waist having vis wait for access. What's a good way to allow simultaneous access, read only, to a value? 

0 Kudos
Message 1 of 3
(2,128 Views)

What's wrong with putting the value (once) into a Global Variable and then using it as a "Read-Only Value"?  They are available in any/all VIs, are extremely fast, and are vanishly-unlikely to cause two parallel threads to "block", (a) because reading the value takes so little time (crossrulz showed that it is one of the fastest way of getting values), and (b) having two routines running truly in parallel are quite unlikely to call on the particular Global at the same instant.

 

Bob Schor

Message 2 of 3
(2,112 Views)

Write ONCE/NONE, Read Many: sounds like one of the ideal situations for a Global Variable.  And here are a couple of links to some things you really should look at, especially the second one (my NI Week 2016 presentation).

A Look At Race Conditions

Are Global Variables Truely Evil?


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 3 of 3
(2,098 Views)