From 91d2ee98318cba6ca2d8e92500ff4c06de7626ce Mon Sep 17 00:00:00 2001 From: jb Date: Wed, 30 Sep 1998 06:22:07 +0000 Subject: - Fix the debug macros. - Add support of a thread being listed in the dead thread list as well as the thread list. - Add a new thread state to make sigwait work properly. (Submitted by Daniel M. Eischen ) - Add global variable for the garbage collector mutex and condition variable. - Delete a couple of prototypes that are no longer required. - Add a prototype for the garbage collector thread. --- lib/libc_r/uthread/pthread_private.h | 25 +++++++++++++++++++++---- lib/libkse/thread/thr_private.h | 25 +++++++++++++++++++++---- lib/libpthread/thread/thr_private.h | 25 +++++++++++++++++++++---- 3 files changed, 63 insertions(+), 12 deletions(-) (limited to 'lib') diff --git a/lib/libc_r/uthread/pthread_private.h b/lib/libc_r/uthread/pthread_private.h index 5b76a86..04600cf 100644 --- a/lib/libc_r/uthread/pthread_private.h +++ b/lib/libc_r/uthread/pthread_private.h @@ -62,8 +62,8 @@ #define PANIC(string) _thread_exit(__FILE__,__LINE__,string) /* Output debug messages like this: */ -#define stdout_debug(_x) _write(1,_x,strlen(_x)); -#define stderr_debug(_x) _write(2,_x,strlen(_x)); +#define stdout_debug(_x) _thread_sys_write(1,_x,strlen(_x)); +#define stderr_debug(_x) _thread_sys_write(2,_x,strlen(_x)); /* * State change macro: @@ -252,6 +252,7 @@ enum pthread_state { PS_SELECT_WAIT, PS_SLEEP_WAIT, PS_WAIT_WAIT, + PS_SIGSUSPEND, PS_SIGWAIT, PS_JOIN, PS_SUSPENDED, @@ -333,6 +334,11 @@ struct pthread { struct pthread *nxt; /* + * Pointer to the next thread in the dead thread linked list. + */ + struct pthread *nxt_dead; + + /* * Thread start routine, argument, stack pointer and thread * attributes. */ @@ -591,6 +597,18 @@ SCLASS int _thread_dtablesize /* Descriptor table size. */ ; #endif +/* Garbage collector mutex and condition variable. */ +SCLASS pthread_mutex_t _gc_mutex +#ifdef GLOBAL_PTHREAD_PRIVATE += NULL +#endif +; +SCLASS pthread_cond_t _gc_cond +#ifdef GLOBAL_PTHREAD_PRIVATE += NULL +#endif +; + /* * Array of signal actions for this process. */ @@ -623,10 +641,8 @@ int _thread_fd_lock(int, int, struct timespec *); int _thread_fd_lock_debug(int, int, struct timespec *,char *fname,int lineno); void _dispatch_signals(void); void _thread_signal(pthread_t, int); -void _lock_dead_thread_list(void); void _lock_thread(void); void _lock_thread_list(void); -void _unlock_dead_thread_list(void); void _unlock_thread(void); void _unlock_thread_list(void); void _thread_exit(char *, int, char *); @@ -649,6 +665,7 @@ int _thread_queue_remove(struct pthread_queue *, struct pthread *); int _thread_fd_table_init(int fd); struct pthread *_thread_queue_get(struct pthread_queue *); struct pthread *_thread_queue_deq(struct pthread_queue *); +pthread_addr_t _thread_gc(pthread_addr_t); /* #include */ int _thread_sys_sigaction(int, const struct sigaction *, struct sigaction *); diff --git a/lib/libkse/thread/thr_private.h b/lib/libkse/thread/thr_private.h index 5b76a86..04600cf 100644 --- a/lib/libkse/thread/thr_private.h +++ b/lib/libkse/thread/thr_private.h @@ -62,8 +62,8 @@ #define PANIC(string) _thread_exit(__FILE__,__LINE__,string) /* Output debug messages like this: */ -#define stdout_debug(_x) _write(1,_x,strlen(_x)); -#define stderr_debug(_x) _write(2,_x,strlen(_x)); +#define stdout_debug(_x) _thread_sys_write(1,_x,strlen(_x)); +#define stderr_debug(_x) _thread_sys_write(2,_x,strlen(_x)); /* * State change macro: @@ -252,6 +252,7 @@ enum pthread_state { PS_SELECT_WAIT, PS_SLEEP_WAIT, PS_WAIT_WAIT, + PS_SIGSUSPEND, PS_SIGWAIT, PS_JOIN, PS_SUSPENDED, @@ -333,6 +334,11 @@ struct pthread { struct pthread *nxt; /* + * Pointer to the next thread in the dead thread linked list. + */ + struct pthread *nxt_dead; + + /* * Thread start routine, argument, stack pointer and thread * attributes. */ @@ -591,6 +597,18 @@ SCLASS int _thread_dtablesize /* Descriptor table size. */ ; #endif +/* Garbage collector mutex and condition variable. */ +SCLASS pthread_mutex_t _gc_mutex +#ifdef GLOBAL_PTHREAD_PRIVATE += NULL +#endif +; +SCLASS pthread_cond_t _gc_cond +#ifdef GLOBAL_PTHREAD_PRIVATE += NULL +#endif +; + /* * Array of signal actions for this process. */ @@ -623,10 +641,8 @@ int _thread_fd_lock(int, int, struct timespec *); int _thread_fd_lock_debug(int, int, struct timespec *,char *fname,int lineno); void _dispatch_signals(void); void _thread_signal(pthread_t, int); -void _lock_dead_thread_list(void); void _lock_thread(void); void _lock_thread_list(void); -void _unlock_dead_thread_list(void); void _unlock_thread(void); void _unlock_thread_list(void); void _thread_exit(char *, int, char *); @@ -649,6 +665,7 @@ int _thread_queue_remove(struct pthread_queue *, struct pthread *); int _thread_fd_table_init(int fd); struct pthread *_thread_queue_get(struct pthread_queue *); struct pthread *_thread_queue_deq(struct pthread_queue *); +pthread_addr_t _thread_gc(pthread_addr_t); /* #include */ int _thread_sys_sigaction(int, const struct sigaction *, struct sigaction *); diff --git a/lib/libpthread/thread/thr_private.h b/lib/libpthread/thread/thr_private.h index 5b76a86..04600cf 100644 --- a/lib/libpthread/thread/thr_private.h +++ b/lib/libpthread/thread/thr_private.h @@ -62,8 +62,8 @@ #define PANIC(string) _thread_exit(__FILE__,__LINE__,string) /* Output debug messages like this: */ -#define stdout_debug(_x) _write(1,_x,strlen(_x)); -#define stderr_debug(_x) _write(2,_x,strlen(_x)); +#define stdout_debug(_x) _thread_sys_write(1,_x,strlen(_x)); +#define stderr_debug(_x) _thread_sys_write(2,_x,strlen(_x)); /* * State change macro: @@ -252,6 +252,7 @@ enum pthread_state { PS_SELECT_WAIT, PS_SLEEP_WAIT, PS_WAIT_WAIT, + PS_SIGSUSPEND, PS_SIGWAIT, PS_JOIN, PS_SUSPENDED, @@ -333,6 +334,11 @@ struct pthread { struct pthread *nxt; /* + * Pointer to the next thread in the dead thread linked list. + */ + struct pthread *nxt_dead; + + /* * Thread start routine, argument, stack pointer and thread * attributes. */ @@ -591,6 +597,18 @@ SCLASS int _thread_dtablesize /* Descriptor table size. */ ; #endif +/* Garbage collector mutex and condition variable. */ +SCLASS pthread_mutex_t _gc_mutex +#ifdef GLOBAL_PTHREAD_PRIVATE += NULL +#endif +; +SCLASS pthread_cond_t _gc_cond +#ifdef GLOBAL_PTHREAD_PRIVATE += NULL +#endif +; + /* * Array of signal actions for this process. */ @@ -623,10 +641,8 @@ int _thread_fd_lock(int, int, struct timespec *); int _thread_fd_lock_debug(int, int, struct timespec *,char *fname,int lineno); void _dispatch_signals(void); void _thread_signal(pthread_t, int); -void _lock_dead_thread_list(void); void _lock_thread(void); void _lock_thread_list(void); -void _unlock_dead_thread_list(void); void _unlock_thread(void); void _unlock_thread_list(void); void _thread_exit(char *, int, char *); @@ -649,6 +665,7 @@ int _thread_queue_remove(struct pthread_queue *, struct pthread *); int _thread_fd_table_init(int fd); struct pthread *_thread_queue_get(struct pthread_queue *); struct pthread *_thread_queue_deq(struct pthread_queue *); +pthread_addr_t _thread_gc(pthread_addr_t); /* #include */ int _thread_sys_sigaction(int, const struct sigaction *, struct sigaction *); -- cgit v1.1