void *entry_arg;
Coroutine *caller;
QSLIST_ENTRY(Coroutine) pool_next;
+ size_t locks_held;
/* Coroutines that should be woken up when we yield or terminate */
QSIMPLEQ_HEAD(, Coroutine) co_queue_wakeup;
mutex->locked = true;
mutex->holder = self;
+ self->locks_held++;
trace_qemu_co_mutex_lock_return(mutex, self);
}
mutex->locked = false;
mutex->holder = NULL;
+ self->locks_held--;
qemu_co_queue_next(&mutex->queue);
trace_qemu_co_mutex_unlock_return(mutex, self);
void qemu_co_rwlock_rdlock(CoRwlock *lock)
{
+ Coroutine *self = qemu_coroutine_self();
+
while (lock->writer) {
qemu_co_queue_wait(&lock->queue);
}
lock->reader++;
+ self->locks_held++;
}
void qemu_co_rwlock_unlock(CoRwlock *lock)
{
+ Coroutine *self = qemu_coroutine_self();
+
assert(qemu_in_coroutine());
if (lock->writer) {
lock->writer = false;
qemu_co_queue_next(&lock->queue);
}
}
+ self->locks_held--;
}
void qemu_co_rwlock_wrlock(CoRwlock *lock)
{
+ Coroutine *self = qemu_coroutine_self();
+
while (lock->writer || lock->reader) {
qemu_co_queue_wait(&lock->queue);
}
lock->writer = true;
+ self->locks_held++;
}