NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Multithreading in TestStand

Does TestStand lock accesses to data structures (like StationGlobals or FileGlobals) such that it is safe to read and write them from
  • sequences running in different threads
  • threads started within test steps using the TestStand API

or do I have to take care of these locks myself?

0 Kudos
Message 1 of 3
(3,371 Views)

TestStand locks access to individual data items. So if you write :

    StationGlobals.CurrentChannelName = "Chassis3:Channel4"

there is no chance of another thread reading an invalid intermediate state of the string value if it tries to read StationGlobals.CurrentChannelName during the write.

However if you write:

    StationGlobals.CurrentChannelName = "Chassis3:Channel4"

    StationGlobals.CurrentVoltage = 50

 

and another thread reads both values, then the other thread might read both values while the first thread is in between setting the first and second value.  So if you have groups of values that must change "atomically", you need to lock access to them. You can use any locks you want, including the ones TestStand provides, just as long as you use them consistently.

 

Message 2 of 3
(3,362 Views)
Thank you! Exactly what I needed to know!
0 Kudos
Message 3 of 3
(3,340 Views)