From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NSKZP-00082A-QE for qemu-devel@nongnu.org; Tue, 05 Jan 2010 20:20:19 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NSKZL-0007y5-VY for qemu-devel@nongnu.org; Tue, 05 Jan 2010 20:20:19 -0500 Received: from [199.232.76.173] (port=59037 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NSKZL-0007xq-KX for qemu-devel@nongnu.org; Tue, 05 Jan 2010 20:20:15 -0500 Received: from mail2.shareable.org ([80.68.89.115]:35894) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1NSKZL-0007aG-Ao for qemu-devel@nongnu.org; Tue, 05 Jan 2010 20:20:15 -0500 Date: Wed, 6 Jan 2010 01:20:10 +0000 From: Jamie Lokier Subject: Re: [Qemu-devel] Re: [PATCH 11/19] use a bottom half to run timers Message-ID: <20100106012010.GB25683@shareable.org> References: <1261382970-23251-1-git-send-email-pbonzini@redhat.com> <1261382970-23251-12-git-send-email-pbonzini@redhat.com> <4B424E95.4040806@codemonkey.ws> <4B42491C.1050709@redhat.com> <4B4280FC.4020602@codemonkey.ws> <4B43350A.7000309@redhat.com> <4B43394C.1040106@codemonkey.ws> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4B43394C.1040106@codemonkey.ws> List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Anthony Liguori Cc: Paolo Bonzini , qemu-devel@nongnu.org Anthony Liguori wrote: > Thread and signal safety are slightly different. They are very different: Virtually all libc calls are thread safe, unless they use unsafe static data APIs. On the other hand, the number of libc calls that are signal safe is very limited. For example, calling printf() is not signal-safe; neither is malloc(). pthread functions are not safe in signal handlers either: pthread_self, pthread_getspecific, pthread_mutex_lock and pthread_cond_broadcast, not of them are signal-safe. In a nutshell, it's dubious to do much inside a signal handler. Pure system calls tend to be ok, though. > Scheduling an idle > callback from a signal handler is a pretty reasonable thing to do. Scheduling, yes, by telling the main event loop that it's time. Running it inside the signal handler... Then you're depending on non-portabilities among hosts. -- Jamie