mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-01 23:03:54 -06:00
util/qemu-thread-*: add qemu_lock, locked and unlock trace events
Signed-off-by: Alex Bennée <alex.bennee@linaro.org> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
parent
15a356c49a
commit
6c27a0ded9
4 changed files with 62 additions and 25 deletions
|
@ -56,30 +56,32 @@ void qemu_mutex_destroy(QemuMutex *mutex)
|
|||
InitializeSRWLock(&mutex->lock);
|
||||
}
|
||||
|
||||
void qemu_mutex_lock(QemuMutex *mutex)
|
||||
void qemu_mutex_lock_impl(QemuMutex *mutex, const char *file, const int line)
|
||||
{
|
||||
assert(mutex->initialized);
|
||||
trace_qemu_mutex_lock(mutex, file, line);
|
||||
|
||||
AcquireSRWLockExclusive(&mutex->lock);
|
||||
trace_qemu_mutex_locked(mutex);
|
||||
trace_qemu_mutex_locked(mutex, file, line);
|
||||
}
|
||||
|
||||
int qemu_mutex_trylock(QemuMutex *mutex)
|
||||
int qemu_mutex_trylock_impl(QemuMutex *mutex, const char *file, const int line)
|
||||
{
|
||||
int owned;
|
||||
|
||||
assert(mutex->initialized);
|
||||
owned = TryAcquireSRWLockExclusive(&mutex->lock);
|
||||
if (owned) {
|
||||
trace_qemu_mutex_locked(mutex);
|
||||
trace_qemu_mutex_locked(mutex, file, line);
|
||||
return 0;
|
||||
}
|
||||
return -EBUSY;
|
||||
}
|
||||
|
||||
void qemu_mutex_unlock(QemuMutex *mutex)
|
||||
void qemu_mutex_unlock_impl(QemuMutex *mutex, const char *file, const int line)
|
||||
{
|
||||
assert(mutex->initialized);
|
||||
trace_qemu_mutex_unlocked(mutex);
|
||||
trace_qemu_mutex_unlock(mutex, file, line);
|
||||
ReleaseSRWLockExclusive(&mutex->lock);
|
||||
}
|
||||
|
||||
|
@ -140,12 +142,12 @@ void qemu_cond_broadcast(QemuCond *cond)
|
|||
WakeAllConditionVariable(&cond->var);
|
||||
}
|
||||
|
||||
void qemu_cond_wait(QemuCond *cond, QemuMutex *mutex)
|
||||
void qemu_cond_wait_impl(QemuCond *cond, QemuMutex *mutex, const char *file, const int line)
|
||||
{
|
||||
assert(cond->initialized);
|
||||
trace_qemu_mutex_unlocked(mutex);
|
||||
trace_qemu_mutex_unlock(mutex, file, line);
|
||||
SleepConditionVariableSRW(&cond->var, &mutex->lock, INFINITE, 0);
|
||||
trace_qemu_mutex_locked(mutex);
|
||||
trace_qemu_mutex_locked(mutex, file, line);
|
||||
}
|
||||
|
||||
void qemu_sem_init(QemuSemaphore *sem, int init)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue