From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LfZhV-0000Me-1n for qemu-devel@nongnu.org; Fri, 06 Mar 2009 08:02:53 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LfZhT-0000MR-HJ for qemu-devel@nongnu.org; Fri, 06 Mar 2009 08:02:52 -0500 Received: from [199.232.76.173] (port=43070 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LfZhT-0000MO-Dv for qemu-devel@nongnu.org; Fri, 06 Mar 2009 08:02:51 -0500 Received: from mail2.shareable.org ([80.68.89.115]:37823) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1LfZhS-0006UW-HJ for qemu-devel@nongnu.org; Fri, 06 Mar 2009 08:02:50 -0500 Date: Fri, 6 Mar 2009 13:02:45 +0000 From: Jamie Lokier Subject: Re: [Qemu-devel] Race condition between signal handler and cpu_exec() Message-ID: <20090306130245.GA24685@shareable.org> References: <20090305221412.GI17410@hall.aurel32.net> <20090306010555.GC13735@shareable.org> <200903061249.29263.jseward@acm.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <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: Julian Seward Cc: qemu-devel@nongnu.org Julian Seward wrote: > 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. No, it only requires that if you keep with the same representation. If you move that bit into its very own variable, just for the one bit, you can read/write the whole variable. _That's_ portable (assuming a suitable variable type is used). -- Jamie