Nested Locks

NI-VISA

Nested Locks

VISA supports nested locking. That is, a session can lock the same resource multiple times (for the same lock type). Unlocking the resource requires an equal number of invocations of the viUnlock() operation. Each session maintains a separate lock count for each type of locks. Repeated invocations of the viLock() operation for the same session increase the appropriate lock count, depending on the type of lock requested. In the case of shared locks, nesting viLock() calls return with the same accessKey every time. In the case of exclusive locks, viLock() does not return an accessKey, regardless of whether it is nested. For each invocation of viUnlock(), the lock count is decremented. VISA unlocks a resource only when the lock count equals 0.