IVI Driver Help

Edition Date: August 2011

Part Number: 370430H-01

»View Product Info
Download Help (Windows Only)

IVI Inherent Function

To form the ClassPrefix_ of the function name, use the prefix of the class driver with which you are working. For example, if you are working with the IviDmm class driver, use the prefix IviDmm_ to create the correct function name, IviDmm_LockSession.

C Function Prototype

ViStatus ClassPrefix_LockSession (ViSession vi, ViBoolean *callerHasLock);


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

  • Your application called ClassPrefix_LockSession.
  • A call to the class driver or specific driver locked the session.

After your call to ClassPrefix_LockSession returns successfully, no other threads can access the instrument session until you call ClassPrefix_UnlockSession. Use ClassPrefix_LockSession and ClassPrefix_UnlockSession around a sequence of calls to instrument driver functions if you require that the instrument retain its settings through the end of the sequence.

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


Inputs Type Description
vi ViSession The instrument handle that you obtain from the ClassPrefix_init or ClassPrefix_InitWithOptions functions. The handle identifies a particular IVI session.
Outputs Type Description
callerHasLock ViBoolean This parameter serves as a convenience. If you do not want to use this parameter, pass VI_NULL. Use this parameter in complex functions to keep track of whether you obtain a lock and therefore need to unlock the session. Pass the address of a local ViBoolean variable. In the declaration of the local variable, initialize it to VI_FALSE. Pass the address of the same local variable to any other calls you make to ClassPrefix_LockSession or ClassPrefix_UnlockSession in the same function.

Return Values


Not Helpful