From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=40014 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PyRvy-0004Um-Ba for qemu-devel@nongnu.org; Sat, 12 Mar 2011 11:44:55 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PyRvx-00043Z-1o for qemu-devel@nongnu.org; Sat, 12 Mar 2011 11:44:54 -0500 Received: from mail-wy0-f173.google.com ([74.125.82.173]:53088) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PyRvw-0003tD-Sy for qemu-devel@nongnu.org; Sat, 12 Mar 2011 11:44:52 -0500 Received: by mail-wy0-f173.google.com with SMTP id 42so3523531wyb.4 for ; Sat, 12 Mar 2011 08:44:52 -0800 (PST) Sender: Paolo Bonzini From: Paolo Bonzini Date: Sat, 12 Mar 2011 17:44:08 +0100 Message-Id: <1299948248-30206-22-git-send-email-pbonzini@redhat.com> In-Reply-To: <1299948248-30206-1-git-send-email-pbonzini@redhat.com> References: <1299948248-30206-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PATCH v4 upstream 21/21] add Win32 IPI service List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: blauwirbel@gmail.com Signed-off-by: Paolo Bonzini --- cpus.c | 25 ++++++++++++++++++++++--- qemu-thread-posix.c | 9 --------- qemu-thread-posix.h | 1 - 3 files changed, 22 insertions(+), 13 deletions(-) diff --git a/cpus.c b/cpus.c index 7559a02..077729c 100644 --- a/cpus.c +++ b/cpus.c @@ -854,13 +854,32 @@ static void *qemu_tcg_cpu_thread_fn(void *arg) 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) { CPUState *env = _env; qemu_cond_broadcast(env->halt_cond); if (!env->thread_kicked) { - qemu_thread_signal(env->thread, SIG_IPI); + qemu_cpu_kick_thread(env); env->thread_kicked = true; } } @@ -871,7 +890,7 @@ void qemu_cpu_kick_self(void) assert(cpu_single_env); 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; } #else @@ -893,7 +912,7 @@ void qemu_mutex_lock_iothread(void) } else { qemu_mutex_lock(&qemu_fair_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_unlock(&qemu_fair_mutex); diff --git a/qemu-thread-posix.c b/qemu-thread-posix.c index 8b54cc0..87c1a9f 100644 --- a/qemu-thread-posix.c +++ b/qemu-thread-posix.c @@ -171,15 +171,6 @@ void qemu_thread_create(QemuThread *thread, 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) { thread->thread = pthread_self(); diff --git a/qemu-thread-posix.h b/qemu-thread-posix.h index 7af371c..ee4618e 100644 --- a/qemu-thread-posix.h +++ b/qemu-thread-posix.h @@ -14,5 +14,4 @@ struct QemuThread { pthread_t thread; }; -void qemu_thread_signal(QemuThread *thread, int sig); #endif -- 1.7.4