[comp.unix.wizards] comp_t fields

jfh@rpp386.cactus.org (John F Haugh II) (04/22/91)

In article <16226.280f85ed@levels.sait.edu.au> xtdn@levels.sait.edu.au writes:
>Ray.Moody@Cray.Com writes:
>> 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.
>
>What about the comp_t fields in struct acct?  They, while not floats,
>are apparently floating point fields.

So this doesn't turn into a discussion of floating point fields in the
UNIX kernel ...

The comp_t fields are not "floating point fields" in the traditional
sense.  They are a scaled representation of 32 bit integers that the
system uses for various process accounting information.  The function
for decoding one of these gadgets is

	long
	uncompress(comp_t value)
	{
		return (value & 0x1fff) << ((value & 0xc000) >> 13);
	}

The compress function is slightly more complex, but left as an
exercise for the reader.

As an aside, AIX/370 makes considerable use of floating point in the
kernel, so watch out for those generalizations!
-- 
John F. Haugh II        | Distribution to  | UUCP: ...!cs.utexas.edu!rpp386!jfh
Ma Bell: (512) 255-8251 | GEnie PROHIBITED :-) |  Domain: jfh@rpp386.cactus.org
"If liberals interpreted the 2nd Amendment the same way they interpret the
 rest of the Constitution, gun ownership would be mandatory."