Project

General

Profile

Actions

Bug #585

closed

top: output correct process states after lwp changes

Added by sq over 17 years ago. Updated almost 10 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Userland
Target version:
Start date:
Due date:
% Done:

0%

Estimated time:

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 & P_SYSTEM) 0))))) {
total_procs++;
+ if (LP(pp, stat) LSSLEEP)
+ PP = SZOMB + 1;
process_states[(unsigned char) PP]++;
if ((show_threads && (LP == 0)) ||
(!show_only_threads && PP != SZOMB &&

Actions #1

Updated by corecode over 17 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;
if (LP == LSSLEEP)
state = SZOMB + 1;
process_states[state]++;

what do you think?

cheers
simon

Actions #2

Updated by corecode over 17 years ago

Hello Dmitry,

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

cheers
simon

Actions #3

Updated by c.turner over 17 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 :)

Actions #4

Updated by corecode over 17 years ago

any progress with this patch?

Actions #5

Updated by tuxillo almost 10 years 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

Hi,

Fixed in the related revision.

Cheers,
Antonio Huete

Actions

Also available in: Atom PDF