Improved state_to_text() output to match the states in get_thread_info().

Improved the threads list: despite looking much better, it now also prints
out the semaphore number a thread is waiting on.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@9530 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2004-10-27 12:50:48 +00:00
parent f048d50953
commit 4002d2d272
+32 -17
View File
@@ -409,19 +409,29 @@ create_thread(const char *name, team_id teamID, thread_entry_func entry,
static const char * static const char *
state_to_text(int state) state_to_text(struct thread *thread, int32 state)
{ {
switch (state) { switch (state) {
case B_THREAD_READY: case B_THREAD_READY:
return "READY"; return "ready";
case B_THREAD_RUNNING: case B_THREAD_RUNNING:
return "RUNNING"; return "running";
case B_THREAD_WAITING: case B_THREAD_WAITING:
return "WAITING"; if (thread->sem.blocking == sSnoozeSem)
return "zzz";
if (thread->sem.blocking == thread->msg.read_sem)
return "receive";
return "waiting";
case B_THREAD_SUSPENDED: case B_THREAD_SUSPENDED:
return "SUSPEND"; return "suspended";
case THREAD_STATE_FREE_ON_RESCHED: case THREAD_STATE_FREE_ON_RESCHED:
return "DEATH"; return "death";
default: default:
return "UNKNOWN"; return "UNKNOWN";
} }
@@ -439,8 +449,8 @@ _dump_thread_info(struct thread *t)
dprintf("all_next: %p\nteam_next: %p\nq_next: %p\n", dprintf("all_next: %p\nteam_next: %p\nq_next: %p\n",
t->all_next, t->team_next, t->queue_next); t->all_next, t->team_next, t->queue_next);
dprintf("priority: 0x%lx\n", t->priority); dprintf("priority: 0x%lx\n", t->priority);
dprintf("state: %s\n", state_to_text(t->state)); dprintf("state: %s\n", state_to_text(t, t->state));
dprintf("next_state: %s\n", state_to_text(t->next_state)); dprintf("next_state: %s\n", state_to_text(t, t->next_state));
dprintf("cpu: %p ", t->cpu); dprintf("cpu: %p ", t->cpu);
if (t->cpu) if (t->cpu)
dprintf("(%d)\n", t->cpu->info.cpu_num); dprintf("(%d)\n", t->cpu->info.cpu_num);
@@ -517,20 +527,25 @@ dump_thread_list(int argc, char **argv)
struct thread *t; struct thread *t;
struct hash_iterator i; struct hash_iterator i;
dprintf("thread id state sem cpu stack name\n");
hash_open(sThreadHash, &i); hash_open(sThreadHash, &i);
while ((t = hash_next(sThreadHash, &i)) != NULL) { while ((t = hash_next(sThreadHash, &i)) != NULL) {
dprintf("%p", t); dprintf("%p %6lx %-9s", t, t->id, state_to_text(t, t->state));
if (t->name != NULL)
dprintf("\t%32s", t->name); // does it block on a semaphore?
if (t->state == B_THREAD_WAITING)
dprintf("%6lx ", t->sem.blocking);
else else
dprintf("\t%32s", "<NULL>"); dprintf(" - ");
dprintf("\t0x%lx", t->id);
dprintf("\t%16s", state_to_text(t->state)); // on which CPU does it run?
if (t->cpu) if (t->cpu)
dprintf("\t%d", t->cpu->info.cpu_num); dprintf("%2d", t->cpu->info.cpu_num);
else else
dprintf("\tNOCPU"); dprintf(" -");
dprintf("\t0x%lx\n", t->kernel_stack_base);
dprintf(" %p %s\n", (void *)t->kernel_stack_base, t->name != NULL ? t->name : "<NULL>");
} }
hash_close(sThreadHash, &i, false); hash_close(sThreadHash, &i, false);
return 0; return 0;