diff options
Diffstat (limited to 'lib/libpthread/thread/thr_info.c')
-rw-r--r-- | lib/libpthread/thread/thr_info.c | 108 |
1 files changed, 44 insertions, 64 deletions
diff --git a/lib/libpthread/thread/thr_info.c b/lib/libpthread/thread/thr_info.c index 9ade157..3218b5b 100644 --- a/lib/libpthread/thread/thr_info.c +++ b/lib/libpthread/thread/thr_info.c @@ -56,11 +56,12 @@ struct s_thread_info { /* Static variables: */ static const struct s_thread_info thread_info[] = { {PS_RUNNING , "Running"}, + {PS_LOCKWAIT , "Waiting on an internal lock"}, {PS_MUTEX_WAIT , "Waiting on a mutex"}, {PS_COND_WAIT , "Waiting on a condition variable"}, {PS_SLEEP_WAIT , "Sleeping"}, - {PS_WAIT_WAIT , "Waiting process"}, - {PS_SPINBLOCK , "Waiting for a spinlock"}, + {PS_SIGSUSPEND , "Suspended, waiting for a signal"}, + {PS_SIGWAIT , "Waiting for a signal"}, {PS_JOIN , "Waiting to join"}, {PS_SUSPENDED , "Suspended"}, {PS_DEAD , "Dead"}, @@ -71,12 +72,9 @@ static const struct s_thread_info thread_info[] = { void _thread_dump_info(void) { - char s[512]; - int fd; - int i; - pthread_t pthread; - char tmpfile[128]; - pq_list_t *pq_list; + char s[512], tmpfile[128]; + pthread_t pthread; + int fd, i; for (i = 0; i < 100000; i++) { snprintf(tmpfile, sizeof(tmpfile), "/tmp/uthread.dump.%u.%i", @@ -102,64 +100,34 @@ _thread_dump_info(void) /* all 100000 possibilities are in use :( */ return; } else { - /* Output a header for active threads: */ - strcpy(s, "\n\n=============\nACTIVE THREADS\n\n"); + /* Dump the active threads. */ + strcpy(s, "\n\n========\nACTIVE THREADS\n\n"); __sys_write(fd, s, strlen(s)); /* Enter a loop to report each thread in the global list: */ TAILQ_FOREACH(pthread, &_thread_list, tle) { - dump_thread(fd, pthread, /*long_verson*/ 1); + if (pthread->state != PS_DEAD) + dump_thread(fd, pthread, /*long_verson*/ 1); } - /* Output a header for ready threads: */ - strcpy(s, "\n\n=============\nREADY THREADS\n\n"); - __sys_write(fd, s, strlen(s)); - - /* Enter a loop to report each thread in the ready queue: */ - TAILQ_FOREACH (pq_list, &_readyq.pq_queue, pl_link) { - TAILQ_FOREACH(pthread, &pq_list->pl_head, pqe) { - dump_thread(fd, pthread, /*long_version*/ 0); - } - } - - /* Output a header for waiting threads: */ - strcpy(s, "\n\n=============\nWAITING THREADS\n\n"); + /* + * Dump the ready threads. + * XXX - We can't easily do this because the run queues + * are per-KSEG. + */ + strcpy(s, "\n\n========\nREADY THREADS - unimplemented\n\n"); __sys_write(fd, s, strlen(s)); - /* Enter a loop to report each thread in the waiting queue: */ - TAILQ_FOREACH (pthread, &_waitingq, pqe) { - dump_thread(fd, pthread, /*long_version*/ 0); - } - /* Output a header for threads in the work queue: */ - strcpy(s, "\n\n=============\nTHREADS IN WORKQ\n\n"); + /* + * Dump the waiting threads. + * XXX - We can't easily do this because the wait queues + * are per-KSEG. + */ + strcpy(s, "\n\n========\nWAITING THREADS - unimplemented\n\n"); __sys_write(fd, s, strlen(s)); - /* Enter a loop to report each thread in the waiting queue: */ - TAILQ_FOREACH (pthread, &_workq, qe) { - dump_thread(fd, pthread, /*long_version*/ 0); - } - - /* Check if there are no dead threads: */ - if (TAILQ_FIRST(&_dead_list) == NULL) { - /* Output a record: */ - strcpy(s, "\n\nTHERE ARE NO DEAD THREADS\n"); - __sys_write(fd, s, strlen(s)); - } else { - /* Output a header for dead threads: */ - strcpy(s, "\n\nDEAD THREADS\n\n"); - __sys_write(fd, s, strlen(s)); - - /* - * Enter a loop to report each thread in the global - * dead thread list: - */ - TAILQ_FOREACH(pthread, &_dead_list, dle) { - dump_thread(fd, pthread, /*long_version*/ 0); - } - } - - /* Close the dump file: */ + /* Close the dump file. */ __sys_close(fd); } } @@ -167,9 +135,9 @@ _thread_dump_info(void) static void dump_thread(int fd, pthread_t pthread, int long_version) { - struct pthread *curthread = _get_curthread(); - char s[512]; - int i; + struct pthread *curthread = _get_curthread(); + char s[512]; + int i; /* Find the state: */ for (i = 0; i < NELEMENTS(thread_info) - 1; i++) @@ -178,10 +146,11 @@ dump_thread(int fd, pthread_t pthread, int long_version) /* Output a record for the thread: */ snprintf(s, sizeof(s), - "--------------------\nThread %p (%s) prio %3d state %s [%s:%d]\n", + "--------------------\n" + "Thread %p (%s) prio %3d, blocked %s, state %s [%s:%d]\n", pthread, (pthread->name == NULL) ? "" : pthread->name, - pthread->active_priority, thread_info[i].name, pthread->fname, - pthread->lineno); + pthread->active_priority, (pthread->blocked != 0) ? "yes" : "no", + thread_info[i].name, pthread->fname, pthread->lineno); __sys_write(fd, s, strlen(s)); if (long_version != 0) { @@ -192,13 +161,24 @@ dump_thread(int fd, pthread_t pthread, int long_version) __sys_write(fd, s, strlen(s)); } /* Check if this is the initial thread: */ - if (pthread == _thread_initial) { + if (pthread == _thr_initial) { /* Output a record for the initial thread: */ strcpy(s, "This is the initial thread\n"); __sys_write(fd, s, strlen(s)); } /* Process according to thread state: */ switch (pthread->state) { + case PS_SIGWAIT: + snprintf(s, sizeof(s), "sigmask (hi)"); + __sys_write(fd, s, strlen(s)); + for (i = _SIG_WORDS - 1; i >= 0; i--) { + snprintf(s, sizeof(s), "%08x\n", + pthread->sigmask.__bits[i]); + __sys_write(fd, s, strlen(s)); + } + snprintf(s, sizeof(s), "(lo)\n"); + __sys_write(fd, s, strlen(s)); + break; /* * Trap other states that are not explicitly * coded to dump information: @@ -212,10 +192,10 @@ dump_thread(int fd, pthread_t pthread, int long_version) /* Set the thread name for debug: */ void -_pthread_set_name_np(pthread_t thread, const char *name) +_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) { + if (thread != NULL && thread->magic == THR_MAGIC) { if (thread->name != NULL) { /* Free space for previous name. */ free(thread->name); |