From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JYRif-0003cP-0L for qemu-devel@nongnu.org; Sun, 09 Mar 2008 16:02:05 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JYRid-0003aQ-0I for qemu-devel@nongnu.org; Sun, 09 Mar 2008 16:02:04 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JYRic-0003aH-Rf for qemu-devel@nongnu.org; Sun, 09 Mar 2008 16:02:02 -0400 Received: from mail2.shareable.org ([80.68.89.115]) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1JYRic-00079v-8A for qemu-devel@nongnu.org; Sun, 09 Mar 2008 16:02:02 -0400 Date: Sun, 9 Mar 2008 20:01:54 +0000 From: Jamie Lokier Subject: Re: [Qemu-devel] [PATCH] use a thread id variable Message-ID: <20080309200154.GA16225@shareable.org> References: <12047472772114-git-send-email-gcosta@redhat.com> <47D3AD53.6030809@codefidence.com> <20080309115826.GA8077@shareable.org> <20080309.100911.844330500.imp@bsdimp.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20080309.100911.844330500.imp@bsdimp.com> Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "M. Warner Losh" Cc: kvm-devel@lists.sourceforge.net, glommer@gmail.com, qemu-devel@nongnu.org, chrisw@sous-sol.org, gcosta@redhat.com M. Warner Losh wrote: > In message: <20080309115826.GA8077@shareable.org> > Jamie Lokier writes: > : Btw, unfortunately pthread_self() is not safe to call from signal > : handlers. > > And also often times meaningless, as signal handlers can run in > arbitrary threads... That's usually the case, but sometimes it is useful. Some causes of signals are thread specific, or can be asked to be, and it's nice to know which thread is receiving them (e.g. thread specific timers, SIGIOs, write-protection SEGVs, and even sending messages with good old pthread_kill (same reason as kernel uses IPIs)). GCC's Boehm garbage collector uses pthread_self() from a signal handler. I've used gettid() in a signal handler on a few occasions. -- Jamie