[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH] use a thread id variable

From: Jamie Lokier
Subject: Re: [Qemu-devel] [PATCH] use a thread id variable
Date: Sun, 9 Mar 2008 20:01:54 +0000
User-agent: Mutt/1.5.13 (2006-08-11)

M. Warner Losh wrote:
> In message: <address@hidden>
>             Jamie Lokier <address@hidden> 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

reply via email to

[Prev in Thread] Current Thread [Next in Thread]