7c9b2bf677
QemuEvents are used heavily by call_rcu. We do not want them to be slow, but the current implementation does a kernel call on every invocation of qemu_event_* and won't cut it. So, wrap a Win32 manual-reset event with a fast userspace path. The states and transitions are the same as for the futex and mutex/condvar implementations, but the slow path is different of course. The idea is to reset the Win32 event lazily, as part of a test-reset-test-wait sequence. Such a sequence is, indeed, how QemuEvents are used by RCU and other subsystems! The patch includes a formal model of the algorithm. Tested-by: Stefan Weil <sw@weilnetz.de> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Stefan Weil <sw@weilnetz.de>
35 lines
555 B
C
35 lines
555 B
C
#ifndef __QEMU_THREAD_WIN32_H
|
|
#define __QEMU_THREAD_WIN32_H 1
|
|
#include "windows.h"
|
|
|
|
struct QemuMutex {
|
|
CRITICAL_SECTION lock;
|
|
LONG owner;
|
|
};
|
|
|
|
struct QemuCond {
|
|
LONG waiters, target;
|
|
HANDLE sema;
|
|
HANDLE continue_event;
|
|
};
|
|
|
|
struct QemuSemaphore {
|
|
HANDLE sema;
|
|
};
|
|
|
|
struct QemuEvent {
|
|
int value;
|
|
HANDLE event;
|
|
};
|
|
|
|
typedef struct QemuThreadData QemuThreadData;
|
|
struct QemuThread {
|
|
QemuThreadData *data;
|
|
unsigned tid;
|
|
};
|
|
|
|
/* Only valid for joinable threads. */
|
|
HANDLE qemu_thread_get_handle(QemuThread *thread);
|
|
|
|
#endif
|