From owner-p4-projects@FreeBSD.ORG Sat Apr 16 13:09:03 2005 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 82AC416A4D0; Sat, 16 Apr 2005 13:09:03 +0000 (GMT) Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 57A4316A4CE for ; Sat, 16 Apr 2005 13:09:03 +0000 (GMT) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id E365143D54 for ; Sat, 16 Apr 2005 13:09:02 +0000 (GMT) (envelope-from davidxu@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.1/8.13.1) with ESMTP id j3GD92RH068983 for ; Sat, 16 Apr 2005 13:09:02 GMT (envelope-from davidxu@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.1/8.13.1/Submit) id j3GD9265068980 for perforce@freebsd.org; Sat, 16 Apr 2005 13:09:02 GMT (envelope-from davidxu@freebsd.org) Date: Sat, 16 Apr 2005 13:09:02 GMT Message-Id: <200504161309.j3GD9265068980@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to davidxu@freebsd.org using -f From: David Xu To: Perforce Change Reviews Subject: PERFORCE change 75320 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 16 Apr 2005 13:09:04 -0000 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);