\section{niceness}
\begin{frame}
   {Using nice to Set Priorities}

   \begin{itemize}
      \item Every process has a \textbf{nice value} which
      affects the process's execution priority
      \item \textbf{nice} can raise or lower a process'
      priority by adjusting its nice value
      \item Higher nice values lower the priority
      \item Lower nice values raise the priority
      \item Non-privileged users can only raise the nice
      value
      \item Only the superuser can lower the nice value
   \end{itemize}

\end{frame}

\cprotect\note{

   Nice values range in value from -20 (lowest nice, highest
   priority) to 19 (highest nice, lowest priority).  Note that
   only the superuser can lower a nice value but any user can
   raise their process' nice value.  By default, a process has
   a nice value of 0 which is inherited from the shell.

   \textbf{nice} can be used to run a process with a
   specific nice value:

   \begin{cmd}
$ nice -n 10 myprog
   \end{cmd}
   runs \textbf{myprog} with nice value of 10

   \begin{cmd}
$ nice -n 19 myprog
   \end{cmd}
   runs \textbf{myprog} with lowest priority, nice value
   of 19

   \begin{cmd}
$ sudo nice -n -20 myprog
   \end{cmd}
   runs \textbf{myprog} with highest priority, nice value
   of -20

   If you do not give a nice value the default is to
   increase the niceness by \texttt{10}. If you give no
   arguments at all, you report your current niceness.

   Note that increasing the niceness of a process does
   not mean it will not run; it may even get all the CPU
   time if there is nothing else to compete with.

}


\begin{frame}
   {Modifying the Nice Value}

   \begin{itemize}
      \item \textbf{renice} can change the nice value
      of a running process
      \begin{cmd}
$ renice --help
        \end{cmd}
      \begin{response}
Usage:
 renice [-n] <priority> [-p|--pid] <pid>...
 renice [-n] <priority>  -g|--pgrp <pgid>...
 renice [-n] <priority>  -u|--user <user>...
      \end{response}
      \item Raise the nice value of pid 20003 to 5 :
      \begin{cmd}
$ renice +5 -p 20003
      \end{cmd}
      \item Only the superuser can lower the nice value of
      processes
   \end{itemize}

\end{frame}

\cprotect\note{


   \textbf{renice} is used to raise or lower the nice
   value of an already running process.  It basically lets
   you change the nice value on the fly.

   By default only a superuser can decrease the niceness;
   i.e., increase the priority. However it is possible to
   give normal users the ability to decrease their
   niceness within a predetermined range, by editing
   \filelink{/etc/security/limits.conf}.

   After a non-privileged user has increased the nice
   value, only a superuser can lower it back.

   To change the niceness of an already running process it
   is easy to use the \textbf{renice} command, as in:

   \begin{cmd}
$ renice +3 13848
   \end{cmd}

   which will reset the  niceness to \texttt{3} for the process
   with \textbf{pid = 13848}. More than one process can be
   done at the same time and there are some other options,
   so see \textbf{man renice}.


}


