Function panda_sys::qemu_lockcnt_inc[][src]

pub unsafe extern "C" fn qemu_lockcnt_inc(lockcnt: *mut QemuLockCnt)
Expand description

qemu_lockcnt_inc: increment a QemuLockCnt’s counter @lockcnt: the lockcnt to operate on

If the lockcnt’s count is zero, wait for critical sections to finish and increment lockcnt’s count to 1. If the count is not zero, just increment it.

Because this function can wait on the mutex, it must not be called while the lockcnt’s mutex is held by the current thread. For the same reason, qemu_lockcnt_inc can also contribute to AB-BA deadlocks. This is a sample deadlock scenario:

       thread 1                      thread 2
       -------------------------------------------------------
       qemu_lockcnt_lock(&lc1);
                                     qemu_lockcnt_lock(&lc2);
       qemu_lockcnt_inc(&lc2);
                                     qemu_lockcnt_inc(&lc1);