Is there still a need for nice?
Some time last week, the collective minds of Bristol Wireless were hunched over their pints down the pub when someone asked: “Is there still a point to nice?”
For those unfamiliar with nice, it’s a means on a Unix/Linux system of giving a process more or less CPU time than other processes. A niceness of −20 is the highest priority and 19 or 20 is the lowest priority. The default niceness for processes is inherited from its parent process, usually 0.
For an idea of how it works, here’s the nice man page:
Name
nice – run a program with modified scheduling priority
Synopsis
nice [OPTION] [COMMAND [ARG]…]
Description
Run COMMAND with an adjusted niceness, which affects process scheduling. With no COMMAND, print the current niceness. Nicenesses range from -20 (most favorable scheduling) to 19 (least favorable).
-n, –adjustment=N
add integer N to the niceness (default 10)–help
display this help and exit–version
output version information and exitNOTE: your shell may have its own version of nice, which usually supersedes the version described here. Please refer to your shell’s documentation for details about the options it supports.
Author
Written by David MacKenzie.Reporting Bugs
Report nice bugs to bug-coreutils@gnu.org
GNU coreutils home page: http://www.gnu.org/software/coreutils/
General help using GNU software: http://www.gnu.org/gethelp/
Report nice translation bugs to http://translationproject.org/team/Copyright
Copyright © 2010 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html.This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.
See Also
nice(2)The full documentation for nice is maintained as a Texinfo manual. If the info and nice programs are properly installed at your site, the command
info coreutils aqnice invocationaq
should give you access to the complete manual.
Anyway, the main discussion centred around whether processes still needed to have their niceness adjusted (‘reniced’ in the correct terminology) in these days of processors and amounts of RAM that have capacities many multiples of the systems upon which Unix and Linux were originally designed to run, although no real conclusions were reached, apart from one instance mentioned: that of a process just starting up and slowing the whole system to a crawl. Perhaps readers would like to leave their opinions – if any – in the comments below.
Putting on my language hat and looking at Wikipedia, it seems the etymology of nice is as follows. The name “nice” comes from the fact that the program’s purpose is to modify a process niceness value. The true priority, used to decide how much CPU time to concede to each process, is calculated by the kernel process scheduler from a combination of the niceness values of different processes and other data, such as the amount of I/O done by each process.
The term “niceness” itself originates from the idea that a process with a higher niceness value is “nicer” to other processes in the system, as it allows the other processes more CPU time.
Update: 27/09/12: Alex Butcher of Bristol & Bath LUG has suggested ionice is a more useful tool than nice.