On 2/21/22 12:11, Daniel P. Berrangé wrote:
As a point of history, the original code only used sem_t. The pthreads
based fallback was introduced by Paolo in
commit c166cb72f1676855816340666c3b618beef4b976
Author: Paolo Bonzini <pbonz...@redhat.com>
Date: Fri Nov 2 15:43:21 2012 +0100
semaphore: implement fallback counting semaphores with mutex+condvar
OpenBSD and Darwin do not have sem_timedwait. Implement a fallback
for them.
Signed-off-by: Paolo Bonzini <pbonz...@redhat.com>
Signed-off-by: Anthony Liguori <aligu...@us.ibm.com>
I'm going to assume this fallback impl is less efficient than the
native sem_t impl as the reason for leaving the original impl, or
maybe Paolo just want to risk accidental bugs by removing the
existing usage ?
Yes, it is a bit less efficient. But really there aren't any places
where semaphores vs. mutex+condvar will make a difference. The original
reason to use semaphores was that Windows had a hand-written condition
variable implementation that didn't support cond_timedwait.
Paolo