Bug #585

top: output correct process states after lwp changes

Added by sq over 8 years ago. Updated 8 months ago.

Status:ClosedStart date:
Priority:NormalDue date:
Assignee:tuxillo% Done:

0%

Category:Userland
Target version:4.2.x

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 &&

Associated revisions

Revision bc40e61d
Added by Stathis Kamperis about 5 years ago

top: Fix count of process states

The count was not in correspondence with our enumeration constants
for the process states. For example, an "active" process could be
counted as "running".

Only tested with i386/UP :)

History

#1 Updated by corecode over 8 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 over 8 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 over 8 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 over 8 years ago

any progress with this patch?

#5 Updated by tuxillo 8 months ago

  • Description updated (diff)
  • Category set to Userland
  • Status changed from New to Closed
  • Assignee changed from corecode to tuxillo
  • Target version set to 4.2.x

Hi,

Fixed in the related revision.

Cheers,
Antonio Huete

Also available in: Atom PDF