Movatterモバイル変換


[0]ホーム

URL:


Jump to content
WikipediaThe Free Encyclopedia
Search

nice (Unix)

From Wikipedia, the free encyclopedia
Computer utility for Unix-like operating systems
"Renice" redirects here. For the Polish village, seeRenice, Poland.
icon
This articleneeds additional citations forverification. Please helpimprove this article byadding citations to reliable sources. Unsourced material may be challenged and removed.
Find sources: "Nice" Unix – news ·newspapers ·books ·scholar ·JSTOR
(November 2010) (Learn how and when to remove this message)
nice
DeveloperAT&T Bell Laboratories
Initial releaseNovember 1973; 52 years ago (1973-11)
Operating systemUnix andUnix-like
PlatformCross-platform
TypeCommand
Licensecoreutils:GNU GPL v34.4BSD:BSD License

nice is a program found onUnix andUnix-likeoperating systems such asLinux. It directly maps to akernelcall of the same name.nice is used to invoke autility orshell script with a particularCPU priority, thus giving theprocess more or less CPU time than other processes. A niceness of -20 is the lowest niceness, or highest priority. The default niceness for processes is inherited from its parent process and is usually 0.

Systems have diverged on what priority is the lowest. Linux systems document a niceness of 19 as the lowest priority,[1] BSD systems document 20 as the lowest priority.[2] In both cases, the "lowest" priority is documented as running only when nothing else wants to.

Etymology

[edit]

Niceness value is a number attached to processes in *nix systems, that is used along with other data (such as the amount ofI/O done by each process) by the kernel process scheduler to calculate a process' 'true priority'—which is used to decide how much CPU time is allocated to it.

The program's name,nice, is an allusion to its task of modifying a process' niceness value.

The termniceness itself originates from the idea that a process with a higher niceness value isnicer to other processes in the system and to users by virtue of demanding less CPU power—freeing up processing time and power for the more demanding programs, who would in this case be lessnice to the system from a CPU usage perspective.[3]

Use and effect

[edit]

nice becomes useful when several processes are demanding more resources than theCPU can provide. In this state, a higher-priority process will get a larger chunk of the CPU time than a lower-priority process. Only thesuperuser (root) may set the niceness to a lower value (i.e. a higher priority). On Linux it is possible to change/etc/security/limits.conf to allow other users or groups to set low nice values.[4]

If a user wanted to compress a large file without slowing down other processes, they might run the following:

$nice-n19tarcvzfarchive.tgzlargefile

The exact mathematical effect of setting a particular niceness value for a process depends on the details of how thescheduler is designed on that implementation of Unix. A particular operating system's scheduler will also have various heuristics built into it (e.g. to favor processes that are mostly I/O-bound over processes that are CPU-bound). As a simple example, when two otherwise identical CPU-bound processes are running simultaneously on a single-CPU Linux system, each one's share of the CPU time will be proportional to 20 −p, wherep is the process' priority. Thus a process, run withnice +15, will receive 25% of the CPU time allocated to a normal-priority process: (20 − 15)/(20 − 0) = 0.25.[5] On theBSD 4.x scheduler, on the other hand, the ratio in the same example is about ten to one.[citation needed]

Similar commands

[edit]

The relatedrenice program can be used to change the priority of a process that is already running.[1]

Linux also has anionice program, which affects scheduling of I/O rather than CPU time.[6]

See also

[edit]

References

[edit]
  1. ^abrenice(1) – Linux General CommandsManual from ManKier.com
  2. ^"renice(8) - NetBSD Man Pages".NetBSD. October 22, 2020.Archived from the original on April 18, 2023. RetrievedApril 18, 2023.
  3. ^Jerry Peek, Shelley Powers, Tim O'Reilly and Mike Loukides (2002).Unix Power Tools. O'Reilly, p. 507.
  4. ^limits.conf(5) – Linux File FormatsManual from ManKier.com
  5. ^Silberschatz, Abraham; Galvin, Peter B.; Gagne, Greg (2013).Operating system concepts (ninth ed.). Hoboken, N.J: Wiley. p. 294.ISBN 978-1-118-06333-0.
  6. ^ionice(1) – Linux General CommandsManual from ManKier.com

External links

[edit]
The WikibookGuide to Unix has a page on the topic of:Commands
File system
Processes
User environment
Text processing
Shell builtins
Searching
Documentation
Software development
Miscellaneous
File system
Text utilities
Shell utilities
Retrieved from "https://en.wikipedia.org/w/index.php?title=Nice_(Unix)&oldid=1336331115"
Categories:
Hidden categories:

[8]ページ先頭

©2009-2026 Movatter.jp