Table of Content

Weight: 2

Description: Candidates should should be able to manage process execution priorities.

Key Knowledge Areas:

  • Know the default priority of a job that is created
  • Run a program with higher or lower priority than the default
  • Change the priority of a running process

Terms and Utilities:

nice
ps
renice
top

nice

range -20(high) to 19(low)
default is 10 

root@dclab-u1504s:~# ps -l
F S   UID   PID  PPID  C PRI  NI ADDR SZ WCHAN  TTY          TIME CMD
4 S     0  2021  1909  0  80   0 - 12510 wait   pts/0    00:00:00 su
4 S     0  2022  2021  0  80   0 -  5639 wait   pts/0    00:00:00 bash
0 R     0  2049  2022  0  80   0 -  2512 -      pts/0    00:00:00 ps

root@dclab-u1504s:~# nice
0

nice --18 top # nice -18 

renice -newnice 

• renice +1 p 14292 – make process 14292 just a little nicer
• renice +2 u jack – make all of Jack's processes two notches nicer.
• renice +3 g users – make the processes whose group is “users” three notches nicer.

Quiz questions

1. Why would one want to run a process with a lower priority?
2. How does one run a process with a lower priority?
3. How does one increase the priority of a process when running it? Who can do this?
4. How do you change the priority of a running process?
5. What key in top changes the priority of an existing process?

Answers to quiz questions

1. So that the process does not interfere with processes which should be running more urgently.
2. nice process
3. nice -n -20 process ... only root
4. renice +2 pid ... make process 2 notches less important
5. r for renice