Linux系统上的优先级处理 [英] Niceness and priority processes on Linux system

查看:187
本文介绍了Linux系统上的优先级处理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一种通过命令行修改进程优先级的方法. 我发现内置的(bash)nice和命令renice可以修改进程的优美性,但不能修改内核计算出的实际优先级.

I am looking for a way to modify a process' priority through command line. I found the builtin (bash) nice and the command renice which allow to modify the niceness of the process, but not the actual priority which is calculated by the kernel.

有没有可以设置优先级的命令? (还是让我感到困惑和优先?)

Is there a command which allows to set the priority? (Or am I confused between niceness and priority?)

推荐答案

Linux中进程的优先级是动态的:它运行的时间越长,其优先级就越低.进程在实际使用CPU时运行-典型Linux机器上的大多数进程仅等待I/O,因此不算作运行.

The priority of a process in linux is dynamic: The longer it runs, the lower its priority will be. A process runs when its actually using the CPU - most processes on a typical Linux box just wait for I/O and thus do not count as running.

当运行的进程多于可用的CPU内核时,将考虑优先级:最高优先级获胜.但是随着制胜进程随着时间的流逝而失去其优势,其他进程将在某个时候接管CPU.

The priority is taken into account when there are more processes running than CPU cores available: Highest priority wins. But as the winning process looses its proirity over time, other processes will take over the CPU at some point.

nicerenice将从优先级添加/删除一些点". nice值较高的进程将获得较少的CPU时间.根也可以设置负的nice值-进程获得更多的CPU时间.

nice and renice will add/remove some "points" from priority. A process which has a higher nice value will get lesser CPU time. Root can also set a negative nice value - the process gets more CPU time.

示例:系统中有两个过程(1和2)计算暂停问题,一个CPU内核.默认值为nice 0,因此两个进程每个都占用大约一半的CPU时间.现在让renice进程1的值为10.结果:进程2与进程1相比,获得了更高的CPU时间.

Example: There are two processes (1 and 2) calculating the halting problem and one CPU core in the system. Default is nice 0, so both processes get about half of the CPU time each. Now lets renice process 1 to value 10. Result: Process 2 gets a significant higher amount of cpu time as process 1.

注意:在现代台式机中,有足够的CPU时间可用-这些天来它们很快.不幸的是,HDD在随机I/O上仍然相对较慢,因此即使 nice 进程也可以生成足够的I/O流量,从而显着降低系统速度.

Note: In modern desktops there is plenty CPU time available - they are fast these days. Unfortunately HDDs are still relativeley slow on random I/O, so even a nice process can generate enough I/O traffic to significantly slow down a system.

这篇关于Linux系统上的优先级处理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆