Context decision due to "nice"

Context decision due to "nice"

Post by Angus Marc » Fri, 07 Dec 2001 02:45:04



I'd like to understand exactly (if possible) how the nice/priority
affects which process gets != time. If one process has a lower
nice/higher priority than another, will that process always get
preference over the other? For instance, if all process have nice=0
(and almost all do) will a process with -1 get just as many cycles as
if it was at -15? When I compile a kernel, I usually give it a
positive nice, since I'm not in a hurry to get the job done. I still
notice that a lot of other processes drag. Is that because a power
hungry process will still affect processes with a lower nice, or could
that be from swapping, which I'm sure a compilation would force?
--
        Angus March
          VE2 UFP
Concordia University Amateur Radio

http://www.ece.concordia.ca/~ac_march/addr.html (very frivolous)
 
 
 

Context decision due to "nice"

Post by Jeffrey Ros » Sat, 08 Dec 2001 12:27:38


"nice" affects the scheduling of the process.  Even slowing a process with
"nice -n 19" a process may still noticeably affect the other processes in
the system.  If a process is running at the highest priority (nice -n -20)
it cannot be interrupted, so no other processes will get a time-slice until
that process voluntarily swaps out (say for an I/O call).
There may be other ways of slowing a process that I'm not aware of.  You can
suspend a process and restart it using the appropriate kill commands.
Other than that read the documentation.

 
 
 

Context decision due to "nice"

Post by Sony Anto » Sat, 08 Dec 2001 18:55:25



> I'd like to understand exactly (if possible) how the nice/priority
> affects which process gets != time. If one process has a lower
> nice/higher priority than another, will that process always get
> preference over the other? For instance, if all process have nice=0
> (and almost all do) will a process with -1 get just as many cycles as
> if it was at -15? When I compile a kernel, I usually give it a
> positive nice, since I'm not in a hurry to get the job done. I still
> notice that a lot of other processes drag. Is that because a power
> hungry process will still affect processes with a lower nice, or could
> that be from swapping, which I'm sure a compilation would force?

Linux has 3 scheduling classes SCHED_RR, SCHED_FIFO & SCHED_OTHER. The
first 2 are real time classes. Most of the processes uses SCHED_OTHER.

Linux also has a static priority & a dynamic one. Both SCHED_RR &
SCHED_FIFO has the static priority in the range of 1 to 99. Since only
root is allowed static priority above 0, only root can create these
class of processes.

If at any time a process of higher static priority gets ready to run,
the running process is pre empted in order to run the higher priority
one.

The dynamic priority is used only to choose the process from the list
of ready-to-run-processes belonging to the same static priority.

A processes dynamic priority goes up  whenever it is ready to run but
scheduler picker up another process ( of teh same class ). As a result
when a process sits in the queue for a while ready to run, it s
dynamic priority will increase.

The nice(1) uses system call setpriority() to change the dynamic
priority base point of a process.

So if you make a process -15, it will only wait smaller period of time
compared to a -1, before the scheduler picks it up for running. ( In
the first case other processes will have to wait longer before their
dynamic priorities go above -15, whereas in the second case they only
have to wait a shorter period before their dynamic priorities go above
-1 ).

--sony

So