NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Multithreading not waiting

Hi All,

 

Thanks for helping with resolving the issue with accessing shared resource with Locks in multithreading.  However, now I have two sequences with steps that skip the execution.

 

I've been experimenting with Locks by locking the same step type in both sequence files that run in parallel. I checked the box in synchronization tab but left the Lock Name(reference expression) field empty.  In the properties window, it mentions ..leave blank to use a lock unique to the steps.

 

By doing this, my multithread scripts no longer crashes the Window XP.  However, my test results are inaccurate now. I think the reason is the step type in one sequence file are not waiting for the step type in another sequence?  If it sense it's been locked( by another sequence file) it will just skip to next step?

I want all the step types to execute but how can I make it to wait for the other step to unlock.

 

Thanks again.

 

ph

0 Kudos
Message 1 of 5
(3,370 Views)

If you don't specify a lock name (or reference), the lock applies only to the step you checkmarked. If you run the step more than once, only one runtime instance of the step executes at a time.

 

The unnamed lock does not apply to any other step, not even if you make a copy of the step. If you want two different steps (no matter how similar) to share a lock, you should specifiy the same lock using the same lock name or same lock reference.

0 Kudos
Message 2 of 5
(3,364 Views)

James,

 

Thanks for the reply.

 

Just for testing purpose, I made a copy of the exact step and added to another sequence file, and gave both steps the same lock name in parenthesis like ("lockStepA").  Here's an example of the sequences:

 

Sequence A, step A

Sequence B, step A

 

When running both sequences in parallel, the SeqB step now waits for the SeqA step to finish. However, once the SeqA stepA completes, SeqB stepA just freezes and won't execute.  Any suggestions?

 

Best Regards,

 

ph

0 Kudos
Message 3 of 5
(3,343 Views)

Hey ph,

 

I just tried this on my end and was able to get it to work properly. To clarify, what method are you using to run the two sequence files in parallel? 

 

One thing I might suggest would be to try this with a very simple step, rather than a complex one--so for example, try it with a simple message popup or Wait step, to make sure that the step configuration itself isn't contributing to the issue. 

 

Finally, I wasn't sure if you were saying that the lock name was exactly as follows: ("lockStepA").    If so, it's not necessary to use the parenthesis.

0 Kudos
Message 4 of 5
(3,330 Views)

Daniel,

 

Yes, It seems to be working now. The wait step works just fine.  But for some reason, my customized step type need to run with the option"Unload after step executes" (but sometimes it works fine without). 

 

I should also remove the parenthesis like you mentioned.  I wish there was a easier way to add/edit the lock name for each step.

 

Thanks!

 

ph

0 Kudos
Message 5 of 5
(3,309 Views)