From owner-p4-projects@FreeBSD.ORG Tue Feb 15 01:32:33 2005 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id EF87C16A4D0; Tue, 15 Feb 2005 01:32:31 +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 B32E416A4CE for ; Tue, 15 Feb 2005 01:32:31 +0000 (GMT) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 7FA5143D4C for ; Tue, 15 Feb 2005 01:32:31 +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 j1F1WVYV069613 for ; Tue, 15 Feb 2005 01:32:31 GMT (envelope-from davidxu@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.1/8.13.1/Submit) id j1F1WVRR069610 for perforce@freebsd.org; Tue, 15 Feb 2005 01:32:31 GMT (envelope-from davidxu@freebsd.org) Date: Tue, 15 Feb 2005 01:32:31 GMT Message-Id: <200502150132.j1F1WVRR069610@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 71086 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: Tue, 15 Feb 2005 01:32:33 -0000 http://perforce.freebsd.org/chv.cgi?CH=71086 Change 71086 by davidxu@davidxu_tiger on 2005/02/15 01:32:10 Change default stack size to 2M for 64 bits machine, 1M for 32 bits machine. Affected files ... .. //depot/projects/davidxu_thread/src/lib/libthread/thread/thr_attr.c#4 edit .. //depot/projects/davidxu_thread/src/lib/libthread/thread/thr_create.c#7 edit .. //depot/projects/davidxu_thread/src/lib/libthread/thread/thr_init.c#11 edit .. //depot/projects/davidxu_thread/src/lib/libthread/thread/thr_private.h#20 edit .. //depot/projects/davidxu_thread/src/lib/libthread/thread/thr_stack.c#5 edit Differences ... ==== //depot/projects/davidxu_thread/src/lib/libthread/thread/thr_attr.c#4 (text+ko) ==== @@ -321,15 +321,15 @@ int ret; pthread_attr_t pattr; + _thr_check_init(); + /* Allocate memory for the attribute object: */ if ((pattr = (pthread_attr_t) malloc(sizeof(struct pthread_attr))) == NULL) /* Insufficient memory: */ ret = ENOMEM; else { /* Initialise the attribute object with the defaults: */ - memcpy(pattr, &_pthread_attr_default, - sizeof(struct pthread_attr)); - pattr->guardsize_attr = _thr_guard_default; + memcpy(pattr, &_pthread_attr_default, sizeof(struct pthread_attr)); /* Return a pointer to the attribute object: */ *attr = pattr; ==== //depot/projects/davidxu_thread/src/lib/libthread/thread/thr_create.c#7 (text+ko) ==== @@ -91,9 +91,9 @@ */ } - if (_thread_scope_system > 0) + if (_thr_scope_system > 0) new_thread->attr.flags |= PTHREAD_SCOPE_SYSTEM; - else if (_thread_scope_system < 0) + else if (_thr_scope_system < 0) new_thread->attr.flags &= ~PTHREAD_SCOPE_SYSTEM; if (create_stack(&new_thread->attr) != 0) { ==== //depot/projects/davidxu_thread/src/lib/libthread/thread/thr_init.c#11 (text+ko) ==== @@ -329,7 +329,7 @@ * resource limits, so this stack needs an explicitly mapped * red zone to protect the thread stack that is just beyond. */ - if (mmap((void *)_usrstack - THR_STACK_INITIAL - + if (mmap((void *)_usrstack - _thr_stack_initial - _thr_guard_default, _thr_guard_default, 0, MAP_ANON, -1, 0) == MAP_FAILED) PANIC("Cannot allocate red zone for initial thread"); @@ -343,8 +343,8 @@ * actually free() it; it just puts it in the free * stack queue for later reuse. */ - thread->attr.stackaddr_attr = (void *)_usrstack - THR_STACK_INITIAL; - thread->attr.stacksize_attr = THR_STACK_INITIAL; + thread->attr.stackaddr_attr = (void *)_usrstack - _thr_stack_initial; + thread->attr.stacksize_attr = _thr_stack_initial; thread->attr.guardsize_attr = _thr_guard_default; thread->attr.flags |= THR_STACK_USER; @@ -399,16 +399,17 @@ PANIC("Cannot get kern.usrstack from sysctl"); _thr_page_size = getpagesize(); _thr_guard_default = _thr_page_size; - _pthread_attr_default.guardsize_attr = _thr_guard_default; - + _pthread_attr_default.guardsize_attr = _thr_guard_default; + _pthread_attr_default.stacksize_attr = _thr_stack_default; + TAILQ_INIT(&_thr_atfork_list); #ifdef SYSTEM_SCOPE_ONLY - _thread_scope_system = 1; + _thr_scope_system = 1; #else if (getenv("LIBPTHREAD_SYSTEM_SCOPE") != NULL) - _thread_scope_system = 1; + _thr_scope_system = 1; else if (getenv("LIBPTHREAD_PROCESS_SCOPE") != NULL) - _thread_scope_system = -1; + _thr_scope_system = -1; #endif } init_once = 1; ==== //depot/projects/davidxu_thread/src/lib/libthread/thread/thr_private.h#20 (text+ko) ==== @@ -255,14 +255,14 @@ /* * Miscellaneous definitions. */ -#define THR_STACK_DEFAULT 0x100000 +#define THR_STACK_DEFAULT (sizeof(void *) / 4 * 1024 * 1024) /* * Maximum size of initial thread's stack. This perhaps deserves to be larger * than the stacks of other threads, since many applications are likely to run * almost entirely on this stack. */ -#define THR_STACK_INITIAL 0x200000 +#define THR_STACK_INITIAL (THR_STACK_DEFAULT * 2) /* * Define the different priority ranges. All applications have thread @@ -584,8 +584,8 @@ SCLASS void *_usrstack SCLASS_PRESET(NULL); SCLASS struct pthread *_thr_initial SCLASS_PRESET(NULL); /* For debugger */ -SCLASS int _libkse2_debug SCLASS_PRESET(0); -SCLASS int _thread_scope_system SCLASS_PRESET(0); +SCLASS int _libthread_debug SCLASS_PRESET(0); +SCLASS int _thr_scope_system SCLASS_PRESET(0); /* List of all threads: */ SCLASS TAILQ_HEAD(, pthread) _thread_list @@ -634,6 +634,8 @@ SCLASS pid_t _thr_pid SCLASS_PRESET(0); SCLASS int _thr_guard_default; +SCLASS int _thr_stack_default SCLASS_PRESET(THR_STACK_DEFAULT); +SCLASS int _thr_stack_initial SCLASS_PRESET(THR_STACK_INITIAL); SCLASS int _thr_page_size; /* Garbage thread count. */ SCLASS int _gc_count SCLASS_PRESET(0); ==== //depot/projects/davidxu_thread/src/lib/libthread/thread/thr_stack.c#5 (text+ko) ==== @@ -187,7 +187,7 @@ else { /* Allocate a stack from usrstack. */ if (last_stack == NULL) - last_stack = _usrstack - THR_STACK_INITIAL - + last_stack = _usrstack - _thr_stack_initial - _thr_guard_default; /* Allocate a new stack. */