version 1.65, 2010/01/29 00:36:09 |
version 1.66, 2010/03/26 05:10:50 |
|
|
"", "start", "run", "sleep", "stop", "zomb", "dead", "onproc" |
"", "start", "run", "sleep", "stop", "zomb", "dead", "onproc" |
}; |
}; |
|
|
static int stathz; |
|
|
|
/* these are for calculating cpu state percentages */ |
/* these are for calculating cpu state percentages */ |
static int64_t **cp_time; |
static int64_t **cp_time; |
static int64_t **cp_old; |
static int64_t **cp_old; |
|
|
|
|
unsigned int maxslp; |
unsigned int maxslp; |
|
|
static int |
|
getstathz(void) |
|
{ |
|
struct clockinfo cinf; |
|
size_t size = sizeof(cinf); |
|
int mib[2]; |
|
|
|
mib[0] = CTL_KERN; |
|
mib[1] = KERN_CLOCKRATE; |
|
if (sysctl(mib, 2, &cinf, &size, NULL, 0) == -1) |
|
return (-1); |
|
return (cinf.stathz); |
|
} |
|
|
|
int |
int |
machine_init(struct statics *statics) |
machine_init(struct statics *statics) |
{ |
{ |
|
|
err(1, NULL); |
err(1, NULL); |
} |
} |
|
|
stathz = getstathz(); |
|
if (stathz == -1) |
|
return (-1); |
|
|
|
pbase = NULL; |
pbase = NULL; |
pref = NULL; |
pref = NULL; |
onproc = -1; |
onproc = -1; |
|
|
pp = *(hp->next_proc++); |
pp = *(hp->next_proc++); |
hp->remaining--; |
hp->remaining--; |
|
|
cputime = (pp->p_uticks + pp->p_sticks + pp->p_iticks) / stathz; |
cputime = pp->p_rtime_sec + ((pp->p_rtime_usec + 500000) / 1000000); |
|
|
/* calculate the base for cpu percentages */ |
/* calculate the base for cpu percentages */ |
pct = pctdouble(pp->p_pctcpu); |
pct = pctdouble(pp->p_pctcpu); |