LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   CPU hogging. (http://www.linuxquestions.org/questions/programming-9/cpu-hogging-695097/)

kirankumarburgu 01-05-2009 08:39 AM

CPU hogging.
 
Hi all,

i just put while(1) in main and exuected that on one of the linux, top shows 99.9 cpu utilization is hogged by this process, in this case if i executed any other process on this machine,it shouldt get any processor time but its not happening......can someone tell me reason for this.

Thanks in advance,
Kiran

wje_lq 01-05-2009 10:08 AM

Your language is not quite understandable at a crucial point in the sentence. Could you ask this in different words, please?

rtspitz 01-05-2009 10:33 AM

you need to start your code 'niced'.

Code:

nice -n 19 name_of_your_executable
this will make sure this job does not hog cpu time, when it is needed elsewhere.

theNbomr 01-05-2009 11:02 AM

Your program is requesting (by not sleeping or waiting) CPU time, which it is getting because no other process is reequesting CPU cycles. The scheduler in the kernel will try to share the CPU equitably according to its algorithms to all processes that want it. So as soon as processes compete for CPU time, they will be given their fair share, which seeems to be what you are seeing.
--- rod.


All times are GMT -5. The time now is 09:26 PM.