As mentioned before, each process takes up a certain amount of CPU time. For every moment the CPU is busy running one process, another process loses valuable running time.
As you can imagine, there will be some instances when you are under time constraints and want to prioritize one job over others. Or other times you'll want to push a process back so that it can run quietly in the background while you tend to other things. To control such priorities, we may launch a program with the
nice command, or modify a currently running process with
The term niceness comes from how "nice" the process is, in terms of how much CPU time it hogs. A nice process (as you would imagine) doesn't take too much CPU time and shares the CPU liberally with other processes.
This range of values goes from -20 to 20, where the lower the niceness, the more prioritized the process is. Thus, a "mean" process (one that hogs system resources) would have values close to -20, while a nicer process is closer to 20. The default niceness of any program is 10.
There are several ways you can call on nice:
$ nice -12 python longProgram.py $ nice -n 12 python longProgram.py $ nice --adjustment=12 python longProgram.py
As you can tell, we call nice, then specify any arguments before we input a command.
We can use the renice command to alter the priority of an already running process without disrupting its operation.
$ renice priority [[-p] pids] [[-g] pgrps] [[-u] users]
You may specify a process via its PID with the
-p option. If you want to change the priorities of all processes under a certain group or user, use the
$ renice 5 -p 21649 # Prioritizes the process with pid 21649 $ renice 19 -u SarahMarsh # Deprioritizes all processes belonging to user SarahMarsh
Relieve your stress, back, neck and sciatic pain through 1,782 acupuncture points for immediate neck pain relief. Made for lower, upper and mid chronic back pain treatment, and improves circulation, sleep, digestion and quality of life.$$ Check price
In this completely revised second edition of the perennial best seller How Linux Works, author Brian Ward makes the concepts behind Linux internals accessible to anyone curious about the inner workings of the operating system. Inside, you'll find the kind of knowledge that normally comes from years of experience doing things the hard way.$ Check price