Re: how to set priority for idle process ?

Adam D. Bradley (bradley@cs.unca.edu)
Sat, 12 Apr 1997 13:10:25 -0400 (EDT)


[-20 priority]
> even this is only theory:
>
> PID USER PRI NI SIZE RES SHRD STAT %CPU %MEM TIME COMMAND
> 1096 root 15 -20 780 220 172 R < 63.5 0.7 0:30 niceloop -20
> 1095 root 17 0 780 220 172 R 33.0 0.7 0:18 niceloop 0
>
> and I don't want to run the whole system at negative priorities (I need them
> for a few other almost realtime tasks) just to be able to have a real and only
> "idle task" in user space...
>
>
> Harald
> -------------------------------------------------------------------------------
> /* niceloop.c */
>
> void main(int argc, char *argv[])
> {
[snip]
> while(1);
> }

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.

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.

Adam

--
He feeds on ashes; a deluded mind has led him    Adam Bradley, UNCA Senior
astray, and he cannot deliver himself or say,             Computer Science
"Is there not a lie in my right hand?"   Isaiah 44:20
        bradley@cs.unca.edu       http://www.cs.unca.edu/~bradley      <><