* Question about threads and signals
@ 2003-01-18 3:24 Jamie Lokier
2003-01-18 3:51 ` Ulrich Drepper
0 siblings, 1 reply; 3+ messages in thread
From: Jamie Lokier @ 2003-01-18 3:24 UTC (permalink / raw)
To: linux-kernel; +Cc: Ingo Molnar, Ulrich Drepper
Dear POSIX thread experts (i.e. Ingo and Ulrich),
I have a teensy question. Using the new Linux 2.5 threads + glibc/NPTL:
1. If a signal is delivered to a thread, is it masked for the duration of
the handler in (a) just that thread or (b) all threads?
In other words, if I have 3 threads and SIGIO is not blocked in any
of them, is it possible for my SIGIO handler to be called up to 3
times concurrently? Or is the blocked mask somehow shared?
Is the same thing true of SIGCHLD? SIGSEGV?
2. Is this true of POSIX threads in general, or just Linux?
Thanks,
-- Jamie
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Question about threads and signals
2003-01-18 3:24 Question about threads and signals Jamie Lokier
@ 2003-01-18 3:51 ` Ulrich Drepper
2003-01-18 4:49 ` Jamie Lokier
0 siblings, 1 reply; 3+ messages in thread
From: Ulrich Drepper @ 2003-01-18 3:51 UTC (permalink / raw)
To: Jamie Lokier; +Cc: linux-kernel, Ingo Molnar
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Jamie Lokier wrote:
> 1. If a signal is delivered to a thread, is it masked for the duration of
> the handler in (a) just that thread or (b) all threads?
(a)
> In other words, if I have 3 threads and SIGIO is not blocked in any
> of them, is it possible for my SIGIO handler to be called up to 3
> times concurrently? Or is the blocked mask somehow shared?
Masks are never shared.
> Is the same thing true of SIGCHLD? SIGSEGV?
Yes. Up to the point where a fatal signal isn't caught and the process
is killed. At that point all threads except the one responsible for the
termination is stopped and then terminated.
> 2. Is this true of POSIX threads in general, or just Linux?
Well, the above is what POSIX requires and what I think we've
implemented. These requirements are essential for programs which do
much of their work in signal handlers. Creating more threads which
mainly just sit around but can react to signals is a valid programming
model.
- --
- --------------. ,-. 444 Castro Street
Ulrich Drepper \ ,-----------------' \ Mountain View, CA 94041 USA
Red Hat `--' drepper at redhat.com `---------------------------
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)
iD8DBQE+KM8m2ijCOnn/RHQRAlcEAJ0W27Ju6gq4xhT7A0PGr2IJCGfp0ACfa2NY
2mmvlgXLC2Xm8UYnU+rD6cE=
=7eDw
-----END PGP SIGNATURE-----
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Question about threads and signals
2003-01-18 3:51 ` Ulrich Drepper
@ 2003-01-18 4:49 ` Jamie Lokier
0 siblings, 0 replies; 3+ messages in thread
From: Jamie Lokier @ 2003-01-18 4:49 UTC (permalink / raw)
To: Ulrich Drepper; +Cc: linux-kernel, Ingo Molnar
Ulrich Drepper wrote:
> > 2. Is this true of POSIX threads in general, or just Linux?
>
> Well, the above is what POSIX requires and what I think we've
> implemented. These requirements are essential for programs which do
> much of their work in signal handlers.
So, in a program which uses pthread_create(), a SIGCHLD handler must
either (a) be reentrant, or (b) be unblocked (or installed) in one
thread only.
> Creating more threads which mainly just sit around but can react to
> signals is a valid programming model.
Indeed, as Ingo pointed out, some signals are like poor man's threads,
and that programming model makes that explicit. I like that, because
it means the signal handler can validly do everything normal code can
do, including use mutexes and other locking primitives which may sleep.
(Some other signals are intrinsically thread-local though, such as
SIGSEGV and SIGFPE - they are synchronous exception handlers rather
than asynchronous event handlers).
Thanks for your quick answer,
-- Jamie
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2003-01-18 4:40 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-01-18 3:24 Question about threads and signals Jamie Lokier
2003-01-18 3:51 ` Ulrich Drepper
2003-01-18 4:49 ` Jamie Lokier
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox