LPIC-1 103.6: Process priorities
Sharing a CPU between niced processes, who may lower a nice value, and how
nice passes on to child processes.
Before you start
The lab creates user dana (password Lab-Pass-1) and starts a long
sleep process owned by her at nice value 10. Write answers to the
files in /root/lab-answers/. The process doesn't survive a reboot, so
check before you reboot.
Tasks
- Start two CPU-heavy loops pinned to the same CPU, one at the default
and one niced:
taskset -c 0 sh -c 'while :; do :; done' &andtaskset -c 0 nice -n 19 sh -c 'while :; do :; done' &. Watch their CPU share intop, then end them withkill %1 %2. Check it yourself: the niced loop gets only a few percent. - As
dana, try to renice hersleepprocess from 10 to 5 and read the error. Then do it as root. - Run
nicewith no arguments, thennice bashand runniceagain inside the new shell. Write whatniceprinted inside the new shell to/root/lab-answers/3.
Hints
topshowsNIand%CPU;qquits.su - dana(orsudo -iu dana),pgrep -u dana sleep,renice -n 5 -p PID;ps -o pid,ni,comm -u dana.nicealone prints the current nice value;nice CMDadds 10.