![]() |
![]() |
![]() |
Get the program scheduling priority
#include <sys/resource.h> int getpriority( int which, id_t who );
libc
The getpriority() function obtains the current 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, getpriority() returns the highest priority (lowest numerical value) pertaining to any of the specified processes.
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.
Only a process with appropriate privileges can raise its priority (that is, assign a lower numerical priority value).
An integer in the range from -20 to 20, or -1 if an error occurred (errno is set).
Safety: | |
---|---|
Cancellation point | No |
Interrupt handler | No |
Signal handler | Yes |
Thread | Yes |
Because getpriority() can return the value -1 on successful completion, you should set errno to 0 before calling getpriority(). If getpriority() returns -1, check errno to see if an error occurred or if the value is a legitimate priority.
nice, renice in the Utilities reference
![]() |
![]() |
![]() |