From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:34274) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RLvoi-0003Gu-Mw for qemu-devel@nongnu.org; Thu, 03 Nov 2011 07:50:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RLvog-0008I6-TM for qemu-devel@nongnu.org; Thu, 03 Nov 2011 07:50:44 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41567) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RLvog-0008Hx-ME for qemu-devel@nongnu.org; Thu, 03 Nov 2011 07:50:42 -0400 Message-ID: <4EB27FF6.2040907@redhat.com> Date: Thu, 03 Nov 2011 12:50:14 +0100 From: Paolo Bonzini MIME-Version: 1.0 References: <4EB1640F.2090604@adacore.com> <4EB1796B.7050901@adacore.com> <4EB181C4.1090501@redhat.com> <4EB19F6B.8020907@redhat.com> <4EB264D5.6070009@adacore.com> <4EB2689F.3060205@redhat.com> <4EB26CF4.7080806@redhat.com> In-Reply-To: <4EB26CF4.7080806@redhat.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] Multiple instances of Qemu on Windows multicore List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Avi Kivity Cc: Peter Maydell , qemu-devel@nongnu.org, Fabien Chouteau On 11/03/2011 11:29 AM, Avi Kivity wrote: > > It would ensure that two mutators wouldn't run concurrently. In some > > sense, signal-safe code could then be considered thread-safe too. > > How so? The scheduler can switch between the two threads on every > instruction. In general signal-safe is more stringent than thread-safe, but with two exceptions: memory barriers and locked memory access. On x86 (implied by Windows...) you might also assume that the compiler will generate arithmetic operations with a memory destination, which makes code like void cpu_interrupt(CPUState *env, int mask) { env->interrupt_request |= mask; /* <--- this */ cpu_unlink_tb(env); } signal-safe in practice---and even "thread-safe" on non-SMP systems. It's a huge assumption though, and I don't think it should be assumed anymore. With iothread the architecture of the QEMU main loop is anyway completely different. Paolo