NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Run multiple sequences concurrently

Hi,

 

I need to simultaneously run 2 sequence files.  I have selected the option "Run Sequence in a New Execution".  The two sequences runs fine most of the time. But since the steps in those two sequence files access the same Step Types (i.e. code module), occasionally when they both try to access the same Step Type simultaneously, that particular step will fail.

 

Is there a way to have the step from sequence_file_A to halt a particular step execution until sequence _file_B finish executing its step, and vice-versa (i.e. sequence_B finish step execution and let's sequence_A know)

 

Thanks a lot!

 

ph2

0 Kudos
Message 1 of 12
(5,006 Views)

If I understand correctly, you can do the following. On each of the two steps, go to Properties>>Synchronization and set the Use Lock... checkbox.

 

In the Lock Name.. field, put the same name.

 

Remember to put the name in quotes because the field is an expression.

0 Kudos
Message 2 of 12
(5,001 Views)

Hi James,

 

Thanks for the reply.

 

In my Main sequence file, I have over 200 steps.  In the sequence file which runs concurrently with the Main sequence file, it has 8 steps.

So I need to check the Use Lock for each of the 200 steps in Main Sequence file, as well as the sequence file that runs concurrently? Which means I need to do it 208 times?

 

Also, I'm not sure what and how this works below:

 

"In the Lock Name.. field, put the same name.

Remember to put the name in quotes because the field is an expression"

 

Thanks again.

 

ph

0 Kudos
Message 3 of 12
(4,982 Views)

The step types that ship with teststand do not require any special locking to be used concurrently from multiple threads at once. I recommend you similarly make any step types you write also be threadsafe. To make them threadsafe you either have to not use any global, shared data, or you have to use critical sections while accessing such shared data.

 

I think it's best if you determine why you are getting errors and address that, rather than blindly adding locks to everything.


Hope this helps,

-Doug

0 Kudos
Message 4 of 12
(4,976 Views)

Dug,

 

Thanks for the reply. I am quite sure it's the multiple threads causing the problem.  The part of script using just a single thread has no problems,  but as soon the launching another sequence with second thread running concurrently, the problem occurs.

 

Unfortunately, both threads need to use the same step types and accessing the same database. There's no way around that.

 

Regards,

 

ph

0 Kudos
Message 5 of 12
(4,960 Views)

What I meant was that rather than assume every step has a threading problem, try to determine which sections of the sequence can't really be run in parallel and put a lock around those, rather than locking on every step. You can lock around multiple steps using the Lock step type.

 

Also, this might have nothing to do with the step type directly, but rather with what the step type is doing or the code module it is calling is doing.

 

-Doug

0 Kudos
Message 6 of 12
(4,954 Views)

Hi,

 

Thanks for all the help.

 

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 7 of 12
(4,859 Views)

Is there any reason why you are using a lock instead of a semaphore and using rendezvous points? There is a good example for this in the synchronization folder for TestStand examples.

Ian M.
National Instruments
0 Kudos
Message 8 of 12
(4,835 Views)

Lanidas,

 

I thought rendezvous is used for sychroization between the sequences(i.e dependent on Sequence to finish, etc).  In my case, my main sequence can run independent from Sequence_B( no dependencies).  All sequence_B does is just continuously resets an alarm, while the main sequence executes the regular tests.

 

But to reset the alarm, Sequence_B uses the same steps that will occur in the main sequence.

 

Thanks,

 

ph

0 Kudos
Message 9 of 12
(4,822 Views)

@ph2 wrote:

Hi,

 

Thanks for all the help.

 

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

 

 


Use a name for the lock and make it the same name everywhere if you want to make it so that only one thread at a time can execute any of the steps which use the lock. You can also hold the lock around multiple steps by using the Lock step type.

 

-Doug

0 Kudos
Message 10 of 12
(4,805 Views)