![]() Result of that formula is random (4, sometimes 8). > That will give link failure for _udivdi3. > You can use "long long" for high precision math if necessary. > kernel code will enable that the FP stack gets properly switched when a process > the kernel tries to execute an FP instruction (and traps as a result), more > Floating point operations are not allowed in the kernel. > * I am not sure about the use of jiffies when it comes to CONFIG_NO_HZ=y. > * So use integer math: (task->utime + task->stime) * 100 / jiffies > On 07:34, linux-os (Dick Johnson) wrote: Use do_div().Ĭ_sum = cputime64_to_clock_t(task->utime) +Īnd if I check the p value of a certain process it gives wrong results.įor example for a process using 99% of the CPU it shows 20. That will give link failure for _udivdi3. >You can use "long long" for high precision math if necessary. Kernel code will enable that the FP stack gets properly switched when a process The kernel tries to execute an FP instruction (and traps as a result), more >Floating point operations are not allowed in the kernel. * I am not sure about the use of jiffies when it comes to CONFIG_NO_HZ=y. * So use integer math: (task->utime + task->stime) * 100 / jiffiesĪnd you get the 'common' percentage. If you are not the intended recipient, please notify Analogic Corporation immediately - by replying to this message or by sending an email to - and destroy all copies of this information, including any attachments, without reading or disclosing them. Any review, retransmission, dissemination, or other use of this information by persons or entities other than the intended recipient is prohibited. The information transmitted in this message is confidential and may be privileged. Penguin : Linux version 2.6.22.1 on an i686 machine (5588.30 BogoMips). You can use "long long" for high precision math if necessary. Generates runtime code so you have to watch out for that as well. When you think you are simply creating a constant, the compiler Is this correct?įloating point operations are not allowed in the kernel. > Before calculating I convert all the variables to jiffies. > task_struct and figured the following formula: I'm trying to get the percentage of CPU used for a certain The body of a message to majordomo info at To unsubscribe from this list: send the line "unsubscribe linux-kernel" in Just scale your numbers by shifting them. with the 2 fields of taskstruct stucture, utime and stime i am calculating total time a task taken, The procedure i m following in every 100th timer interrupt, I am updating cpu time of current task. Point in the kernel, fixed point works as well or better. For almost every imaginable case where you would want floating Overhead even in cases where it isn't used, and there is very littleīenefit. The short version is simply that it's very expensive to allow this, adding It can sometimes beĭifficult to understand the assumptions the kernel has on the toolchainĪnd the extensions that it uses, and unfortunately there is noĭefinitive reference for them. Arbitrary long longĭivisions and floating point are not allowed. Portions of the C standard are not supported. The kernel is a freestanding CĮnvironment, with no reliance on the standard C library, so some While itĪdheres to the ISO C89 standard, it uses a number of extensions that are "The kernel is written using GNU C and the GNU toolchain. > And if I compile with normal integers, I get zero as the result. > (double)b)? It gives me strange errors when compiling: Why can't I divide with regular casting to double ((double)a / * SPDX-License-Identifier: GPL-2.> I'm new to kernel development and have some questions.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |