Linux Process Priority implementation

Source: Internet
Author: User

First the Linux process priority range is 20 to 19

Package The documents directory under the current directory, but do not want tar to consume too much CPU:

Nice-19 tar zcf pack.tar.gz documents

The "-" in this "-19" represents only the parameter prefix, so if you want to give the tar process the highest priority, execute:

Nice--19 tar zcf pack.tar.gz documents

You can also modify the priority of a process that already exists:

Set the PID 1799 process priority to the lowest:

Renice 19 1799

The Renice command is the opposite of the priority parameter of the Nice command, directly with the priority value as an argument, without the "-" prefix.

Process CPU Resource allocation refers to the priority of the process. High priority processes have priority rights to implementation. Configuring process precedence is useful for Linux in multitasking environments and can improve system performance. The process can also be run to the specified CPU, so that the non-important process to a certain CPU, can greatly improve the overall performance of the system.

First, look at the system process:

First of all, I would like to use a simple command to raise the issue. In Linux or UNIX systems, using the PS–L command will output the following several things:

[Email protected] root]# Ps–l---This is a Linux test.
F S UID PID PPID C PRI NI ADDR SZ Wchan TTY time CMD
4 S 0 20538 20534 0 0-1063 wait4 pts/2 00:00:00 Bash
4 R 0 20663 20538 0 0-828-PTS/2 00:00:00 PS

It is easy to notice a few of these important information, there are the following:
UID: Representing the identity of the performer
PID: Represents the code for this process
PPID: Represents which process is derived from the process, that is, the name of the parent process
PRI: Represents the priority that the process can be executed, and the smaller the value, the sooner it is executed
NI: The nice value representing the process (priority up-down activity value)
Here's the previous three information, we are relatively easy to understand, but the following two strange information, one is a pri, one is NI, what is this? In contrast, thepri is still better understood, that is, the priority of the process, or the popular point is that the program is executed by the CPU sequence, the smaller the value of the process of higher priority . What about NI? That's what we're talking about. The nice value, which represents the corrected value of the priority that the process can be executed. As mentioned earlier, the smaller the PRI value, the faster it is executed, then the addition of the Nice value will make the PRI:pri (new) =pri (old) +nice. Thus, when the nice value is negative, the program will lower the priority value, i.e. its priority will be higher, and the faster it is executed.

so far, it is important to emphasize that the nice value of the process is not a process priority, they are not a concept, but the process nice value affects the process's priority change .

—————————————————————————
Second, the command to modify the priority of the process has two main: Nice,renice

1. start executing the program to specify a nice value: Nice

Nice-n -5/usr/local/mysql/bin/mysqld_safe &

  

Linux Nice command details

Function Description: Set priority.

Syntax: Nice [-n < priority level >][--help][--version][execution Instructions]

Additional note: The Nice directive can change the priority level of program execution.

Parameter:-n< priority level > or-< priority level > or –adjustment=< priority > Set priority level for the instruction to be executed. Levels range from 20-19, where-20 is the highest, 19 lowest, and only system administrators can set negative levels.
Help online Help.
–version Displays version information.
—————————————————————————
2.1, adjust the existing process Nice:renice

Renice-5-P 5200#pid 5200 process Nice set to-5

Linux Renice Command detailed

Function Description: Adjust priority.

Syntax: Renice [Priority Level][-G < program group name ...] [-p < Program identification Code, ....] [-u < user name; ...]

Additional note: The Renice directive can readjust the priority level of the program execution. The preset is to adjust its priority with the program identification Code designation program, you can also specify the program group or user name to adjust the priority level, and modify all the programs that belong to the program group or user priority. Level range from -20–19, only system administrators can change the priority of other user programs, and only system administrators can set negative levels.
Parameters
-G < program group name > Use the program group name to modify the priority of all programs that belong to the program group.
-P < Program identification code > change the program's priority level, this parameter is a preset value.
-u < user name > Specify user name, modify the priority of all programs that belong to the user.

2.2. You can also change the existing process's nice with the top command:

top# Enter top and press "R" –> input process pid–> input Nice value

  

Transcription: http://blog.chinaunix.net/uid-24517549-id-3969451.html

--

Linux process priority implementation

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.