NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Do Locks work the same after upgrade from Teststand 2.0 to 3.1?

It looks like the locks leak.  I have an array of ActiveXObjects each of which is a lock as station globals.  When I converted to 3.1 from 2.0 the station globals were not there in 3.1.  So I created an array of ObjectReferences. I am assuming these are the same and the name just changed.  Anyway the locks are not working now. That is when a thread locks a lock another thread still gets the lock and "comes on in" creating a cascade of run time error messages. I have a post expression on the get lock step (timeouts are enabled) : Locals.LockTimedout =Step.Result.TimeoutOccurred. And the next step jumps over the code if a timeout occured.
Any ideas?
Thanks,
Sahc
0 Kudos
Message 1 of 10
(4,847 Views)

Sahc,

I believe the problem you are experiencing might be due to the timeout or scope of your lock.  TestStand will only release a lock under three situations: the lock is released explicitly in a step, the timeout is expired or the scope of the lock is reached.  I don't believe you are releasing the lock explicitly ,so it must be one of the other two situations.

Try running your sequence without the timeouts to see if you still receive the errors.  If the errors do not occur without the timeouts you might want to go back and increase the value of your timeouts.

If you find that the timeouts are not the cause of the issue, make sure that the scope of the locks you are using aren't being reached, and therefore, the lock is released.  The best way to go through this process is to set a breakpoint in your sequence and step through it one step at a time.

I am including a small example that demonstrates how different threads can share access to an array using locks.  If you run it with the parallel model one step at a time you will see that locks are operating correctly.

 

Regards,

Santiago D

NIC

0 Kudos
Message 2 of 10
(4,827 Views)
In my application I need for the threads to do other work if the lock is unavailable.  So I try to get a lock with a 1 second timeout.  If I got the lock I do some work then release the lock with QuickRelease.  If I didn't get the lock I do something else.  I will include a sample sequence.  If I change the get lock to not allow timeouts then if thread A has the lock thread B will wait until it is released.  If I allow timeouts thread B waits the timeout value (set to 2 seconds in this example change the local  WaitTime of the Main Sequence to use another value) then returns.  But the value of the step result  Step.Result.TimeoutOccurred is ALWAYS False.  Under 2.0 the result acted as expected Step.Result.TimeoutOccurred is Falsee with no time out and True when a timeout occures.  Under 3.1  Step.Result.TimeoutOccurred is always False.
0 Kudos
Message 3 of 10
(4,822 Views)
Opps looks like the sample didn't come through
0 Kudos
Message 4 of 10
(4,819 Views)
I tried setting the Timeout is a runtime error flag.  And sure enough you get  a run time error when there is a timeout. So the only thing that doesn't work is the step result.  I made a simplified 2p0 sequence for comparision too.
0 Kudos
Message 5 of 10
(4,811 Views)
A bug was introduced in the 3.1 version of the SyncSteps.dll file. Attached is a fixed version of the dll with accompanying src code changes. Both of these files should go in your:

<TestStand>\Components\NI\StepTypes\SyncSteps

directory.

-Doug
Message 6 of 10
(4,785 Views)
Thanks, You are a lifesaver.

0 Kudos
Message 7 of 10
(4,780 Views)
Thanks for the DLL fix earlier.  But I am wondering, does it always work or just usually work?  I am seeing symptoms that could be explained by the timeout indication usually but not always working. Have you ever seen a similar result?
thank you,
sahc
0 Kudos
Message 8 of 10
(4,681 Views)
It should always work. Basically, the step property just wasn't getting set if you didn't have the "timeout causes error" setting checked.

-Doug
0 Kudos
Message 9 of 10
(4,669 Views)
Yes that is right, I had a silly code error that fooled me. Thanks again.
0 Kudos
Message 10 of 10
(4,626 Views)