-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Fri, Aug 24, 2007 at 03:18:32AM +0200, Luka Napotnik wrote: > I'm new to kernel development and have some questions. > > 1. Apperently kernel doesn't support operations with floating-point > types. How can I then divide a number 265 with the number 7 if I can > divide only by 2 with right-shifting? Correct, floating point arithmetic is not allowed in the kernel. Use fixed point math if you really need more precision. Or export the raw values to userland and do the floating point math over there. > 2. I'm trying to get the percentage of CPU used for a certain > task_struct and figured the following formula: > > (task->utime + task->stime) / jiffies > > Before calculating I convert all the variables to jiffies. Is this correct? That should be ok. Couple of things: - - jiffies is continuously updated, so your percentage formula doesn't work. you need to use a jiffies difference - - jiffies can and will wrap around But why would you calculate this in kernel? All the information is already exported to userland so do the calculations over there. Get the source for "top" and see how it is done. Erik - -- They're all fools. Don't worry. Darwin may be slow, but he'll eventually get them. -- Matthew Lammers in alt.sysadmin.recovery -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) iD8DBQFGzrvj/PlVHJtIto0RAl3ZAJ9ysb8YrGG3YgOwxWi9GrcKKd200ACfRyZA EVeQhgr/585PuR0XcTMcyvI= =JZvH -----END PGP SIGNATURE----- -- To unsubscribe from this list: send an email with "unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx Please read the FAQ at http://kernelnewbies.org/FAQ