![]() |
![]() |
![]() |
Set the program scheduling priority
#include <sys/resource.h> int setpriority( int which, id_t who, int priority );
libc
The setpriority() function sets the scheduling priority of a process, process group, or user.
Target processes are specified by the values of the which and who arguments. The which argument indicates how to interpret the who argument:
If which is: | Then who is a: |
---|---|
PRIO_PROCESS | Process ID |
PRIO_PGRP | Process group ID |
PRIO_USER | User ID |
A 0 value for the who argument specifies the current process, process group, or user.
If more than one process is specified, setpriority() sets the priorities of all of the specified processes to the specified value.
The default priority is 0; negative priorities cause more favorable scheduling. While the range of valid priority values is [-20, 20], implementations may enforce more restrictive limits. If the value specified to setpriority() is less than the system's lowest supported priority value, the system's lowest supported value is used; if it is greater than the system's highest supported value, the system's highest supported value is used.
Only a process with appropriate privileges can raise its priority (that is, assign a lower numerical priority value).
Safety: | |
---|---|
Cancellation point | No |
Interrupt handler | No |
Signal handler | Yes |
Thread | Yes |
The effect of changing the scheduling priority may vary depending on the process-scheduling algorithm in effect.
nice, renice in the Utilities reference
![]() |
![]() |
![]() |