thread-posix: implement Semaphore with QemuCond and QemuMutex

Now that QemuSemaphore is implemented through pthread_cond_t only, we can use
QemuCond and QemuMutex to make the code smaller.  Features such as mutex
tracing and CLOCK_MONOTONIC timedwait are supported in qemu-sem naturally.

Signed-off-by: Longpeng(Mike) <longpeng2@huawei.com>
Message-Id: <20220222090507.2028-4-longpeng2@huawei.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
Longpeng(Mike) 2022-02-22 17:05:06 +08:00 committed by Paolo Bonzini
parent 657ac98b58
commit a0d45db854
2 changed files with 34 additions and 76 deletions

View file

@ -27,10 +27,9 @@ struct QemuCond {
};
struct QemuSemaphore {
pthread_mutex_t lock;
pthread_cond_t cond;
QemuMutex mutex;
QemuCond cond;
unsigned int count;
bool initialized;
};
struct QemuEvent {