– Why does daemon process dont spike cpu usage to 100% whereas an infinite for loop does ?

291 views

A daemon process is supposed to be running all the time waiting for user to do something and then respond right ? Does “All the time” mean infinite time ? (Infinite loop) ?

When I run an infinite for loop, the cpu usage spikes to 100% ? Why is it so ?

Thank you for your time.

In: 4

3 Answers

Anonymous 0 Comments

If your loop doesn’t do anything that could possibly yield the CPU to other processes, then that loop is going to nail the cpu to 100%.

Proper way of coding the loop is to have it sleep for a brief time or wait for I/o to let the OS run other tasks.

You are viewing 1 out of 3 answers, click here to view all answers.