[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
[Qemu-devel] Re: [PATCH 0/3] Expose thread id through info cpus, Glauber Costa, 2008/03/05
[Qemu-devel] Re: [PATCH 0/3] Expose thread id through info cpus, Avi Kivity, 2008/03/06