niHSDIO_LockSession

NI Digital Waveform Generator/Analyzer

niHSDIO_LockSession

Specific Function

C Function Prototype

ViStatus niHSDIO_LockSession (ViSession vi, ViBoolean* callerHasLock);

Purpose

This function obtains the multithreaded lock on the instrument session. Before doing so, the function waits until all other execution threads have released the lock on the instrument session. Other threads might have obtained the lock on this session in the following ways:

- Your application called niHSDIO_LockSession
- A call to the instrument driver locked the session
- A call to the IVI engine locked the session

After the call to niHSDIO_LockSession returns successfully, no other threads can access the instrument session until you call niHSDIO_UnlockSession. Use niHSDIO_LockSession and niHSDIO_UnlockSession around a sequence of calls to instrument driver functions if you require exclusive access through the end of the sequence.

You can safely make nested calls to niHSDIO_LockSession within the same thread. To completely unlock the session, you must balance each call to niHSDIO_LockSession with a call to niHSDIO_UnlockSession. If, however, you use the callerHasLock parameter in all calls to niHSDIO_LockSession and niHSDIO_UnlockSession within a function, the IVI Library locks the session only once within the function, regardless of the number of calls you make to niHSDIO_LockSession. This functionality allows you to call niHSDIO_UnlockSession just once at the end of the function.

Parameters

Name Type Description
vi ViSession This handle identifies your instrument session. vi was obtained from the niHSDIO_InitAcquisitionSession or niHSDIO_InitGenerationSession function.
callerHasLock ViBoolean This parameter serves as a convenience. If you do not want to use this parameter, pass VI_NULL. You can use this parameter in complex functions to track lock status and the need to unlock the session. Pass the address of a local ViBoolean variable in the declaration of the local variable and initialize it to VI_FALSE. Also, pass the address of the same local variable to any other calls you make to niHSDIO_LockSession or niHSDIO_UnlockSession in the same function.

Return Value