Bug #585

top: output correct process states after lwp changes

Added by sq about 7 years ago. Updated about 5 years ago.

Status:NewStart date:
Priority:NormalDue date:
Assignee:corecode% Done:

0%

Category:-
Target version:-

Description

Good time of day.

As defined in sys/proc.h process may have one of this states:

enum procstat {
SIDL = 1,
SACTIVE = 2,
SSTOP = 3,
SZOMB = 4,
};

For display summary process info 'top' use procstatenames array with values:
"", " starting, ", " running, ", " sleeping, ", " stopped, ", " zombie, "
which are not mapped to process's states.

There is a patch fo fix this promblem. It also display processes with
sleeping lwp as sleeping, for example:

37 processes: 1 running, 36 sleeping

But is more better mark process as sleeping only if _all_ of this lwps
are in sleeping state.

--- /usr/src/usr.bin/top/machine.c.orig 2007-03-22 17:03:23.000000000 +0300
+++ /usr/src/usr.bin/top/machine.c 2007-03-22 18:16:48.000000000 +0300
@@ -138,8 +138,8 @@

int process_states[6];
char *procstatenames[] = {
- "", " starting, ", " running, ", " sleeping, ", " stopped, ",
- " zombie, ",
+ "", " starting, ", " running, ", " stopped, ", " zombie, ",
+ " sleeping, ",
NULL
};

@@ -501,6 +501,8 @@
(show_system || ((PP(pp, flags) & P_SYSTEM) == 0)))))
{
total_procs++;
+ if (LP(pp, stat) == LSSLEEP)
+ PP(pp, stat) = SZOMB + 1;
process_states[(unsigned char) PP(pp, stat)]++;
if ((show_threads && (LP(pp, pid) == 0)) ||
(!show_only_threads && PP(pp, stat) != SZOMB &&

History

#1 Updated by corecode about 7 years ago

I'm not sure. Maybe we should display all lwps for the time being. This for sure is an area of discussion.

well caught!

I don't really like this. Maybe something like

int state;

state = PP(pp, stat);
if (LP(pp, stat) == LSSLEEP)
state = SZOMB + 1;
process_states[state]++;

what do you think?

cheers
simon

#2 Updated by corecode about 7 years ago

Hello Dmitry,

Knock yourself out, but always try to keep the code at least as clean as the surrounding code :)

cheers
simon

#3 Updated by c.turner about 7 years ago

personally, I'm a fan of having this be runtime selectable -
sometimes you want to see what the system is doing, other times
you want to see what a few programs are doing.. but feel free
mod my comment -1 for no code attachment :)

#4 Updated by corecode about 7 years ago

any progress with this patch?

Also available in: Atom PDF