Debian – Do sleeping processes get the same CPU time

debianlinuxprocess

Some processes spend most of their "lives" in a sleep status. Daemons, servers and general listener come to mind. I was wondering if they get the same CPU time in that state? On something like my laptop, that wouldn't be very optimal!

I vaguely remember from my operating system course that there are different approaches to scheduling. I am interested to find out more about my current Linux (Debian) box.

How can I find out about my current scheduling policies? Can I change them dynamically? With a pretty userland app?

Best Answer

Processes do not consume CPU resources while they are sleeping. They may add some overhead since the Kernel has to juggle them around, but that is very insignificant.

However, because of the way the question is worded, I should mention that when using Linux's CFS (Completely Fair Scheduler), it attempts to give programs increased CPU time in proportion to the time it sleeps - that is, if a process sleeps a lot, when it is resumed, it gets a higher priority.

See http://www.ibm.com/developerworks/linux/library/l-completely-fair-scheduler/ for a description of CFS.

Related Question