Reckoning CPU Load
On Linux systems, the load-average is not calculated on each clock tick, but driven by a variable value that is based on the Hz frequency setting and tested on each clock tick. (Hz variable is the pulse rate of particular Linux kernel activity. 1Hz is equal to one clock tick; 10ms by default.) Although the Hz value can be configured in some versions of the kernel, it is normally set to 100. The calculation code uses the Hz value to determine the CPU Load calculation frequency. Specifically, the timer.c::calc_load function will run the algorithm every 5 * Hz, or roughly every five seconds. Following is that function in its entirety:
unsigned long avenrun; static inline void calc_load(unsigned long ticks) { unsigned long active_tasks; /* fixed-point */ static int count = LOAD_FREQ; count -= ticks; if (count < 0) { count += LOAD_FREQ; active_tasks = count_active_tasks; CALC_LOAD(avenrun, EXP_1, active_tasks); CALC_LOAD(avenrun, EXP_5, active_tasks); CALC_LOAD(avenrun, EXP_15, active_tasks); } }The avenrun array contains 1-minute, 5-minute and 15-minute average. The CALC_LOAD macro and its associated values are defined in sched.h :
#define FSHIFT 11 /* nr of bits of precision */ #define FIXED_1 (1<Read more about this topic: Load (computing)
Famous quotes containing the words reckoning and/or load:
“He wasnt off a mere degree;
His reckoning was off a sea.”
—Robert Frost (18741963)
“Belief and love,a believing love will relieve us of a vast load of care. O my brothers, God exists. There is a soul at the centre of nature, and over the will of every man, so that none of us can wrong the universe.”
—Ralph Waldo Emerson (18031882)