NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

[q]System-wide synchronization and information passing

Hello,

i'm trying to solve two following problems for TS2.0 test-system using MSVC++6.0:

1. Synchronize TS execution with some independent process. I.e. using CreateMutex and CreateEvent operations.

2. Create some system shared memory area to do data buffering (for NT based system).

Considering the first issue, i've found some information about creating "Lock" step and naming it with the name that starts with "*"-symbol. If this method is best solution - could someone kindly provide me with short example source code for essential synchronization part. Any kinds of links would be also highly appreciated.

Second problem is still unclear for me. Is there any native ways for solving that kind of tasks? O
f course, i can write some library function, that will do all the stuff, but ideology is first to find best solutions within product (i.e. TestStand).

Thank for any kind of help in advance!
0 Kudos
Message 1 of 4
(3,443 Views)
1) The source code for the Lock step type is located in \Components\NI\StepTypes\SyncSteps. You will notice that it uses a COM server called TestStand Synchronization. You are correct that if you name the Lock with a name that starts with an "*" character that it will be shared between processes. Also, you can access the TestStand Synchronization COM server directly if you want to access it from a process that is not running a sequence. See the source code for the SyncSteps and the documentation for the Synchronization Step types in the user manual for more information.

2) The Queue step type is useful for passing data between threads and processes. I suggest you read the section in the user manual on the queue step type to see if it meets your needs.


Hope this helps,
Doug
0 Kudos
Message 2 of 4
(3,443 Views)
But is there possibility to work with mutex _without_ starting TestStand Engine or passing reference to it?

It's clear that I can use it withing my Operator Interface. But some applets (.exe files), which need to be synchronized with, know only CreateMutex and WaitForSingleObject operations. Recompiling them in order to get COM support would take huge amount of time and people resources.

In source code for "Mutex.cpp" we have something like: (name for lock is "*SystemWideLock")

...
ISyncManagerPtr syncManager = engine->GetSyncManager(objNameStr);
...
IMutexPtr mutex = syncManager->CreateMutex(objNameStr, &alreadExists);
...

I've tryed to get mutex handle from CPP code via:

...
CString name = "*SystemWideLock";
HANDLE hMutex = OpenMutex(SYNCHR
ONIZE, FALSE, name);
...

But it allways fails. It seems that TestStand uses it's own synchronization techniques (I couldn't get deeper than "raw_CreateMutex" operation in source code).

The similar problem arises with "Queue" step.

Please, inform me if there is no way to implement things i'am trying to do, so I'll start developing custom data types, which suit my needs.

Thanks for help!
0 Kudos
Message 3 of 4
(3,443 Views)
You are correct that teststand uses its own synchronization implementation that does not directly correspond to the operating system. If you want to use a teststand mutex in your other applications they will have to be COM clients and create the teststand engine. To do this, they just need to call CoInitialize() and then you can use the following header and source files under \API\VC in order to create the engine and call into it:
tsapivc.cpp/.h
tssyncvc.cpp/.h

-Doug
0 Kudos
Message 4 of 4
(3,443 Views)