mirror of
https://git.proxmox.com/git/qemu
synced 2025-08-01 02:03:57 +00:00
add Win32 IPI service
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
This commit is contained in:
parent
b55c22c65b
commit
cc015e9a5d
25
cpus.c
25
cpus.c
@ -854,13 +854,32 @@ static void *qemu_tcg_cpu_thread_fn(void *arg)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void qemu_cpu_kick_thread(CPUState *env)
|
||||||
|
{
|
||||||
|
#ifndef _WIN32
|
||||||
|
int err;
|
||||||
|
|
||||||
|
err = pthread_kill(env->thread->thread, SIG_IPI);
|
||||||
|
if (err) {
|
||||||
|
fprintf(stderr, "qemu:%s: %s", __func__, strerror(err));
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
#else /* _WIN32 */
|
||||||
|
if (!qemu_cpu_is_self(env)) {
|
||||||
|
SuspendThread(env->thread->thread);
|
||||||
|
cpu_signal(0);
|
||||||
|
ResumeThread(env->thread->thread);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
void qemu_cpu_kick(void *_env)
|
void qemu_cpu_kick(void *_env)
|
||||||
{
|
{
|
||||||
CPUState *env = _env;
|
CPUState *env = _env;
|
||||||
|
|
||||||
qemu_cond_broadcast(env->halt_cond);
|
qemu_cond_broadcast(env->halt_cond);
|
||||||
if (!env->thread_kicked) {
|
if (!env->thread_kicked) {
|
||||||
qemu_thread_signal(env->thread, SIG_IPI);
|
qemu_cpu_kick_thread(env);
|
||||||
env->thread_kicked = true;
|
env->thread_kicked = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -871,7 +890,7 @@ void qemu_cpu_kick_self(void)
|
|||||||
assert(cpu_single_env);
|
assert(cpu_single_env);
|
||||||
|
|
||||||
if (!cpu_single_env->thread_kicked) {
|
if (!cpu_single_env->thread_kicked) {
|
||||||
qemu_thread_signal(cpu_single_env->thread, SIG_IPI);
|
qemu_cpu_kick_thread(cpu_single_env);
|
||||||
cpu_single_env->thread_kicked = true;
|
cpu_single_env->thread_kicked = true;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
@ -893,7 +912,7 @@ void qemu_mutex_lock_iothread(void)
|
|||||||
} else {
|
} else {
|
||||||
qemu_mutex_lock(&qemu_fair_mutex);
|
qemu_mutex_lock(&qemu_fair_mutex);
|
||||||
if (qemu_mutex_trylock(&qemu_global_mutex)) {
|
if (qemu_mutex_trylock(&qemu_global_mutex)) {
|
||||||
qemu_thread_signal(tcg_cpu_thread, SIG_IPI);
|
qemu_cpu_kick_thread(first_cpu);
|
||||||
qemu_mutex_lock(&qemu_global_mutex);
|
qemu_mutex_lock(&qemu_global_mutex);
|
||||||
}
|
}
|
||||||
qemu_mutex_unlock(&qemu_fair_mutex);
|
qemu_mutex_unlock(&qemu_fair_mutex);
|
||||||
|
@ -171,15 +171,6 @@ void qemu_thread_create(QemuThread *thread,
|
|||||||
pthread_sigmask(SIG_SETMASK, &oldset, NULL);
|
pthread_sigmask(SIG_SETMASK, &oldset, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void qemu_thread_signal(QemuThread *thread, int sig)
|
|
||||||
{
|
|
||||||
int err;
|
|
||||||
|
|
||||||
err = pthread_kill(thread->thread, sig);
|
|
||||||
if (err)
|
|
||||||
error_exit(err, __func__);
|
|
||||||
}
|
|
||||||
|
|
||||||
void qemu_thread_get_self(QemuThread *thread)
|
void qemu_thread_get_self(QemuThread *thread)
|
||||||
{
|
{
|
||||||
thread->thread = pthread_self();
|
thread->thread = pthread_self();
|
||||||
|
@ -14,5 +14,4 @@ struct QemuThread {
|
|||||||
pthread_t thread;
|
pthread_t thread;
|
||||||
};
|
};
|
||||||
|
|
||||||
void qemu_thread_signal(QemuThread *thread, int sig);
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user