ccpu
Ray.Moody at Cray.Com
Ray.Moody at Cray.Com
Fri Apr 19 03:37:14 AEST 1991
>Can anybody tell me more about the kernel variable ccpu?
>Where does it stand for?
>Is its value a constant or not?
>What is the use of it?
Ccpu is used compute a processes percent CPU utilization. It is a
constant traditionally set to exp(-1/20). It is unusual in that it is
one of the very few floating point numbers in the kernel.
Some machines that don't have floating point hardware and don't want
to load floating point emulation routines into the kernel will treat
ccpu as a fixed point number. Check out FSCALE in <sys/param.h>.
Machines that do this are subject to significant truncation (not
roundoff) errors.
Ccpu is used to "decay" the percent CPU utilization of a process. A
process that is listed as having 100% of the CPU will be decayed to
36.78% CPU if it is idle for 20 seconds. The 20 comes from the 1/20
part and the 36.78% comes from 1/e where e is the base of natural
logarithms.
I imagine that natural logarithms were used because they are preferred
by mathematicians for decay related math (such as radioactivity). I
believe that the constant "20" is more or less arbitrary. Somewhere I
remember seeing this constant "20" in an ancient scheduler to
represent the attention span of a human. (It is interesting to note
that "ps" reports processes that have been inactive for more than 20
seconds as "Idle" but processes that have been inactive for less than
20 seconds as "Sleeping".)
Ray
More information about the Comp.unix.wizards
mailing list