newly released clone() based pthreads package

Bernhard Kaindl (joot@vnet.ibm.com)
Mon, 22 Jul 1996 18:30:53 -0400 (EDT)


Hi Xavier,

I haven't tried out your clone based POSIX threads package yet, but I
noticed in the README there was a comment about not being able
to share pid's. I was looking in the kernel source ( 2.0.0 )
last night, and it seems to me that all you have to do in order
to share the pid's is set CLONE_PID in the clone flags.
Have you tried this?

I haven't really looked into the kernel scheduler code, but was
wondering about ways to get rid of some of the extra overhead
incurred context switching between two clone() based threads of the
same process.

There are probably some changes that could be made to the kernel to
lower the overhead of switching between two threads of the same
process. The one that I can think of is sharing of all thread invariant
task_struct data. When the clone() ( do_fork() ) routine is called
a new struct task_struct is allocated, and the clone()'ing process's
entire task_struct is copied. Perhaps it would be a good idea to
rework task_struct with threading in mind -- have it contain a
pointer to a structure that contains the process information that is
thread invariant, and share this data between threads rather than coping
it. There could also be some places where things could be shared on
a copy-on-write basis. This may reduce some the overhead
associated with context switching two threads of the same process -- if
a process is creating lots of threads, then it's likely that it will
have to context switch repeatedly between it's own threads, and
this could perhaps make a significant difference.

If the overhead between switching such threads could be reduced, then
perhaps the scheduler could give a thread context switch a higher
priority than a process context switch since it wouldn't take as much
work to do. I don't know how feasible this is, however.

What do think?

Peeter

--
 Peeter Joot          TOROLAB(PJOOT)         joot@vnet.ibm.com
 IBM Canada           Tie Line 778-3186      Phone 416-448-3186