词条 | Nice (Unix) |
释义 |
| name = nice | logo = | screenshot = | screenshot size = | caption = | developer = AT&T Bell Laboratories | released = {{Start date and age|1973|11}} | latest release version = | latest release date = | operating system = Unix and Unix-like | genre = Command | license = coreutils: GNU GPL v3 | website = }}nice is a program found on Unix and Unix-like operating systems such as Linux. It directly maps to a kernel call of the same name. nice is used to invoke a utility or shell script with a particular priority, thus giving the process more or less CPU time than other processes. A niceness of −20 is the highest priority and 19 is the lowest priority. The default niceness for processes is inherited from its parent process and is usually 0. The version of nice bundled in GNU coreutils was written by David MacKenzie.[1]Use and effectnice becomes useful when several processes are demanding more resources than the CPU can provide. In this state, a higher-priority process will get a larger chunk of the CPU time than a lower-priority process. Only the superuser (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.[2]If a user wanted to compress a large file, but not slow down other processes, they might run the following: The exact mathematical effect of setting a particular niceness value for a process depends on the details of how the scheduler 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, where p is the process' priority. Thus a process run with nice +15 will receive 25% of the CPU time allocated to a normal-priority process: (20 − 15)/(20 − 0) = 0.25.[3] On the BSD 4.x scheduler, on the other hand, the ratio in the same example is about ten to one.{{Citation needed|date=November 2013}} Similar commandsThe related renice program can be used to change the priority of a process that is already running. [4] Linux also has an ionice program, which affects scheduling of I/O rather than CPU time. [5] EtymologyThe 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 different processes' niceness values and other data, such as the amount of I/O done by each process. The name "niceness" originates from the idea that a process with a higher niceness value is "nicer" to other processes in the system: This is why the nice number is usually called niceness: a job with a high niceness is very kind to the users of your system (i.e., it runs at low priority), while a job with little niceness utilises more of the CPU. The term "niceness" could be considered awkward. Unfortunately, it's the only term that is both accurate (nice numbers are used to compute the priorities but are not the priorities themselves) and avoids horrible circumlocutions ("increasing the priority means lowering the priority...").[6] See also
References1. ^https://linux.die.net/man/1/nice 2. ^{{man|5|limits.conf|ManKier}} 3. ^{{cite book|last1=College|first1=Abraham Silberschatz, Yale University, Peter Baer Galvin, Pluribus Networks, Greg Gagne, Westminster|last2=Baer Galvin|first2=Peter|last3=Gagne|first3=Greg|title=Operating system concepts|date=2013|publisher=Wiley|location=Hoboken, N.J|isbn=978-1-118-06333-0|page=294|edition=Ninth edition.}} 4. ^{{cite web|title=Linux man page for renice |url=http://linux.die.net/man/8/renice|accessdate=17 April 2016}} 5. ^{{cite web|title=Linux man page for ionice|url=http://linux.die.net/man/1/ionice|accessdate=17 April 2016}} 6. ^Jerry Peek, Shelley Powers, Tim O'Reilly and Mike Loukides (2007). Unix Power Tools. O'Reilly, p. 507. External links
2 : Unix SUS2008 utilities|Unix process- and task-management-related software |
随便看 |
|
开放百科全书收录14589846条英语、德语、日语等多语种百科知识,基本涵盖了大多数领域的百科知识,是一部内容自由、开放的电子版国际百科全书。