The documentation suggests that the use of Ivi_LockSession/UnlockSession within the driver code results in a thread-safe driver, however, experimentation leads me to believe that this is not quite the full story.
I found that IviLockSession/UnlockSession did not protect the enclosed code from multiple threads on different sessions. That is, if my driver is used to open two sessions on two different instruments, a thread on one session does not respect the lock of the other session.
The fact that the Ivi_LockSession function requires a ViSession parameter suggests very strongly that the lock is only applicable to that session. A thread on a different session will not be blocked and so, in such cases, further care has to be taken to ensure that such threads do not cause any problems. I found I had to use a CriticalSection in order to
protect my code in this multi-session scenario.
Have I correctly understood the behaviour of Ivi_LockSession? Is the lock only applicable to threads on the same session?
Alan Hume, Pickering Interfaces Ltd