Re: printk

Richard B. Johnson (root@chaos.analogic.com)
Mon, 29 Nov 1999 11:30:32 -0500 (EST)


On 29 Nov 1999, Andreas Schwab wrote:

> "Richard B. Johnson" <root@chaos.analogic.com> writes:
>
> |> Most kernel stuff has 'HZ' granularity so you get 'decimal' information
> |> easily like:
> |>
> |> cpu_time = whatever();
> |> printk("CPU = %lu.%lu\n", cpu_time/HZ, cpu_time % HZ);
>
> This gives misleading numbers in the output if HZ != 100. Even if HZ is
> 100 the output is misleading if cpu_time % HZ < 10.

Well yes, the format should be "%lu.%02lu" for HZ=100. If HZ isn't 100,
i.e., Alpha, you can normalize to either 100 or 1000 before using the
mod operator.

Cheers,
Dick Johnson

Penguin : Linux version 2.3.13 on an i686 machine (400.59 BogoMips).
Warning : It's hard to remain at the trailing edge of technology.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/