LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

thread priority


@jyang72211 wrote:

The loop doesn't have to be syn, but they all need to start ASAP.  i see that one loop is delayed by 1s.  


You will not get the loop times you want while in Windows, period.

 

You are at the mercy of Windows and having a 1ms loop rate is not going to be something that can be achived for any length of time.  The jitter along is probably on the order of a few milliseconds.  What if Windows downloads an update?  Runs anti-virus?  Performs a cache memory to disk? etc.

 

If you are trying to have anything happen at 1ms timing, you want hardware timed loops.  This means FPGA, real-time, or some kind of embedded device.

Message 11 of 17
(976 Views)

dont' really  need the 1ms timing.  It believe it is put there to indicate high priority.

------------------------------------------------------------------

Kudos and Accepted as Solution are welcome!
0 Kudos
Message 12 of 17
(964 Views)

@jyang72211 wrote:

The loop doesn't have to be syn, but they all need to start ASAP.  i see that one loop is delayed by 1s.  


Is it always exactly 1 second, or it varies from run to run? How are you measuring that delay? Are all the loops in one VI, or separate VIs? If you separate them into different VIs and put them in different execution subsystems, does it make a difference? Are you doing any operations that would cause a switch to the user interface thread - for example, using front-panel property nodes - which could force portions of the loops to execute serially rather than in parallel?

Message 13 of 17
(961 Views)

@jyang72211 wrote:

dont' really  need the 1ms timing.  It believe it is put there to indicate high priority.


That's not how thread priority works at all. The wait functions (Wait (ms), Dequeue, etc) wait until at least that amount of time has passed; in no way does it guarantee that execution will resume after exactly that amount of time has passed. If you want a high priority loop, do it properly: move it to a separate VI and set the priority, or use a Timed Loop (which runs in its own thread at a high priority).

Message 14 of 17
(956 Views)

I don't really care about the loop rate.  I just care about the start time of the loop.  

------------------------------------------------------------------

Kudos and Accepted as Solution are welcome!
0 Kudos
Message 15 of 17
(905 Views)

Hello jyang72211,

 

There is a very good chance that you are already familiar with this concept, but have you looked into using Wait Until Next ms Multiple?

 

http://digital.ni.com/public.nsf/allkb/12B2EA9AD5B265AD86256257004DD8E2

http://zone.ni.com/reference/en-XX/help/371361K-01/glang/wait_till_next_ms_multiple/

 

Here is an example:

https://decibel.ni.com/content/docs/DOC-14149

 

It may assist in at least getting loops to synchronously start, though again, it may still be susceptable to software timing issues.

Chris H
Applications Engineer
National Instruments
0 Kudos
Message 16 of 17
(865 Views)

I think we are trying to provide a solution for a problem that hasn't really been defined.  What happens in the loop that is "late"?  Does it do hardware initialization, are you reading or writing some equipment?  Are you building some kind af array?

 

I think this is one of those times where we should pull back and ask you why it is so critical that they all start at the same time and what this code is supposed to accomplish.  Maybe there's an easy solution that doesn't involve loop timing at all.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 17 of 17
(853 Views)