NAME
chrt - manipulate the real-time attributes of a process
SYNOPSIS
chrt [options] priority command argument ...
chrt [options] -p [priority] PID
DESCRIPTION
chrt sets or retrieves the real-time scheduling attributes of an
existing PID, or runs command with the given attributes.
USAGE
The default behavior is to run a new command:
chrt priority command [arguments]
You can also retrieve the real-time attributes of an existing
task:
chrt -p PID
Or set them:
chrt -r -p priority PID
POLICIES
-o, --other
Set scheduling policy to SCHED_OTHER (time-sharing
scheduling). This is the default Linux scheduling policy.
-f, --fifo
Set scheduling policy to SCHED_FIFO (first in-first out).
-r, --rr
Set scheduling policy to SCHED_RR (round-robin scheduling).
When no policy is defined, the SCHED_RR is used as the
default.
-b, --batch
Set scheduling policy to SCHED_BATCH (scheduling batch
processes). Linux-specific, supported since 2.6.16. The
priority argument has to be set to zero.
-i, --idle
Set scheduling policy to SCHED_IDLE (scheduling very low
priority jobs). Linux-specific, supported since 2.6.23. The
priority argument has to be set to zero.
-d, --deadline
Set scheduling policy to SCHED_DEADLINE (sporadic task model
deadline scheduling). Linux-specific, supported since 3.14.
The priority argument has to be set to zero. See also
--sched-runtime, --sched-deadline and --sched-period. The
relation between the options required by the kernel is
runtime ⇐ deadline ⇐ period. chrt copies period to deadline
if --sched-deadline is not specified and deadline to runtime
if --sched-runtime is not specified. It means that at least
--sched-period has to be specified. See sched(7) for more
details.
-o 也就是normal的情况 似乎优先级只能设置为0 输入其他的数值会出现报错
chrt输入 | top里面显示 |
---|---|
50 | -1 - 50 = -51 |
99 | rt |
在top里面 RT进程都显示为优先级负数。
chrt给的优先级数值越大,优先级越高。
有效优先级:
chrt -m
SCHED_OTHER min/max priority : 0/0
SCHED_FIFO min/max priority : 1/99
SCHED_RR min/max priority : 1/99
SCHED_BATCH min/max priority : 0/0
SCHED_IDLE min/max priority : 0/0
SCHED_DEADLINE min/max priority : 0/0
NAME
nice - run a program with modified scheduling priority
SYNOPSIS
nice [OPTION] [COMMAND [ARG]...]
DESCRIPTION
Run COMMAND with an adjusted niceness, which affects process
scheduling. With no COMMAND, print the current niceness.
Niceness values range from -20 (most favorable to the process) to
19 (least favorable to the process).
Niceness values range from -20 (most favorable to the process) to 19 (least favorable to the process).
19最谦让 -20最占CPU
常用参数:
-n 后面接一个数值,范围在-20~19
nice -n -5 vi &
NAME
renice - alter priority of running processes
SYNOPSIS
renice [-n] priority [-g|-p|-u] identifier...
DESCRIPTION
renice alters the scheduling priority of one or more running
processes. The first argument is the priority value to be used.
The other arguments are interpreted as process IDs (by default),
process group IDs, user IDs, or user names. renice'ing a process
group causes all processes in the process group to have their
scheduling priority altered. renice'ing a user causes all
processes owned by the user to have their scheduling priority
altered.
OPTIONS
-n, --priority priority
Specify the scheduling priority to be used for the process,
process group, or user. Use of the option -n or --priority is
optional, but when used it must be the first argument.
-g, --pgrp
Interpret the succeeding arguments as process group IDs.
-p, --pid
Interpret the succeeding arguments as process IDs (the
default).
-u, --user
Interpret the succeeding arguments as usernames or UIDs.
-h, --help
Display help text and exit.
-V, --version
Print version and exit.
EXAMPLES
The following command would change the priority of the processes
with PIDs 987 and 32, plus all processes owned by the users
daemon and root:
renice +1 987 -u daemon root -p 32
看起来可以修改整个用户或者进程组的nice值,以及按照加减来修改