Re: how to set priority for idle process ?

Harald Koenig (root@tat.physik.uni-tuebingen.de)
Sat, 12 Apr 1997 13:41:36 +0200


On Apr 12, Charlie Ross wrote:

> you can nice with negative values up to -20... from what I understand, a
> process at -20 wont swap, or relinquish any cpu time unless its fighting
> with another -20 process...

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 */

#include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>
#include <sys/resource.h>

void main(int argc, char *argv[])
{
if (argc>1) {
int p = atoi(argv[1]);
printf("prio %d",getpriority(PRIO_PROCESS, 0));
setpriority(PRIO_PROCESS, 0, p);
printf(" -> %d\n",getpriority(PRIO_PROCESS, 0));
}

while(1);
}

--
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                              //  /     \\  \
koenig@tat.physik.uni-tuebingen.de                     ^^^^^       ^^^^^