Messages in this thread |  | | Date | Fri, 1 Sep 2000 18:15:52 -0700 (PDT) | From | Linus Torvalds <> | Subject | Re: 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/
|  |