Re: how to set priority for idle process ?

Harald Koenig (
Sun, 13 Apr 1997 10:57:34 +0200

On Apr 12, Adam D. Bradley wrote:

> The above is the behavior I would expect, actually..."while (1);" (in a
> test compile I just did) generates a two-instruction infinite loop (two
> jmp's directed at each other), so a process suck in a while(1); is
> indistinguishable from any other very CPU-intensive process.

this is exactly what it should be!

> If you really want a process to idle rather than busy-wait, use something
> like sleep() or select() on /dev/null. That way, Linux can put the
> process on an idle queue where it won't use any cycles; as long as the
> process is _doing_ something (and jumping back and forth between two PC's
> is, like it or not, "doing something"), it will continue to get
> timeslices.

hmm, maybe my mail wasn't clear enough. I'll try to explain the real aim again:

I'd like to have a processes doing real and reasonable computations
only and really only if nothing else is running on the system.
it should not even try to compete with jobs running with "nice 19".
this is what I'm calling my "idle task".

the "while (1);" loop was only a short replacement for the real computation...


All SCSI disks will from now on                     ___       _____
be required to send an email notice                0--,|    /OOOOOOO\
24 hours prior to complete hardware failure!      <_/  /  /OOOOOOOOOOO\
                                                    \  \/OOOOOOOOOOOOOOO\
                                                      \ OOOOOOOOOOOOOOOOO|//
Harald Koenig,                                         \/\/\/\/\/\/\/\/\/
Inst.f.Theoret.Astrophysik                              //  /     \\  \                     ^^^^^       ^^^^^