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
|
* Most of it comes from task_struct in linux/sched.h
|
||||||
*/
|
*/
|
||||||
typedef struct proc_t {
|
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
|
#ifdef SIGNAL_STRING
|
||||||
char
|
char
|
||||||
/* Linux 2.1.7x and up have more signals. This handles 88. */
|
/* 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 */
|
sigignore, /* mask of ignored signals */
|
||||||
sigcatch; /* mask of caught signals */
|
sigcatch; /* mask of caught signals */
|
||||||
#endif
|
#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
|
long
|
||||||
priority, /* kernel scheduling priority */
|
priority, /* kernel scheduling priority */
|
||||||
timeout, /* ? */
|
timeout, /* ? */
|
||||||
@ -68,7 +81,6 @@ typedef struct proc_t {
|
|||||||
drs, /* data resident set size */
|
drs, /* data resident set size */
|
||||||
dt; /* dirty pages */
|
dt; /* dirty pages */
|
||||||
unsigned long
|
unsigned long
|
||||||
/* FIXME: are these longs? Maybe when the alpha does PCI bounce buffers */
|
|
||||||
vm_size, /* same as vsize in kb */
|
vm_size, /* same as vsize in kb */
|
||||||
vm_lock, /* locked pages in kb */
|
vm_lock, /* locked pages in kb */
|
||||||
vm_rss, /* same as rss in kb */
|
vm_rss, /* same as rss in kb */
|
||||||
@ -114,18 +126,12 @@ typedef struct proc_t {
|
|||||||
euid, egid, /* effective */
|
euid, egid, /* effective */
|
||||||
suid, sgid, /* saved */
|
suid, sgid, /* saved */
|
||||||
fuid, fgid, /* fs (used for file access only) */
|
fuid, fgid, /* fs (used for file access only) */
|
||||||
pid, /* process id */
|
|
||||||
ppid, /* pid of parent process */
|
|
||||||
pgrp, /* process group id */
|
pgrp, /* process group id */
|
||||||
session, /* session id */
|
session, /* session id */
|
||||||
tty, /* full device number of controlling terminal */
|
tty, /* full device number of controlling terminal */
|
||||||
tpgid, /* terminal process group id */
|
tpgid, /* terminal process group id */
|
||||||
exit_signal, /* might not be SIGCHLD */
|
exit_signal, /* might not be SIGCHLD */
|
||||||
processor; /* current (or most recent?) CPU */
|
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
|
#ifdef FLASK_LINUX
|
||||||
security_id_t sid;
|
security_id_t sid;
|
||||||
#endif
|
#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
|
static unsigned hist_siz; // number of structs
|
||||||
HIST_t *hist_new;
|
HIST_t *hist_new;
|
||||||
unsigned total, running, sleeping, stopped, zombie;
|
unsigned total, running, sleeping, stopped, zombie;
|
||||||
int i;
|
|
||||||
|
|
||||||
if (!hist_sav) {
|
if (!hist_sav) {
|
||||||
Frame_maxtask = 0;
|
Frame_maxtask = 0;
|
||||||
@ -1759,6 +1758,7 @@ static void frame_states (proc_t **ppt, int show)
|
|||||||
while (-1 != ppt[total]->pid) { /* calculations //// */
|
while (-1 != ppt[total]->pid) { /* calculations //// */
|
||||||
TICS_t tics;
|
TICS_t tics;
|
||||||
proc_t *this = ppt[total];
|
proc_t *this = ppt[total];
|
||||||
|
int i;
|
||||||
|
|
||||||
switch (this->state) {
|
switch (this->state) {
|
||||||
case 'S':
|
case 'S':
|
||||||
@ -1801,6 +1801,11 @@ static void frame_states (proc_t **ppt, int show)
|
|||||||
} /* end: while 'pids' */
|
} /* 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 ///////// */
|
if (show) { /* display ///////// */
|
||||||
static CPUS_t *smpcpu = NULL;
|
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 */
|
/* display just the 1st /proc/stat line */
|
||||||
cpudo(&smpcpu[Cpu_tot], "Cpu(s):");
|
cpudo(&smpcpu[Cpu_tot], "Cpu(s):");
|
||||||
} else {
|
} else {
|
||||||
|
int i;
|
||||||
char tmp[SMLBUFSIZ];
|
char tmp[SMLBUFSIZ];
|
||||||
/* display each cpu's states separately */
|
/* display each cpu's states separately */
|
||||||
for (i = 0; i < Cpu_tot; i++) {
|
for (i = 0; i < Cpu_tot; i++) {
|
||||||
@ -1824,11 +1830,6 @@ static void frame_states (proc_t **ppt, int show)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} /* end: if '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