lkml.org 
[lkml]   [2000]   [Sep]   [1]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: thread group comments


On Sat, 2 Sep 2000, Andi Kleen wrote:
>
> But I guess you don't want the context switch to a thread manager just to
> generate a thread ? (and which is one of the main causes of the bad thread
> creation latency in Linux currently)

No, you don't need that. Here it is again:

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
*/
i_am_the_master_thread();
exit(0);
}
/*
* 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 ..
}

and as Uli points out the only thing you need to do is to switch the
stacks around when you do the nasty "switch threads from under the users
feet" thing.

Linus

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/

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