10-18-2012 01:11 PM
If I write an instrument driver using LabWindows/CVI and the appropriate wizards, is it inherently threadsafe? Or do I have to add all of the various lock/unlock functions myself? (I know that I have to add syncronization to make sure that separate threads don't step on each other while one has control of the instrument, that's a separate issue).
10-19-2012 12:48 AM
10-19-2012 08:49 AM
ViStatus _VI_FUNC agx2k3k_reset (ViSession vi)
{
ViStatus error = VI_SUCCESS;
checkErr( Ivi_LockSession (vi, VI_NULL));
if (!Ivi_Simulating(vi))
{
ViSession io = Ivi_IOSession(vi);
checkErr( Ivi_SetNeedToCheckStatus (vi, VI_TRUE));
viCheckErr( viPrintf (io, "*RST"));
}
checkErr( agx2k3k_DefaultInstrSetup (vi));
checkErr( agx2k3k_CheckStatus (vi));
Error:
Ivi_UnlockSession (vi, VI_NULL);
return error;
}
10-19-2012 09:34 AM
Hi pblase,
If you wrote your driver to be thread safe you should pick the option "run in any thread", but if you did not, this is not inherently threadsafe. You can do either, modify your driver to be threadsafe, or select the option run in "UI thread" when you call your library.
Also, if you are importing a library that you are not sure if is threadsafe, you should pick the option "run in UI thread" too, with this option you force the execution to run that specific library only in the User interface thread.
I hope this helps.
10-19-2012 09:53 AM
Last two posts (10-18-12 and 10-19-12) are related to this thread.