lkml.org 
[lkml]   [1998]   [Jun]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: Thread implementations...
Date
In article <k27m2egm8h.fsf@zero.aec.at>, Andi Kleen <ak@muc.de> wrote:
>Linux (LinuxThreads) has is it not really right unfortunately. There is
>no way to send a signal to a process consisting of multiple threads and
>it to be delivered to the first thread that has it unblocked (as defined
>in POSIX) - it will be always delivered to the thread with the pid it was
>directed to.
>
>To fix it CLONE_PID would need to be made fully working.

How about this, I thought this up one night when I could not sleep
so I have no idea if it still makes sense. It's about creating a
"thread group". All threads still have their own PID but share a
TID (Thread group ID) or TGID.


1. When a process calls clone() with CLONE_TID, the calling process becomes
"thread group leader". All it's children, and children of those created
by clone() with CLONE_TID share the thread id, which is the PID of the
first process.

2. All processes still have their own PID.

3. Synchronous signals (generated by the thread execution, e.g. SIGFPE)
are delivered to the thread/pid that raised them.

4. A fatal asynchronous (ie not blocked or caught) signal to any of the threads
causes the signalhandler for that signal to be unblocked, and set to default
for all members of the thread group. The signal is then sent to all threads.

5. An asynchronous signal sent to any thread is handled by the thread or,
if the thread has blocked the signal, by any other thread in the group
that hasn't blocked the signal, but at most to one thread.
Q: what if all threads have blocked the signal? Which one will get
the signal as "pending" ? A: the original thread?

6. Signals to the process group will behave as if sent only to the
thread group leader. Ofcourse (5) still holds.

Ofcourse you also might be able to do something with CLONE_SIGHAND. Perhaps
in combination with the above.

Mike.
--
Miquel van Smoorenburg | Our vision is to speed up time,
miquels@cistron.nl | eventually eliminating it.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu

\
 
 \ /
  Last update: 2005-03-22 13:43    [W:0.417 / U:0.184 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site