Re: Thread implementations...

David Wragg (dpw@doc.ic.ac.uk)
23 Jun 1998 15:02:18 +0000


alan@lxorguk.ukuu.org.uk (Alan Cox) writes:
> > Both of these problem could be neatly solved if the kernel
> > knew that thread-like processes live in teams. There are other
>
> Sort of a thread group like process group model. You need to do that
> cleanly however to keep it fast and Linus happy.

Last night I added a small amount of kernel support, so that I can
modify LinuxThreads for direct thread creation and find out what the
improvements to pthread_create might actually be.

A CLONE_MINOR flag to clone creates a /minor process/. When a minor
process clones/forks a new process, the parent of the new process is
the parent of the minor process, rather than the minor process
itself. So by using CLONE_MINOR, all the threads become child
processes of the initial process.

So for LinuxThreads using CLONE_MINOR, the initial process becomes the
manager thread. Whenever a threads exits (by any means), the manager
(as the parent) gets the child death signal. Hence it can accurately
keep track of all live threads.

The changes to the kernel are tiny, it fixes one problem nicely, and
doesn't seem to create any new ones.

> > motivations for this: reasonable ps output, and robust gdb thread
> > support.
>
> gdb doesnt need that. CLONE_PTRACE hints is all that is needed on the
> kernel side

Yes, I soon realised both of these things were bogus. There can be a
process flag to tell ps that the process is a thread and so (unless
some option is given) be ignored.

The things I was clutching for when those popped into my head were
POSIXly correct threaded signal handling and wait(). I'm now examining
whether CLONE_MINOR support could be extended to deal with these. (it
should be easier than making CLONE_PID work properly, which would
require the same sorts of changes plus adding thread IDs and some new
syscalls).

--
Dave Wragg

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