Date: Sat, 16 Apr 2005 13:09:02 GMT From: David Xu <davidxu@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 75320 for review Message-ID: <200504161309.j3GD9265068980@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=75320 Change 75320 by davidxu@davidxu_tiger on 2005/04/16 13:08:28 Greatly improved the speed of thread creation by using thr_create2. we no longer have to silly doing getcontext->makecontext->sigprocmask thr_create->i386_set_gsbase->sigprocmask. Affected files ... .. //depot/projects/davidxu_thread/src/lib/libthr/thread/thr_create.c#11 edit Differences ... ==== //depot/projects/davidxu_thread/src/lib/libthr/thread/thr_create.c#11 (text+ko) ==== @@ -56,6 +56,7 @@ ucontext_t uc; sigset_t sigmask, oldsigmask; struct pthread *curthread, *new_thread; + struct thr_param param; int ret = 0, locked; _thr_check_init(); @@ -108,11 +109,13 @@ new_thread->arg = arg; new_thread->cancelflags = PTHREAD_CANCEL_ENABLE | PTHREAD_CANCEL_DEFERRED; +#if 0 getcontext(&uc); SIGFILLSET(uc.uc_sigmask); uc.uc_stack.ss_sp = new_thread->attr.stackaddr_attr; uc.uc_stack.ss_size = new_thread->attr.stacksize_attr; makecontext(&uc, (void (*)(void))thread_start, 1, new_thread); +#endif /* * Check if this thread is to inherit the scheduling * attributes from its parent: @@ -145,6 +148,7 @@ if (new_thread->attr.suspend == THR_CREATE_SUSPENDED) new_thread->flags = THR_FLAGS_SUSPENDED; new_thread->state = PS_RUNNING; +#if 0 /* * Thread created by thr_create() inherits currrent thread * sigmask, however, before new thread setup itself correctly, @@ -154,6 +158,7 @@ SIGDELSET(sigmask, SIGTRAP); __sys_sigprocmask(SIG_SETMASK, &sigmask, &oldsigmask); new_thread->sigmask = oldsigmask; +#endif /* Add the new thread. */ _thr_link(curthread, new_thread); /* Return thread pointer eariler so that new thread can use it. */ @@ -163,9 +168,23 @@ locked = 1; } else locked = 0; + param.start_func = thread_start; + param.arg = new_thread; + param.stack_base = new_thread->attr.stackaddr_attr; + param.stack_size = new_thread->attr.stacksize_attr; + param.tls_base = new_thread->tcb; + param.tls_size = sizeof(struct tcb); + param.tls_seg = 0; + param.child_tid = &new_thread->tid; + param.parent_tid = &new_thread->tid; + param.user_crit = 0; + param.flags = 0; /* Schedule the new thread. */ + ret = thr_create2(¶m, sizeof(param)); +#if 0 ret = thr_create(&uc, &new_thread->tid, 0); __sys_sigprocmask(SIG_SETMASK, &oldsigmask, NULL); +#endif if (ret != 0) { if (locked) THR_THREAD_UNLOCK(curthread, new_thread); @@ -218,11 +237,12 @@ static void thread_start(struct pthread *curthread) { +#if 0 _tcb_set(curthread->tcb); /* Thread was created with all signals blocked, unblock them. */ __sys_sigprocmask(SIG_SETMASK, &curthread->sigmask, NULL); - +#endif if (curthread->flags & THR_FLAGS_NEED_SUSPEND) _thr_suspend_check(curthread);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200504161309.j3GD9265068980>