diff options
author | Andrey Shedel <ashedel@microsoft.com> | 2017-03-24 15:01:41 -0700 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2017-03-27 14:41:01 +0200 |
commit | 12f8def0e02232d7c6416ad9b66640f973c531d1 (patch) | |
tree | f9fd9f5eec4dd121034a8a16ded54fcfd6c4c4cc /include | |
parent | dfd0dcc71724b11e125f67c8710c50c41da6ee4a (diff) | |
download | qemu-12f8def0e02232d7c6416ad9b66640f973c531d1.zip qemu-12f8def0e02232d7c6416ad9b66640f973c531d1.tar.gz qemu-12f8def0e02232d7c6416ad9b66640f973c531d1.tar.bz2 |
win32: replace custom mutex and condition variable with native primitives
The multithreaded TCG implementation exposed deadlocks in the win32
condition variables: as implemented, qemu_cond_broadcast waited on
receivers, whereas the pthreads API it was intended to emulate does
not. This was causing a deadlock because broadcast was called while
holding the IO lock, as well as all possible waiters blocked on the
same lock.
This patch replaces all the custom synchronisation code for mutexes
and condition variables with native Windows primitives (SRWlocks and
condition variables) with the same semantics as their POSIX
equivalents. To enable that, it requires a Windows Vista or newer host
OS.
Signed-off-by: Andrey Shedel <ashedel@microsoft.com>
[AB: edited commit message]
Signed-off-by: Andrew Baumann <Andrew.Baumann@microsoft.com>
Message-Id: <20170324220141.10104-1-Andrew.Baumann@microsoft.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'include')
-rw-r--r-- | include/qemu/thread-win32.h | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/include/qemu/thread-win32.h b/include/qemu/thread-win32.h index 5fb6541..4c4a261 100644 --- a/include/qemu/thread-win32.h +++ b/include/qemu/thread-win32.h @@ -4,8 +4,7 @@ #include <windows.h> struct QemuMutex { - CRITICAL_SECTION lock; - LONG owner; + SRWLOCK lock; }; typedef struct QemuRecMutex QemuRecMutex; @@ -19,9 +18,7 @@ int qemu_rec_mutex_trylock(QemuRecMutex *mutex); void qemu_rec_mutex_unlock(QemuRecMutex *mutex); struct QemuCond { - LONG waiters, target; - HANDLE sema; - HANDLE continue_event; + CONDITION_VARIABLE var; }; struct QemuSemaphore { |