Table of Contents

Name

priocntl - display or set real-time attributes of specified process(es)

Synopsis

priocntl [-m cpu_mask] [-c class] [-p priority] [-C] pid...

priocntl [-m cpu_mask] [-c class] [-p priority] -e command...

priocntl -d pid...

priocntl -l

priocntl -v

priocntl -h

Description

priocntl sets or displays real-time scheduling parameters. The user has the ability to set and retrieve class types, valid priority values that are associated with it’s class, and the CPU affinity for the specified process(es).

Each process is categorized by a specific class type that contains a separate scheduling policy. Each class type contains a numeric range of valid priority values that are specific to itself. Currently, the 2.4 version of the Linux scheduler from kernel.org supports the following class types and priority ranges:

SCHED_OTHER: [0]

SCHED_FIFO:  [1 - 99] 1 = lowest priority, 99 = highest priority

SCHED_RR:   [1 - 99] 1 = lowest priority, 99 = highest priority

Please note that there is currently no overlap in priority between SCHED_OTHER and the other classes. This means that you must also change priority in order to move a process from SCHED_OTHER to one of the other classes, and must set priority back to zero in order to move a process to class SCHED_OTHER. If a process has been set to a class type of SCHED_FIFO or SCHED_RR, the user can change the priority without having to re-specify the class type.

The CPU affinity is represented as a bitmask, with the lowest order bit corresponding to the first logical CPU and the highest order bit corresponding to the last logical CPU. Not all CPUs may exist on a given system but a mask may specify more CPUs than are present. A retrieved mask will reflect only the bits that correspond to CPUs physically on the system. If an invalid mask is given (i.e., one that corresponds to no valid CPUs on the current system) an error is returned. The masks are typically given in hexadecimal. For example,

0x00000001
is processor #0
0x00000003
is processors #0 and #1
0xFFFFFFFF
is all processors (#0 through #31)

When priocntl returns, it is guaranteed that the given program has been scheduled to a legal CPU.

In addition to changing the scheduling and CPU affinity properties for the specified process(es), the user can execute a new command, while setting the class type, priority and CPU affinity. Command execution is run by default, so all that is required when executing a command are the appropriate scheduling parameters (see examples).

Options

-m < mask >,  --mask < mask >
Set the CPU affinity bit mask for the specified process(es). mask can be specified in decimal, octal (leading 0), or hexadecimal (leading 0x) as per strtol(3).
-c < class >,  --class < class >
Set the scheduling class for the specified process(es). Valid scheduling class values are: OTHER, FIFO, and RR. Note the interaction between the class and priority setting.
-p < priority >,  --priority < priority >
Set the priority associated with the class type for the specified process(es). Note the interaction between the class and priority setting.
-C, --children
In addition to the selected process, search for and change the scheduling parameters of all current descendants of the process.
-e, --command
Run a new process, setting it’s scheduling parameters.
-d, --display
Display all current scheduling and CPU affinity status for the specified process(es).
-l, --list
List the current scheduling classes along with their max/min priority values and the number of CPU’s for this system.
-v, --version
Display the current version of the priocntl command.
-h, --help
Display a brief command summary.

Examples

To change processes 500 and 600 to a scheduling class of SCHED_RR with a priority of 34:
priocntl -c RR -p 34 500 600
To change process 500 and all it’s children to a scheduling class of SCHED_RR with a priority of 45:
priocntl -C -c RR -p 45 500
To change the CPU affinity of process 500 to run on CPU 1 only:
priocntl -m 01 500
To change the CPU affinity of process 500 and all it’s children to run on CPU 1 only:
priocntl -C -m 01 500
To execute a command with a scheduling class of SCHED_FIFO and a priority of 10:
priocntl -c FIFO -p 10 -e command...
To execute a command only on CPU 3:
priocntl -m 0x04 -e command...
To change the scheduling priority of process 500 to 99:
priocntl -p 99 500
To display the current scheduling attributes for process 500:
priocntl -d 500

Permissions

A user must possess CAP_SYS_NICE to change the scheduling attributes and CPU affinity of a process. Any user can retrieve the scheduling information and affinity mask.

Author

Written by Travis P. Longoria, with inspiration from Robert Love’s schedutils package. Current version modified and maintained by Bryan Sutula.

Copyright

Copyright © 2003-2006 Hewlett-Packard Development Company, LLP

See Also

nice(1), renice(1), sched_setaffinity(2), sched_getaffinity(2)

See sched_setscheduler(2) for a description of the Linux scheduling scheme.

Bugs

Because of the behavior of some of the system sched_* syscalls, priocntl timidly refuses to manipulate process 0.


Table of Contents