Always use growable thread stacks on the i386. The VM_STACK kernel option

must be made default for the alpha before growable thread stacks are
enabled for the alpha.
This commit is contained in:
Jason Evans 1999-07-06 00:25:38 +00:00
parent 5cb0ef41b5
commit 876cc3dae0
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=48609
14 changed files with 51 additions and 88 deletions

View file

@ -1,4 +1,4 @@
# $Id: Makefile,v 1.16 1999/07/05 00:35:14 jasone Exp $
# $Id: Makefile,v 1.17 1999/07/05 00:38:12 jasone Exp $
#
# All library objects contain rcsid strings by default; they may be
# excluded as a space-saving measure. To produce a library that does
@ -15,9 +15,6 @@ CFLAGS+=-DPTHREAD_KERNEL -D_THREAD_SAFE -I${.CURDIR}/uthread
# thread locking.
CFLAGS+=-D_LOCK_DEBUG
# Uncomment this if you want libc_r to use growable stacks.
#CFLAGS+=-D_PTHREAD_GSTACK
AINC= -I${.CURDIR}/../libc/${MACHINE_ARCH} -I${.CURDIR}/uthread
PRECIOUSLIB= yes

View file

@ -31,7 +31,7 @@
*
* Private thread definitions for the uthread kernel.
*
* $Id: pthread_private.h,v 1.20 1999/06/20 08:28:08 jb Exp $
* $Id: pthread_private.h,v 1.21 1999/07/05 00:35:17 jasone Exp $
*/
#ifndef _PTHREAD_PRIVATE_H
@ -335,23 +335,23 @@ struct pthread_attr {
* Miscellaneous definitions.
*/
#define PTHREAD_STACK_DEFAULT 65536
#ifdef _PTHREAD_GSTACK
/* Size of red zone at the end of each stack. */
#define PTHREAD_STACK_GUARD 4096
/* Maximum size of initial thread's stack. This perhaps deserves to be larger
* than the stacks of other threads, since legacy applications are likely to run
* than the stacks of other threads, since many applications are likely to run
* almost entirely on this stack. */
#define PTHREAD_STACK_INITIAL 0x100000
/* Address immediately beyond the beginning of the initial thread stack. */
#if defined(__FreeBSD__)
# if defined(__alpha__)
# define PTHREAD_STACK_TOP 0x160022000
# else
# define PTHREAD_STACK_TOP 0xbfbde000
# endif
# if defined(__i386__)
# define PTHREAD_STACK_TOP 0xbfbde000
# elif defined(__alpha__)
# define PTHREAD_STACK_TOP 0x160022000
# else
# error "Don't recognize this architecture!"
# endif
#else
# error "Don't recognize this operating system!"
#endif
# error "Don't recognize this operating system!"
#endif
#define PTHREAD_DEFAULT_PRIORITY 64
#define PTHREAD_MAX_PRIORITY 126
@ -673,12 +673,10 @@ struct pthread {
int lineno; /* Source line number. */
};
#ifdef _PTHREAD_GSTACK
/* Spare thread stack. */
struct stack {
SLIST_ENTRY(stack) qe; /* Queue entry for this stack. */
};
#endif
/*
* Global variables for the uthread kernel.
@ -889,7 +887,6 @@ SCLASS pthread_switch_routine_t _sched_switch_hook
#endif
;
#ifdef _PTHREAD_GSTACK
/* Spare stack queue. Stacks of default size are cached in order to reduce
* thread creation time. Spare stacks are used in LIFO order to increase cache
* locality. */
@ -905,7 +902,6 @@ SCLASS void * _next_stack
= (void *) PTHREAD_STACK_TOP - PTHREAD_STACK_INITIAL - PTHREAD_STACK_DEFAULT - (2 * PTHREAD_STACK_GUARD)
#endif
;
#endif
/* Used for _PTHREADS_INVARIANTS checking. */
SCLASS int _thread_kern_new_state

View file

@ -29,7 +29,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: uthread_create.c,v 1.13 1999/06/20 08:28:14 jb Exp $
* $Id: uthread_create.c,v 1.14 1999/07/05 00:35:17 jasone Exp $
*/
#include <errno.h>
#include <stdlib.h>
@ -37,10 +37,8 @@
#include <fcntl.h>
#include <unistd.h>
#include <sys/time.h>
#ifdef _PTHREAD_GSTACK
#include <sys/types.h>
#include <sys/mman.h>
#endif
#ifdef _THREAD_SAFE
#include <machine/reg.h>
#include <pthread.h>
@ -81,7 +79,7 @@ pthread_create(pthread_t * thread, const pthread_attr_t * attr,
/* Check if a stack was specified in the thread attributes: */
if ((stack = pattr->stackaddr_attr) != NULL) {
}
#ifdef _PTHREAD_GSTACK
#ifdef __i386__
/* Allocate memory for a default-size stack: */
else if (pattr->stacksize_attr == PTHREAD_STACK_DEFAULT) {
struct stack * spare_stack;

View file

@ -29,7 +29,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: uthread_gc.c,v 1.4 1999/06/20 08:28:25 jb Exp $
* $Id: uthread_gc.c,v 1.5 1999/07/05 00:35:18 jasone Exp $
*
* Garbage collector thread. Frees memory allocated for dead threads.
*
@ -38,10 +38,8 @@
#include <time.h>
#include <unistd.h>
#include <sys/types.h>
#ifdef _PTHREAD_GSTACK
#include <sys/types.h>
#include <sys/mman.h>
#endif
#include <pthread.h>
#include "pthread_private.h"
@ -136,7 +134,7 @@ _thread_gc(pthread_addr_t arg)
*/
if (pthread->attr.stackaddr_attr == NULL &&
pthread->stack != NULL) {
#ifdef _PTHREAD_GSTACK
#ifdef __i386__
if (pthread->attr.stacksize_attr == PTHREAD_STACK_DEFAULT) {
/* Default-size stack. Cache it: */
struct stack * spare_stack = (pthread->stack + PTHREAD_STACK_DEFAULT
@ -172,7 +170,7 @@ _thread_gc(pthread_addr_t arg)
*/
if (pthread->attr.stackaddr_attr == NULL &&
pthread->stack != NULL) {
#ifdef _PTHREAD_GSTACK
#ifdef __i386__
if (pthread->attr.stacksize_attr == PTHREAD_STACK_DEFAULT) {
/* Default-size stack. Cache it: */
struct stack * spare_stack = (pthread->stack + PTHREAD_STACK_DEFAULT

View file

@ -29,7 +29,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: uthread_init.c,v 1.12 1999/06/23 15:01:21 dt Exp $
* $Id: uthread_init.c,v 1.13 1999/07/05 00:35:19 jasone Exp $
*/
/* Allocate space for global thread variables here: */
@ -45,10 +45,8 @@
#include <sys/sysctl.h>
#include <sys/time.h>
#include <sys/ttycom.h>
#ifdef _PTHREAD_GSTACK
#include <sys/types.h>
#include <sys/mman.h>
#endif
#ifdef _THREAD_SAFE
#include <machine/reg.h>
#include <pthread.h>
@ -182,7 +180,7 @@ _thread_init(void)
/* Initialize the scheduling switch hook routine: */
_sched_switch_hook = NULL;
#ifdef _PTHREAD_GSTACK
#ifdef __i386__
/* Initialize the thread stack cache: */
SLIST_INIT(&_stackq);

View file

@ -1,4 +1,4 @@
# $Id: Makefile,v 1.16 1999/07/05 00:35:14 jasone Exp $
# $Id: Makefile,v 1.17 1999/07/05 00:38:12 jasone Exp $
#
# All library objects contain rcsid strings by default; they may be
# excluded as a space-saving measure. To produce a library that does
@ -15,9 +15,6 @@ CFLAGS+=-DPTHREAD_KERNEL -D_THREAD_SAFE -I${.CURDIR}/uthread
# thread locking.
CFLAGS+=-D_LOCK_DEBUG
# Uncomment this if you want libc_r to use growable stacks.
#CFLAGS+=-D_PTHREAD_GSTACK
AINC= -I${.CURDIR}/../libc/${MACHINE_ARCH} -I${.CURDIR}/uthread
PRECIOUSLIB= yes

View file

@ -29,7 +29,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: uthread_create.c,v 1.13 1999/06/20 08:28:14 jb Exp $
* $Id: uthread_create.c,v 1.14 1999/07/05 00:35:17 jasone Exp $
*/
#include <errno.h>
#include <stdlib.h>
@ -37,10 +37,8 @@
#include <fcntl.h>
#include <unistd.h>
#include <sys/time.h>
#ifdef _PTHREAD_GSTACK
#include <sys/types.h>
#include <sys/mman.h>
#endif
#ifdef _THREAD_SAFE
#include <machine/reg.h>
#include <pthread.h>
@ -81,7 +79,7 @@ pthread_create(pthread_t * thread, const pthread_attr_t * attr,
/* Check if a stack was specified in the thread attributes: */
if ((stack = pattr->stackaddr_attr) != NULL) {
}
#ifdef _PTHREAD_GSTACK
#ifdef __i386__
/* Allocate memory for a default-size stack: */
else if (pattr->stacksize_attr == PTHREAD_STACK_DEFAULT) {
struct stack * spare_stack;

View file

@ -29,7 +29,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: uthread_init.c,v 1.12 1999/06/23 15:01:21 dt Exp $
* $Id: uthread_init.c,v 1.13 1999/07/05 00:35:19 jasone Exp $
*/
/* Allocate space for global thread variables here: */
@ -45,10 +45,8 @@
#include <sys/sysctl.h>
#include <sys/time.h>
#include <sys/ttycom.h>
#ifdef _PTHREAD_GSTACK
#include <sys/types.h>
#include <sys/mman.h>
#endif
#ifdef _THREAD_SAFE
#include <machine/reg.h>
#include <pthread.h>
@ -182,7 +180,7 @@ _thread_init(void)
/* Initialize the scheduling switch hook routine: */
_sched_switch_hook = NULL;
#ifdef _PTHREAD_GSTACK
#ifdef __i386__
/* Initialize the thread stack cache: */
SLIST_INIT(&_stackq);

View file

@ -31,7 +31,7 @@
*
* Private thread definitions for the uthread kernel.
*
* $Id: pthread_private.h,v 1.20 1999/06/20 08:28:08 jb Exp $
* $Id: pthread_private.h,v 1.21 1999/07/05 00:35:17 jasone Exp $
*/
#ifndef _PTHREAD_PRIVATE_H
@ -335,23 +335,23 @@ struct pthread_attr {
* Miscellaneous definitions.
*/
#define PTHREAD_STACK_DEFAULT 65536
#ifdef _PTHREAD_GSTACK
/* Size of red zone at the end of each stack. */
#define PTHREAD_STACK_GUARD 4096
/* Maximum size of initial thread's stack. This perhaps deserves to be larger
* than the stacks of other threads, since legacy applications are likely to run
* than the stacks of other threads, since many applications are likely to run
* almost entirely on this stack. */
#define PTHREAD_STACK_INITIAL 0x100000
/* Address immediately beyond the beginning of the initial thread stack. */
#if defined(__FreeBSD__)
# if defined(__alpha__)
# define PTHREAD_STACK_TOP 0x160022000
# else
# define PTHREAD_STACK_TOP 0xbfbde000
# endif
# if defined(__i386__)
# define PTHREAD_STACK_TOP 0xbfbde000
# elif defined(__alpha__)
# define PTHREAD_STACK_TOP 0x160022000
# else
# error "Don't recognize this architecture!"
# endif
#else
# error "Don't recognize this operating system!"
#endif
# error "Don't recognize this operating system!"
#endif
#define PTHREAD_DEFAULT_PRIORITY 64
#define PTHREAD_MAX_PRIORITY 126
@ -673,12 +673,10 @@ struct pthread {
int lineno; /* Source line number. */
};
#ifdef _PTHREAD_GSTACK
/* Spare thread stack. */
struct stack {
SLIST_ENTRY(stack) qe; /* Queue entry for this stack. */
};
#endif
/*
* Global variables for the uthread kernel.
@ -889,7 +887,6 @@ SCLASS pthread_switch_routine_t _sched_switch_hook
#endif
;
#ifdef _PTHREAD_GSTACK
/* Spare stack queue. Stacks of default size are cached in order to reduce
* thread creation time. Spare stacks are used in LIFO order to increase cache
* locality. */
@ -905,7 +902,6 @@ SCLASS void * _next_stack
= (void *) PTHREAD_STACK_TOP - PTHREAD_STACK_INITIAL - PTHREAD_STACK_DEFAULT - (2 * PTHREAD_STACK_GUARD)
#endif
;
#endif
/* Used for _PTHREADS_INVARIANTS checking. */
SCLASS int _thread_kern_new_state

View file

@ -1,4 +1,4 @@
# $Id: Makefile,v 1.16 1999/07/05 00:35:14 jasone Exp $
# $Id: Makefile,v 1.17 1999/07/05 00:38:12 jasone Exp $
#
# All library objects contain rcsid strings by default; they may be
# excluded as a space-saving measure. To produce a library that does
@ -15,9 +15,6 @@ CFLAGS+=-DPTHREAD_KERNEL -D_THREAD_SAFE -I${.CURDIR}/uthread
# thread locking.
CFLAGS+=-D_LOCK_DEBUG
# Uncomment this if you want libc_r to use growable stacks.
#CFLAGS+=-D_PTHREAD_GSTACK
AINC= -I${.CURDIR}/../libc/${MACHINE_ARCH} -I${.CURDIR}/uthread
PRECIOUSLIB= yes

View file

@ -29,7 +29,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: uthread_create.c,v 1.13 1999/06/20 08:28:14 jb Exp $
* $Id: uthread_create.c,v 1.14 1999/07/05 00:35:17 jasone Exp $
*/
#include <errno.h>
#include <stdlib.h>
@ -37,10 +37,8 @@
#include <fcntl.h>
#include <unistd.h>
#include <sys/time.h>
#ifdef _PTHREAD_GSTACK
#include <sys/types.h>
#include <sys/mman.h>
#endif
#ifdef _THREAD_SAFE
#include <machine/reg.h>
#include <pthread.h>
@ -81,7 +79,7 @@ pthread_create(pthread_t * thread, const pthread_attr_t * attr,
/* Check if a stack was specified in the thread attributes: */
if ((stack = pattr->stackaddr_attr) != NULL) {
}
#ifdef _PTHREAD_GSTACK
#ifdef __i386__
/* Allocate memory for a default-size stack: */
else if (pattr->stacksize_attr == PTHREAD_STACK_DEFAULT) {
struct stack * spare_stack;

View file

@ -29,7 +29,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: uthread_gc.c,v 1.4 1999/06/20 08:28:25 jb Exp $
* $Id: uthread_gc.c,v 1.5 1999/07/05 00:35:18 jasone Exp $
*
* Garbage collector thread. Frees memory allocated for dead threads.
*
@ -38,10 +38,8 @@
#include <time.h>
#include <unistd.h>
#include <sys/types.h>
#ifdef _PTHREAD_GSTACK
#include <sys/types.h>
#include <sys/mman.h>
#endif
#include <pthread.h>
#include "pthread_private.h"
@ -136,7 +134,7 @@ _thread_gc(pthread_addr_t arg)
*/
if (pthread->attr.stackaddr_attr == NULL &&
pthread->stack != NULL) {
#ifdef _PTHREAD_GSTACK
#ifdef __i386__
if (pthread->attr.stacksize_attr == PTHREAD_STACK_DEFAULT) {
/* Default-size stack. Cache it: */
struct stack * spare_stack = (pthread->stack + PTHREAD_STACK_DEFAULT
@ -172,7 +170,7 @@ _thread_gc(pthread_addr_t arg)
*/
if (pthread->attr.stackaddr_attr == NULL &&
pthread->stack != NULL) {
#ifdef _PTHREAD_GSTACK
#ifdef __i386__
if (pthread->attr.stacksize_attr == PTHREAD_STACK_DEFAULT) {
/* Default-size stack. Cache it: */
struct stack * spare_stack = (pthread->stack + PTHREAD_STACK_DEFAULT

View file

@ -29,7 +29,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: uthread_init.c,v 1.12 1999/06/23 15:01:21 dt Exp $
* $Id: uthread_init.c,v 1.13 1999/07/05 00:35:19 jasone Exp $
*/
/* Allocate space for global thread variables here: */
@ -45,10 +45,8 @@
#include <sys/sysctl.h>
#include <sys/time.h>
#include <sys/ttycom.h>
#ifdef _PTHREAD_GSTACK
#include <sys/types.h>
#include <sys/mman.h>
#endif
#ifdef _THREAD_SAFE
#include <machine/reg.h>
#include <pthread.h>
@ -182,7 +180,7 @@ _thread_init(void)
/* Initialize the scheduling switch hook routine: */
_sched_switch_hook = NULL;
#ifdef _PTHREAD_GSTACK
#ifdef __i386__
/* Initialize the thread stack cache: */
SLIST_INIT(&_stackq);

View file

@ -31,7 +31,7 @@
*
* Private thread definitions for the uthread kernel.
*
* $Id: pthread_private.h,v 1.20 1999/06/20 08:28:08 jb Exp $
* $Id: pthread_private.h,v 1.21 1999/07/05 00:35:17 jasone Exp $
*/
#ifndef _PTHREAD_PRIVATE_H
@ -335,23 +335,23 @@ struct pthread_attr {
* Miscellaneous definitions.
*/
#define PTHREAD_STACK_DEFAULT 65536
#ifdef _PTHREAD_GSTACK
/* Size of red zone at the end of each stack. */
#define PTHREAD_STACK_GUARD 4096
/* Maximum size of initial thread's stack. This perhaps deserves to be larger
* than the stacks of other threads, since legacy applications are likely to run
* than the stacks of other threads, since many applications are likely to run
* almost entirely on this stack. */
#define PTHREAD_STACK_INITIAL 0x100000
/* Address immediately beyond the beginning of the initial thread stack. */
#if defined(__FreeBSD__)
# if defined(__alpha__)
# define PTHREAD_STACK_TOP 0x160022000
# else
# define PTHREAD_STACK_TOP 0xbfbde000
# endif
# if defined(__i386__)
# define PTHREAD_STACK_TOP 0xbfbde000
# elif defined(__alpha__)
# define PTHREAD_STACK_TOP 0x160022000
# else
# error "Don't recognize this architecture!"
# endif
#else
# error "Don't recognize this operating system!"
#endif
# error "Don't recognize this operating system!"
#endif
#define PTHREAD_DEFAULT_PRIORITY 64
#define PTHREAD_MAX_PRIORITY 126
@ -673,12 +673,10 @@ struct pthread {
int lineno; /* Source line number. */
};
#ifdef _PTHREAD_GSTACK
/* Spare thread stack. */
struct stack {
SLIST_ENTRY(stack) qe; /* Queue entry for this stack. */
};
#endif
/*
* Global variables for the uthread kernel.
@ -889,7 +887,6 @@ SCLASS pthread_switch_routine_t _sched_switch_hook
#endif
;
#ifdef _PTHREAD_GSTACK
/* Spare stack queue. Stacks of default size are cached in order to reduce
* thread creation time. Spare stacks are used in LIFO order to increase cache
* locality. */
@ -905,7 +902,6 @@ SCLASS void * _next_stack
= (void *) PTHREAD_STACK_TOP - PTHREAD_STACK_INITIAL - PTHREAD_STACK_DEFAULT - (2 * PTHREAD_STACK_GUARD)
#endif
;
#endif
/* Used for _PTHREADS_INVARIANTS checking. */
SCLASS int _thread_kern_new_state