diff options
| author | ad <ad@NetBSD.org> | 2007-08-16 00:41:23 +0000 |
|---|---|---|
| committer | ad <ad@NetBSD.org> | 2007-08-16 00:41:23 +0000 |
| commit | ed964af19e1ed43279e00b2f82a04221b7c86966 (patch) | |
| tree | 18ebb4459cf83b940a380f3d216be0629cbddbe6 /lib/libpthread/pthread_stack.c | |
| parent | c94f5a91bc17f5f1064742ceb2fd6faa18043543 (diff) | |
Cache thread context for creation instead of setting it up every time.
Speeds create/join loop by about 10-15% on i386.
Diffstat (limited to 'lib/libpthread/pthread_stack.c')
| -rw-r--r-- | lib/libpthread/pthread_stack.c | 24 |
1 files changed, 2 insertions, 22 deletions
diff --git a/lib/libpthread/pthread_stack.c b/lib/libpthread/pthread_stack.c index fa3c8332284..bfbfcd3c05a 100644 --- a/lib/libpthread/pthread_stack.c +++ b/lib/libpthread/pthread_stack.c @@ -1,4 +1,4 @@ -/* $NetBSD: pthread_stack.c,v 1.20 2007/03/02 18:53:54 ad Exp $ */ +/* $NetBSD: pthread_stack.c,v 1.21 2007/08/16 00:41:24 ad Exp $ */ /*- * Copyright (c) 2001, 2006, 2007 The NetBSD Foundation, Inc. @@ -37,7 +37,7 @@ */ #include <sys/cdefs.h> -__RCSID("$NetBSD: pthread_stack.c,v 1.20 2007/03/02 18:53:54 ad Exp $"); +__RCSID("$NetBSD: pthread_stack.c,v 1.21 2007/08/16 00:41:24 ad Exp $"); #define __EXPOSE_STACK 1 #include <sys/param.h> @@ -151,22 +151,6 @@ pthread__initmain(pthread_t *newt) errx(2, "failed to setup main thread: error=%d", error); } - /* - * The "safe" area chosen below isn't safe for the initial thread stack - * because we don't control the end of the stack. - * For example, on i386 the stack usually ends at 0xbfc00000, - * so for requested sizes >=8MB, the last 4MB of stack isn't available. - * Also, we don't want to clobber the argv, environment, etc. - * Reset the initial pt_uc pointer to be safe for the initial thread. - */ - -#ifdef __MACHINE_STACK_GROWS_UP - t->pt_uc = (ucontext_t *) - ((char *)t->pt_stack.ss_sp + t->pt_stack.ss_size - - sizeof (ucontext_t)); -#else - t->pt_uc = (ucontext_t *)t->pt_stack.ss_sp; -#endif *newt = t; } @@ -198,10 +182,6 @@ pthread__stackid_setup(void *base, size_t size, pthread_t *tp) sp = (caddr_t)t->pt_stack.ss_sp + t->pt_stack.ss_size; #endif - /* Set up an initial ucontext pointer to a "safe" area */ - t->pt_uc = (ucontext_t *)(void *) - STACK_ALIGN(STACK_GROW(sp, pagesize / 2), ~_UC_UCONTEXT_ALIGN); - /* Protect the next-to-bottom stack page as a red zone. */ ret = mprotect(redaddr, pagesize, PROT_NONE); if (ret == -1) { |
