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.
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.
11-28-2007 11:11 AM
11-28-2007 11:36 AM
11-28-2007 11:54 AM
To add to Jeff's explanation and to answer the actual question - you need to understand that what you have is not a variable, but a UI control. When you have a UI control, writing to it or reading to it will be done in one atomic operation, so reading from the control you won't get half of the old values and half of the new values.
However, as Jeff mentioned, this is a good way to create race condition and is usually a sign of trying to use LabVIEW as you would C. There are better ways to handle data.
As a side issue, you can't have two threads in the same VI unless you use timed loops and explicitly set them to separate thread, so you can't use locals in separate threads.
11-28-2007 11:56 AM
11-28-2007 11:58 AM
@tst wrote:As a side issue, you can't have two threads in the same VI unless you use timed loops and explicitly set them to separate thread, so you can't use locals in separate threads.
11-28-2007 01:02 PM
Jarrod S. wrote:
Just to nit-pick, that's not necessarily true. There's no such hard rule regarding threading. Two while loops with Wait VIs in them will usually produce two threads. It's ultimately up to LabVIEW, though, to decide between multi-threading and multi-tasking.
11-28-2007 01:09 PM
"...and LV can do that even in the same VI?"
I've seen it myself. Take a giant array, split into eight parts, feed each to its own for loop and if you have enough cores, LV will split the threads across multiple cores.
"Threadconf" (sp?) will let you define the number of threads.
The article on hyperthreading touches on the topic of how the code is "chuncked-up".
Ben
11-28-2007 01:48 PM
tst wrote:
When you have a UI control, writing to it or reading to it will be done in one atomic operation, so reading from the control you won't get half of the old values and half of the new values.
However, as Jeff mentioned, this is a good way to create race condition and is usually a sign of trying to use LabVIEW as you would C. There are better ways to handle data.
11-28-2007 02:10 PM
@RonW wrote:It sounds like you're saying that this does in fact work, even if the threads are running on different cores. Is my understanding correct? I realize I can play it safe and use a semaphore. I'm just wondering if I need to.