Set process priority

Source: Internet
Author: User

 

Set Process Priority: Nice and renice

Each process running in the system has a priority (also known as "nice value") ranging from-20 (highest priority) to 19 (lowest priority ). By default, the priority of a process is 0 ("basic" scheduling priority ). Processes with a higher priority (Nice value is relatively small, and the lowest is-20) processes with a lower priority (until 19) will be scheduled to run more frequently, therefore, more process cycles are available. Generally, users can only reduce the priority of their own processes, and the range is between 0 and 19. Superuser (RootCan set the priority of any process to any value.

Renice

If a process or process consumes too much system resources, you can change their priority in addition to terminating them. To do this, useReniceCommand. Its syntax is:

Renice priority [[-p] PID...] [[-G] pgrp...] [[-u] username...]

Where,PriorityIndicates the priority value;PID(For multiple processes, use-P(Optional) indicates the process ID;Pgrp(Use-G) Indicates the process group ID.User(If there are more than one, use-U) Indicates the User Name of the process owner.

Assume that you have run a long time science computing process (with a PID of 785), but you want to play a game and release some system resources. You can:

$ renice +15 785

In this way, your process may take longer to complete, but it will not take the CPU time slice from other processes.

If you are a system administrator and you find that some users have executed too many processes and consumed too much system resources, you only need to enter one command to change the priority of these user processes:

# renice +20 -u li_si

In this way, all li_si processes have the lowest priority, so they will not hinder other users' processes.

Nice

Now that you know that you can change the priority of a process, you may need to execute commands Based on the specified priority. To do this, useNiceCommand.

In this case, you need to use the command you want to runNice. Another parameter-NCan be used to set priority. By defaultNiceSet the priority to 10.

For example, if you want to create an ISO image for the mandrakelinux installation CD-ROM:

$ dd if=/dev/cdrom of=~/mdk1.iso

On some systems that assemble standard ide CD-ROM, copying large amounts of information consumes too much system resources. To prevent the replication operation from interfering with other processes, run the following command to start the process at a lower priority:

$ nice -n 19 dd if=/dev/cdrom of=~/mdk1.iso

Then you can continue to work.

 

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.