Changeset View
Changeset View
Standalone View
Standalone View
head/sys/kern/sched_4bsd.c
Show First 20 Lines • Show All 431 Lines • ▼ Show 20 Lines | |||||
*/ | */ | ||||
/* calculations for digital decay to forget 90% of usage in 5*loadav sec */ | /* calculations for digital decay to forget 90% of usage in 5*loadav sec */ | ||||
#define loadfactor(loadav) (2 * (loadav)) | #define loadfactor(loadav) (2 * (loadav)) | ||||
#define decay_cpu(loadfac, cpu) (((loadfac) * (cpu)) / ((loadfac) + FSCALE)) | #define decay_cpu(loadfac, cpu) (((loadfac) * (cpu)) / ((loadfac) + FSCALE)) | ||||
/* decay 95% of `ts_pctcpu' in 60 seconds; see CCPU_SHIFT before changing */ | /* decay 95% of `ts_pctcpu' in 60 seconds; see CCPU_SHIFT before changing */ | ||||
static fixpt_t ccpu = 0.95122942450071400909 * FSCALE; /* exp(-1/20) */ | static fixpt_t ccpu = 0.95122942450071400909 * FSCALE; /* exp(-1/20) */ | ||||
SYSCTL_UINT(_kern, OID_AUTO, ccpu, CTLFLAG_RD, &ccpu, 0, ""); | SYSCTL_UINT(_kern, OID_AUTO, ccpu, CTLFLAG_RD, &ccpu, 0, | ||||
"Decay factor used for updating %CPU"); | |||||
/* | /* | ||||
* If `ccpu' is not equal to `exp(-1/20)' and you still want to use the | * If `ccpu' is not equal to `exp(-1/20)' and you still want to use the | ||||
* faster/more-accurate formula, you'll have to estimate CCPU_SHIFT below | * faster/more-accurate formula, you'll have to estimate CCPU_SHIFT below | ||||
* and possibly adjust FSHIFT in "param.h" so that (FSHIFT >= CCPU_SHIFT). | * and possibly adjust FSHIFT in "param.h" so that (FSHIFT >= CCPU_SHIFT). | ||||
* | * | ||||
* To estimate CCPU_SHIFT for exp(-1/20), the following formula was used: | * To estimate CCPU_SHIFT for exp(-1/20), the following formula was used: | ||||
* 1 - exp(-1/20) ~= 0.0487 ~= 0.0488 == 1 (fixed pt, *11* bits). | * 1 - exp(-1/20) ~= 0.0487 ~= 0.0488 == 1 (fixed pt, *11* bits). | ||||
▲ Show 20 Lines • Show All 1,349 Lines • Show Last 20 Lines |