From 5a4f095bcdd59976ffc8b7b61620e7eb1a2078a1 Mon Sep 17 00:00:00 2001 From: Jack Moffitt Date: Sat, 20 Oct 2001 22:27:52 +0000 Subject: [PATCH] Stack size per thread needs to be configurable. Setting it on a global bases is not enough. ices and icecast need this to be different, and if one is interested in tuning memory usage, one will want to alter this per thread. svn path=/trunk/thread/; revision=2217 --- thread/thread.c | 7 ++----- thread/thread.h | 4 +++- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/thread/thread.c b/thread/thread.c index 60089d3..94387ff 100644 --- a/thread/thread.c +++ b/thread/thread.c @@ -56,9 +56,6 @@ #define LOG_DEBUG2(y, z1, z2) log_write(_logid, 4, CATMODULE "/" __FUNCTION__, y, z1, z2) #define LOG_DEBUG5(y, z1, z2, z3, z4, z5) log_write(_logid, 4, CATMODULE "/" __FUNCTION__, y, z1, z2, z3, z4, z5) -/* INTERNAL DATA */ -#define STACKSIZE 8192 - /* thread starting structure */ typedef struct thread_start_tag { /* the real start routine and arg */ @@ -223,7 +220,7 @@ static void _catch_signals(void) } -long thread_create_c(char *name, void *(*start_routine)(void *), void *arg, int detached, int line, char *file) +long thread_create_c(char *name, void *(*start_routine)(void *), void *arg, int stacksize, int detached, int line, char *file) { pthread_attr_t attr; int created; @@ -248,7 +245,7 @@ long thread_create_c(char *name, void *(*start_routine)(void *), void *arg, int start->detached = detached; pthread_attr_init(&attr); - pthread_attr_setstacksize(&attr, STACKSIZE); + pthread_attr_setstacksize(&attr, stacksize); created = 0; if (pthread_create(&thread->sys_thread, &attr, _start_routine, start) == 0) diff --git a/thread/thread.h b/thread/thread.h index a352265..f032d30 100644 --- a/thread/thread.h +++ b/thread/thread.h @@ -24,6 +24,8 @@ #include +#define THREAD_DEFAULT_STACKSIZE 8192 + typedef struct thread_tag { /* the local id for the thread, and it's name */ long thread_id; @@ -78,7 +80,7 @@ typedef struct rwlock_tag { pthread_rwlock_t sys_rwlock; } rwlock_t; -#define thread_create(n,x,y,z) thread_create_c(n,x,y,z,__LINE__,__FILE__) +#define thread_create(n,w,x,y,z) thread_create_c(n,w,x,y,z,__LINE__,__FILE__) #define thread_mutex_create(x) thread_mutex_create_c(x,__LINE__,__FILE__) #define thread_mutex_lock(x) thread_mutex_lock_c(x,__LINE__,__FILE__) #define thread_mutex_unlock(x) thread_mutex_unlock_c(x,__LINE__,__FILE__)