diff options
| author | John Birrell <jb@FreeBSD.org> | 1998-04-11 07:47:22 +0000 | 
|---|---|---|
| committer | John Birrell <jb@FreeBSD.org> | 1998-04-11 07:47:22 +0000 | 
| commit | d60f0fa60da3004a1b2fb533afd6a7aa790795e3 (patch) | |
| tree | ebe8fdb4866ab709d5d0db2d85c87328cea7307a /lib/libpthread | |
| parent | ec216c263498f3ab7c5554f5c5571125b57024b8 (diff) | |
Notes
Diffstat (limited to 'lib/libpthread')
| -rw-r--r-- | lib/libpthread/thread/thr_create.c | 7 | ||||
| -rw-r--r-- | lib/libpthread/thread/thr_info.c | 27 | ||||
| -rw-r--r-- | lib/libpthread/thread/thr_kern.c | 5 | ||||
| -rw-r--r-- | lib/libpthread/thread/thr_private.h | 11 | 
4 files changed, 39 insertions, 11 deletions
| diff --git a/lib/libpthread/thread/thr_create.c b/lib/libpthread/thread/thr_create.c index 3dcd944bced9..c9c6c9fb6d42 100644 --- a/lib/libpthread/thread/thr_create.c +++ b/lib/libpthread/thread/thr_create.c @@ -40,6 +40,7 @@  #include <machine/reg.h>  #include <pthread.h>  #include "pthread_private.h" +#include "libc_private.h"  int  _thread_create(pthread_t * thread, const pthread_attr_t * attr, @@ -254,6 +255,12 @@ pthread_create(pthread_t * thread, const pthread_attr_t * attr,  	int             ret = 0;  	/* +	 * Locking functions in libc are required when there are +	 * threads other than the initial thread. +	 */ +	__isthreaded = 1; + +	/*  	 * Call the low level thread creation function which allows a parent  	 * thread to be specified:   	 */ diff --git a/lib/libpthread/thread/thr_info.c b/lib/libpthread/thread/thr_info.c index be25d45270f1..fe6565beb5e6 100644 --- a/lib/libpthread/thread/thr_info.c +++ b/lib/libpthread/thread/thr_info.c @@ -52,7 +52,8 @@ static const struct s_thread_info thread_info[] = {  	{PS_FDLR_WAIT	, "Waiting for a file read lock"},  	{PS_FDLW_WAIT	, "Waiting for a file write lock"},  	{PS_FDR_WAIT	, "Waiting for read"}, -	{PS_FDW_WAIT	, "Waitingfor write"}, +	{PS_FDW_WAIT	, "Waiting for write"}, +	{PS_FILE_WAIT	, "Waiting for FILE lock"},  	{PS_SELECT_WAIT	, "Waiting on select"},  	{PS_SLEEP_WAIT	, "Sleeping"},  	{PS_WAIT_WAIT	, "Waiting process"}, @@ -87,8 +88,8 @@ _thread_dump_info(void)  				if (thread_info[j].state == pthread->state)  					break;  			/* Output a record for the current thread: */ -			sprintf(s, "--------------------\nThread %p prio %3d state %s [%s:%d]\n", -				pthread, pthread->pthread_priority, thread_info[j].name,pthread->fname,pthread->lineno); +			sprintf(s, "--------------------\nThread %p (%s) prio %3d state %s [%s:%d]\n", +				pthread, (pthread->name == NULL) ? "":pthread->name, pthread->pthread_priority, thread_info[j].name,pthread->fname,pthread->lineno);  			_thread_sys_write(fd, s, strlen(s));  			/* Check if this is the running thread: */ @@ -105,7 +106,7 @@ _thread_dump_info(void)  			}  			/* Process according to thread state: */  			switch (pthread->state) { -				/* File descriptor read lock wait: */ +			/* File descriptor read lock wait: */  			case PS_FDLR_WAIT:  			case PS_FDLW_WAIT:  			case PS_FDR_WAIT: @@ -117,10 +118,10 @@ _thread_dump_info(void)  				_thread_sys_write(fd, s, strlen(s));  				break; -				/* -				 * Trap other states that are not explicitly -				 * coded to dump information:  -				 */ +			/* +			 * Trap other states that are not explicitly +			 * coded to dump information:  +			 */  			default:  				/* Nothing to do here. */  				break; @@ -179,4 +180,14 @@ _thread_dump_info(void)  	}  	return;  } + +/* Set the thread name for debug: */ +void +pthread_set_name_np(pthread_t thread, char *name) +{ +	/* Check if the caller has specified a valid thread: */ +	if (thread != NULL && thread->magic == PTHREAD_MAGIC) +		thread->name = strdup(name); +	return; +}  #endif diff --git a/lib/libpthread/thread/thr_kern.c b/lib/libpthread/thread/thr_kern.c index eeae75cc39b1..9356c4c63e7c 100644 --- a/lib/libpthread/thread/thr_kern.c +++ b/lib/libpthread/thread/thr_kern.c @@ -29,7 +29,7 @@   * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF   * SUCH DAMAGE.   * - * $Id: uthread_kern.c,v 1.6 1998/02/13 01:27:33 julian Exp $ + * $Id: uthread_kern.c,v 1.7 1998/03/09 04:46:26 jb Exp $   *   */  #include <errno.h> @@ -844,6 +844,7 @@ _thread_signal(pthread_t pthread, int sig)  	case PS_DEAD:  	case PS_FDLR_WAIT:  	case PS_FDLW_WAIT: +	case PS_FILE_WAIT:  	case PS_JOIN:  	case PS_MUTEX_WAIT:  	case PS_RUNNING: @@ -1142,6 +1143,7 @@ _thread_kern_select(int wait_reqd)  		case PS_DEAD:  		case PS_FDLR_WAIT:  		case PS_FDLW_WAIT: +		case PS_FILE_WAIT:  		case PS_JOIN:  		case PS_MUTEX_WAIT:  		case PS_RUNNING: @@ -1491,6 +1493,7 @@ _thread_kern_select(int wait_reqd)  			case PS_DEAD:  			case PS_FDLR_WAIT:  			case PS_FDLW_WAIT: +			case PS_FILE_WAIT:  			case PS_JOIN:  			case PS_MUTEX_WAIT:  			case PS_SIGWAIT: diff --git a/lib/libpthread/thread/thr_private.h b/lib/libpthread/thread/thr_private.h index dc36d8da53f0..5ceeabaf0cc2 100644 --- a/lib/libpthread/thread/thr_private.h +++ b/lib/libpthread/thread/thr_private.h @@ -50,6 +50,7 @@   */  #include <setjmp.h>  #include <signal.h> +#include <sys/queue.h>  #include <sys/types.h>  #include <sys/time.h>  #include <sched.h> @@ -219,6 +220,7 @@ enum pthread_state {  	PS_FDLW_WAIT,  	PS_FDR_WAIT,  	PS_FDW_WAIT, +	PS_FILE_WAIT,  	PS_SELECT_WAIT,  	PS_SLEEP_WAIT,  	PS_WAIT_WAIT, @@ -283,6 +285,7 @@ struct pthread {  	 */  #define	PTHREAD_MAGIC		((u_int32_t) 0xd09ba115)  	u_int32_t		magic; +	char			*name;  	/*  	 * Pointer to the next thread in the thread linked list. @@ -387,12 +390,18 @@ struct pthread {  	 * The current thread can belong to only one queue at a time.  	 *  	 * Pointer to queue (if any) on which the current thread is waiting. +	 * +	 * XXX The queuing should be changed to use the TAILQ entry below. +	 * XXX For the time being, it's hybrid.  	 */  	struct pthread_queue	*queue;  	/* Pointer to next element in queue. */  	struct pthread	*qnxt; +	/* Queue entry for this thread: */ +	TAILQ_ENTRY(pthread) qe; +  	/* Wait data. */  	union pthread_wait_data data; @@ -634,8 +643,6 @@ ssize_t _thread_sys_sendto(int, const void *,size_t, int, const struct sockaddr  /* #include <stdio.h> */  #ifdef  _STDIO_H_ -void    _thread_flockfile(FILE *fp,char *fname,int lineno); -void    _thread_funlockfile(FILE *fp);  FILE    *_thread_sys_fdopen(int, const char *);  FILE    *_thread_sys_fopen(const char *, const char *);  FILE    *_thread_sys_freopen(const char *, const char *, FILE *); | 
