From patchwork Mon Feb 28 09:10:24 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 84778 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 693231007D3 for ; Mon, 28 Feb 2011 21:48:15 +1100 (EST) Received: from localhost ([127.0.0.1]:37159 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Pu0eC-0007sx-1a for incoming@patchwork.ozlabs.org; Mon, 28 Feb 2011 05:48:12 -0500 Received: from [140.186.70.92] (port=45718 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PtzEg-0005yC-Uh for qemu-devel@nongnu.org; Mon, 28 Feb 2011 04:17:48 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ptz8c-0004no-Sc for qemu-devel@nongnu.org; Mon, 28 Feb 2011 04:11:37 -0500 Received: from mail-gx0-f173.google.com ([209.85.161.173]:57989) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ptz8c-0004dE-K0 for qemu-devel@nongnu.org; Mon, 28 Feb 2011 04:11:30 -0500 Received: by mail-gx0-f173.google.com with SMTP id 28so1785045gxk.4 for ; Mon, 28 Feb 2011 01:11:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:sender:from:to:cc:subject:date:message-id :x-mailer:in-reply-to:references; bh=Feiy9g9Zp9CEMFighmreIAlWiWqIll8mgp/TtWPNFdo=; b=pMEYwssVg2kajxwxqPhaWQ2MooIGwh85FwTcoUlooL6Yv/bwmMrSKogsnjwp6nCRwY QxzL0LblDjwFv3mfgiPa8cR/wmzIa8821nG3Mlp6MKfP5abR71WhOIwahqOby0y/W02c ip/PNx5SGz/pIvvAJVISO0OxxevixOPDhPewk= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; b=ck3mzGdN2AkmcQ9wldVDq9Q72WBZ+SltFrjkJx1/8kzJQxlE6trlpMmCKSRqOgds05 xk7Qim3n/Z9OKB4IHZVgPqXk8yFWCZAwR23c+O+t8TR8ZOWgVGPsTVFEga5WHPnwfl6J 8C0eKx/dsfJsLIsv85UVqY9ze+Fjzjhnzf5CQ= Received: by 10.236.116.71 with SMTP id f47mr695555yhh.24.1298884290517; Mon, 28 Feb 2011 01:11:30 -0800 (PST) Received: from localhost.localdomain (93-34-149-100.ip50.fastwebnet.it [93.34.149.100]) by mx.google.com with ESMTPS id 1sm2037209yhl.11.2011.02.28.01.11.28 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 28 Feb 2011 01:11:29 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Mon, 28 Feb 2011 10:10:24 +0100 Message-Id: <1298884224-19734-23-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.7.4 In-Reply-To: <1298884224-19734-1-git-send-email-pbonzini@redhat.com> References: <1298884224-19734-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 209.85.161.173 Cc: blauwirbel@gmail.com, jan.kiszka@siemes.com, aurelien@aurel32.net, kvm@vger.kernel.org, mtosatti@redhat.com Subject: [Qemu-devel] [PATCH v3 uq/master 22/22] add Win32 IPI service X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 a4c6e25..9cceda7 100644 --- a/qemu-thread-posix.c +++ b/qemu-thread-posix.c @@ -186,15 +186,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 11978db..35e0a8b 100644 --- a/qemu-thread-posix.h +++ b/qemu-thread-posix.h @@ -15,5 +15,4 @@ struct QemuThread { pthread_t thread; }; -void qemu_thread_signal(QemuThread *thread, int sig); #endif