User`s guide

Programming with VISA 3
Agilent VISA User’s Guide 87
Using Locks
In VISA, applications can open multiple sessions to a VISA
resource simultaneously. Applications can, therefore, access
a VISA resource concurrently through different sessions.
However, in certain cases, applications accessing a VISA
resource may want to restrict other applications from
accessing that resource.
Lock Functions
For example, when an application needs to perform
successive write operations on a resource, the application
may require that, during the sequence of writes, no other
operation can be invoked through any other session to that
resource. For such circumstances, VISA defines a locking
mechanism that restricts access to resources.
The VISA locking mechanism enforces arbitration of accesses
to VISA resources on a per- session basis. If a session locks a
resource, operations invoked on the resource through other
sessions either are serviced or are returned with an error,
depending on the operation and the type of lock used.
If a VISA resource is not locked by any of its sessions, all
sessions have full privilege to invoke any operation and
update any global attributes. Sessions are not required to
have locks to invoke operations or update global attributes.
However, if some other session has already locked the
resource, attempts to update global attributes or invoke
certain operations will fail.
See descriptions of the individual VISA functions in the
VISA Online Help to determine which would fail when a
resource is locked.
viLock/viUnlock Functions
The VISA viLock function is used to acquire a lock on a
resource.