diff options
Diffstat (limited to 'lib/libpthread/thread/thr_private.h')
-rw-r--r-- | lib/libpthread/thread/thr_private.h | 46 |
1 files changed, 44 insertions, 2 deletions
diff --git a/lib/libpthread/thread/thr_private.h b/lib/libpthread/thread/thr_private.h index 036ea80..1da2151 100644 --- a/lib/libpthread/thread/thr_private.h +++ b/lib/libpthread/thread/thr_private.h @@ -31,7 +31,7 @@ * * Private thread definitions for the uthread kernel. * - * $Id$ + * $Id: pthread_private.h,v 1.20 1999/06/20 08:28:08 jb Exp $ */ #ifndef _PTHREAD_PRIVATE_H @@ -335,6 +335,24 @@ 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 + * 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 +#else +# error "Don't recognize this operating system!" +#endif +#endif #define PTHREAD_DEFAULT_PRIORITY 64 #define PTHREAD_MAX_PRIORITY 126 #define PTHREAD_MIN_PRIORITY 0 @@ -655,6 +673,13 @@ 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. */ @@ -864,6 +889,24 @@ 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. */ +SCLASS SLIST_HEAD(, stack) _stackq; + +/* Base address of next unallocated default-size stack. Stacks are allocated + * contiguously, starting below the beginning of the main stack. When a new + * stack is created, a guard page is created just above it in order to (usually) + * detect attempts by the adjacent stack to trounce the next thread stack. */ +SCLASS void * _next_stack +#ifdef GLOBAL_PTHREAD_PRIVATE +/* main stack top - main stack size - stack size - (red zone + main stack red zone) */ += (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 #ifdef GLOBAL_PTHREAD_PRIVATE @@ -871,7 +914,6 @@ SCLASS int _thread_kern_new_state #endif ; - /* Undefine the storage class specifier: */ #undef SCLASS |