From e73ac85912aa7bf1a141b56b00f9a99a50d2eec1 Mon Sep 17 00:00:00 2001 From: rwatson Date: Thu, 8 Jan 2004 22:49:23 +0000 Subject: Improve the expressiveness of ttyinfo (^T) when dealing with threads in slightly less usual states: If the thread is on a run queue, display "running" if the thread is actually running, otherwise, "runnable". If the thread is sleeping, and it's on a sleep queue, display the name of the queue, otherwise "unknown" -- previously, in this situation we would display "iowait". If the thread is waiting on a lock, display *lockname. If the thread is suspended, display "suspended" -- previously, in this situation we would display "iowait". If the thread is waiting for an interrupt, display "intrwait" -- previously, in this situation we would display "iowait". If the thread is in a state not handled by the above, display "unknown" -- previously, we would print "iowait". Among other things, this avoids displaying "iowait" when the foreground process turns out to be suspended waiting for a debugger to properly attach. --- sys/kern/tty.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) (limited to 'sys/kern/tty.c') diff --git a/sys/kern/tty.c b/sys/kern/tty.c index f34858c..5864817 100644 --- a/sys/kern/tty.c +++ b/sys/kern/tty.c @@ -2422,17 +2422,26 @@ ttyinfo(struct tty *tp) if (pick->p_flag & P_SA) { stmp = "KSE" ; /* XXXKSE */ } else { - if (td) { - if (TD_ON_RUNQ(td) || - (TD_IS_RUNNING(td))) { - stmp = "running"; + if (td != NULL) { + if (TD_ON_RUNQ(td)) { + if (TD_IS_RUNNING(td)) + stmp = "running"; + else + stmp = "runnable"; + } else if (TD_IS_SLEEPING(td)) { + if (TD_ON_SLEEPQ(td)) + stmp = td->td_wmesg; + else + stmp = "unknown"; } else if (TD_ON_LOCK(td)) { stmp = td->td_lockname; sprefix = "*"; - } else if (td->td_wmesg) { - stmp = td->td_wmesg; + } else if (TD_IS_SUSPENDED(td)) { + stmp = "suspended"; + } else if (TD_AWAITING_INTR(td)) { + stmp = "intrwait"; } else { - stmp = "iowait"; + stmp = "unknown"; } } else { stmp = "threadless"; -- cgit v1.1