LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Are sub-VIs of a time-critical parent made time-critical?

Hello,
I have a LabView real-time, time-critical VI in the data acquisition execution system, and that VI calls a sub-VI. I have noticed that LabVIEW does not force me to define the sub-VI in the same execution system, or at the same priority level.

For the parent VI to remain time-critical, does it force this sub-VI to be in the same thread, same execution system, and at the same priority?

Thanks in advance,
Frenk
0 Kudos
Message 1 of 6
(3,135 Views)
If your subVI's execution system is "same as caller" (default value), your subVI will be elevated to time-critical priority and will run in the same thread as the parent VI. So your statement regarding the parent VI and subVI is correct.

In general, you'll only need to set one VI to time-critical priority. Your subVIs will inherit the caller's priority if it is higher than their own.

I would avoid using multiple execution systems within a call chain that involves a time-critical priority VI because you could inadvertently create two time-critical threads, which is not recommended.
0 Kudos
Message 2 of 6
(3,135 Views)
Hi Frenk,

the default settings for the execution properties of a vi are (found in vi properties):
"Same as callers" for the preferred execution system and "normal priority" for the priority. Staying with these settings will inherit the execution system of a subvi's caller (parent) onto a called subvi.
Regarding the priority settings, yes they will be inherited as well. See also:

Multithreading in LabVIEW Real-Time
http://zone.ni.com/devzone/devzoneweb.nsf/Opendoc?openagent&E70A91E01AD6EEA2862568EB00752C1A

Also interesting:

Developing a LabVIEW Real-Time Application for FieldPoint
http://zone.ni.com/devzone/conceptd.nsf/webmain/60644843D0C0395286256D17007FF5FD?opendocument#3

Hope this helps.

Stephan A.
National Instruments
0 Kudos
Message 3 of 6
(3,135 Views)
Hello,

Thanks Bob P. My question is related to a previous discussion that we had, where I have a time critical process that needs to deal with every sample from AI Single Scan. I also have a slower process that will be executed every N samples, and takes N/samplerate seconds to complete.

I was wondering if I could start the slower process in its own thread at "high" priority, using a sub-VI call from within the time-critical VI.

If this isn't a possible or advisable method, then I think I will implement a top-level VI that calls both the time-critical VI, and the slower high-priority VI. I assume that both of these VIs should be specified to run with the same execution system (albeit at different priorities)?

Thanks again,
Frenk
0 Kudos
Message 4 of 6
(3,135 Views)
If a time-critical priority VI calls a high priority subVI (exec sys = same as caller), the high priority VI will actually run in the same thread as its caller at time-critical priority. In this case, your high priority VI could have been set to any priority, and it still would have been elevated to time-critical.

Now if your high priority VI is in a separate execution system, I *believe* what will happen is it will still run at time-critical priority, but in a separate thread (for a total of 2 tc threads).

The best (and safest) option is the solution you mentioned. Let normal call high and tc in parallel. This way, high and tc each get their own thread running at the correct priority. Keep in mind that you could lose connection, which i
s maintained by a normal priority thread, if your high priority VI does not sleep. Note that the tc VI must sleep too; otherwise high won't even run.
0 Kudos
Message 5 of 6
(3,135 Views)
Hello,

I've set it up so that TCP communication happens before and after a relatively short data acquisition, during which the time-critical VI sleeps with AI Single Scan, and the high-priority VI (not yet implemented) will cease after it completes its calculations (in a finite amount of time). I'm starting to use the RT FIFOs as you had previously suggested for communication between my time-critical and high-priority VIs.

Thanks again,
Frenk
0 Kudos
Message 6 of 6
(3,135 Views)