[lkml]   [2000]   [Aug]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: SCO: "thread creation is about a thousand times faster than on

On Thu, 24 Aug 2000, Andi Kleen wrote:
> >
> > Right: so clone with the PARENT flag set. What's the problem?
> Then your original parent would see any thread deaths. Probably not
> what you wanted.

No, it's exactly what you want.

What you do is that the _master_ thread starts out with just CLONE_PID,
but any subsequent thread uses CLONE_PID | CLONE_PARENT.

And no, obviously a pthreads application doesn't even realize anything
like this is going on. What the code would look like is something like

int pthread_create()
static int has_done_this_before = 0;
pid_t newtid;

if (!has_done_this_before) {
pid_t tid;
has_done_this_before = 1;
tid = clone(CLONE_PID);
if (tid > 0) {
* original thread becomes hidden master
* thread, and never returns
* initial CLONE_PID thread comes here,
* it is now one of the "regular children".
newtid = clone(CLONE_PID | CLONE_PARENT);
.. now we have the two "pthread" threads here ..

See? (And no, the above is not the syntax for clone(), it's just meant to
kind of show what the intent is).


To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
Please read the FAQ at

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