From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

1 ms wait is the same as a 2 ms wait

I mean, if that's what you are trying to do, in most cases it shouldn't be necessary at all.  If you're not running your thread at the top priority level, Windows will do this automatically after a time in any case, whether you want it to or not. 

 

And unless you're running on an amazingly cheap or old processor, most processors today have multiple cores and so even if you did lock one single thread it wouldn't stop the rest of the system from running.

0 Kudos
Message 11 of 14
(1,131 Views)

@nanocyte wrote:

 


Can you point to documentation that describes this? Is it Windows specific? My intent was to have a small wait so as not to starve other threads but 2 ms was too long so a 0 ms wait might be just what I'm looking for.


The Help function for Wait (ms) says:

 


Wiring a value of 0 to this parameter forces the current thread to yield control of the CPU.

Message 12 of 14
(1,124 Views)

@nanocyte wrote:


Can you point to documentation that describes this? Is it Windows specific? My intent was to have a small wait so as not to starve other threads but 2 ms was too long so a 0 ms wait might be just what I'm looking for.


https://stackoverflow.com/questions/3727420/significance-of-sleep0

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
Message 13 of 14
(1,098 Views)

Wait (ms) is in the help (CTRL+h or online).

 

If you just want to avoid 100% CPU without slowing down your loop too much, you can wait every few iterations:

 

Wait some iterations.png

 

1.5 decade ago I tested reading the CPU load, and using a controller (P or PI) to conditionally wait to get to a setpoint CPU load. It worked, but seemed too complicated to be practical. I never actually used it.

0 Kudos
Message 14 of 14
(1,085 Views)