From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LfYZI-00011V-VD for qemu-devel@nongnu.org; Fri, 06 Mar 2009 06:50:21 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LfYZH-0000yz-4u for qemu-devel@nongnu.org; Fri, 06 Mar 2009 06:50:19 -0500 Received: from [199.232.76.173] (port=54929 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LfYZG-0000ye-Td for qemu-devel@nongnu.org; Fri, 06 Mar 2009 06:50:18 -0500 Received: from server1linux.rebelnetworks.com ([66.135.44.167]:47514) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1LfYZG-0002Qd-Hj for qemu-devel@nongnu.org; Fri, 06 Mar 2009 06:50:18 -0500 From: Julian Seward Subject: Re: [Qemu-devel] Race condition between signal handler and cpu_exec() Date: Fri, 6 Mar 2009 12:49:28 +0100 References: <20090305221412.GI17410@hall.aurel32.net> <20090306010555.GC13735@shareable.org> In-Reply-To: <20090306010555.GC13735@shareable.org> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200903061249.29263.jseward@acm.org> Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org On Friday 06 March 2009, Jamie Lokier wrote: > Aurelien Jarno wrote: > > I am currently too tired to find a proper solution (which should only > > use read/write to a variable to keep the operations atomic), I'll look > > at that tomorrow, but patches are welcome in the meanwhile. > > The theoretically right thing in C is read/write a "volatile > sig_atomic_t". It looks to me like this requires to atomically test that a bit in a byte is set, and if so clear it. That would require a lock;cmpxchg sequence on x86 and lwarx/stwcx on ppc. I wonder if it can be done with gcc's __sync_bool_compare_and_swap builtin, in order to make it portable. J