setpri Subroutine

Purpose

Sets a process scheduling priority to a constant value.

Library

Standard C Library (libc.a)

Syntax

#include <sys/sched.h>

int setpri ( ProcessID,  Priority)
pid_t ProcessID;
int Priority;

Description

The setpri subroutine sets the scheduling priority of all threads in a process to be a constant. All threads have their scheduling policies changed to SCHED_RR. A process nice value and CPU usage can no longer be used to determine a process scheduling priority. Only processes that have root user authority can set a process scheduling priority to a constant.

Parameters

Item Description
ProcessID Specifies the process ID. If this value is 0 then the current process scheduling priority is set to a constant.
Priority Specifies the scheduling priority for the process. A lower number value designates a higher scheduling priority. The Priority parameter must be in the range PRIORITY_MIN < Priority < PRIORITY_MAX. (See the sys/sched.h file.)

Return Values

Upon successful completion, the setpri subroutine returns the former scheduling priority of the process just changed. Otherwise, a value of -1 is returned and the errno global variable is set to indicate the error.

Error Codes

The setpri subroutine is unsuccessful if one or more of the following is true:

Item Description
EINVAL The priority specified by the Priority parameter is outside the range of acceptable priorities.
EPERM The process executing the setpri subroutine call does not have root user authority.
ESRCH No process can be found corresponding to that specified by the ProcessID parameter.