make top go faster
This commit is contained in:
parent
44d77559ad
commit
77356d9d64
@ -32,6 +32,25 @@
|
||||
* Most of it comes from task_struct in linux/sched.h
|
||||
*/
|
||||
typedef struct proc_t {
|
||||
// 1st 16 bytes
|
||||
int
|
||||
pid, /* process id */
|
||||
ppid; /* pid of parent process */
|
||||
unsigned
|
||||
pcpu; /* %CPU usage (is not filled in by readproc!!!) */
|
||||
char
|
||||
state, /* single-char code for process state (S=sleeping) */
|
||||
pad_1, /* padding */
|
||||
pad_2, /* padding */
|
||||
pad_3; /* padding */
|
||||
// 2nd 16 bytes
|
||||
unsigned long long
|
||||
utime, /* user-mode CPU time accumulated by process */
|
||||
stime, /* kernel-mode CPU time accumulated by process */
|
||||
// and so on...
|
||||
cutime, /* cumulative utime of process and reaped children */
|
||||
cstime, /* cumulative stime of process and reaped children */
|
||||
start_time; /* start time of process -- seconds since 1-1-70 */
|
||||
#ifdef SIGNAL_STRING
|
||||
char
|
||||
/* Linux 2.1.7x and up have more signals. This handles 88. */
|
||||
@ -47,12 +66,6 @@ typedef struct proc_t {
|
||||
sigignore, /* mask of ignored signals */
|
||||
sigcatch; /* mask of caught signals */
|
||||
#endif
|
||||
unsigned long long
|
||||
cutime, /* cumulative utime of process and reaped children */
|
||||
cstime, /* cumulative stime of process and reaped children */
|
||||
utime, /* user-mode CPU time accumulated by process */
|
||||
stime, /* kernel-mode CPU time accumulated by process */
|
||||
start_time; /* start time of process -- seconds since 1-1-70 */
|
||||
long
|
||||
priority, /* kernel scheduling priority */
|
||||
timeout, /* ? */
|
||||
@ -68,7 +81,6 @@ typedef struct proc_t {
|
||||
drs, /* data resident set size */
|
||||
dt; /* dirty pages */
|
||||
unsigned long
|
||||
/* FIXME: are these longs? Maybe when the alpha does PCI bounce buffers */
|
||||
vm_size, /* same as vsize in kb */
|
||||
vm_lock, /* locked pages in kb */
|
||||
vm_rss, /* same as rss in kb */
|
||||
@ -114,18 +126,12 @@ typedef struct proc_t {
|
||||
euid, egid, /* effective */
|
||||
suid, sgid, /* saved */
|
||||
fuid, fgid, /* fs (used for file access only) */
|
||||
pid, /* process id */
|
||||
ppid, /* pid of parent process */
|
||||
pgrp, /* process group id */
|
||||
session, /* session id */
|
||||
tty, /* full device number of controlling terminal */
|
||||
tpgid, /* terminal process group id */
|
||||
exit_signal, /* might not be SIGCHLD */
|
||||
processor; /* current (or most recent?) CPU */
|
||||
unsigned
|
||||
pcpu; /* %CPU usage (is not filled in by readproc!!!) */
|
||||
char
|
||||
state; /* single-char code for process state (S=sleeping) */
|
||||
#ifdef FLASK_LINUX
|
||||
security_id_t sid;
|
||||
#endif
|
||||
|
13
top.c
13
top.c
@ -1744,7 +1744,6 @@ static void frame_states (proc_t **ppt, int show)
|
||||
static unsigned hist_siz; // number of structs
|
||||
HIST_t *hist_new;
|
||||
unsigned total, running, sleeping, stopped, zombie;
|
||||
int i;
|
||||
|
||||
if (!hist_sav) {
|
||||
Frame_maxtask = 0;
|
||||
@ -1759,6 +1758,7 @@ static void frame_states (proc_t **ppt, int show)
|
||||
while (-1 != ppt[total]->pid) { /* calculations //// */
|
||||
TICS_t tics;
|
||||
proc_t *this = ppt[total];
|
||||
int i;
|
||||
|
||||
switch (this->state) {
|
||||
case 'S':
|
||||
@ -1801,6 +1801,11 @@ static void frame_states (proc_t **ppt, int show)
|
||||
} /* end: while 'pids' */
|
||||
|
||||
|
||||
free(hist_sav);
|
||||
hist_sav = hist_new;
|
||||
/* shout results to the world (and us too, the next time around) */
|
||||
Frame_maxtask = total;
|
||||
|
||||
if (show) { /* display ///////// */
|
||||
static CPUS_t *smpcpu = NULL;
|
||||
|
||||
@ -1816,6 +1821,7 @@ static void frame_states (proc_t **ppt, int show)
|
||||
/* display just the 1st /proc/stat line */
|
||||
cpudo(&smpcpu[Cpu_tot], "Cpu(s):");
|
||||
} else {
|
||||
int i;
|
||||
char tmp[SMLBUFSIZ];
|
||||
/* display each cpu's states separately */
|
||||
for (i = 0; i < Cpu_tot; i++) {
|
||||
@ -1824,11 +1830,6 @@ static void frame_states (proc_t **ppt, int show)
|
||||
}
|
||||
}
|
||||
} /* end: if 'show' */
|
||||
|
||||
free(hist_sav);
|
||||
hist_sav = hist_new;
|
||||
/* shout results to the world (and us too, the next time around) */
|
||||
Frame_maxtask = total;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user