HP-UX Reference (11i v1 05/09) - 2 System Calls (vol 5)
r
rtsched(2) rtsched(2)
Note: If the target process is multi-threaded, this change will only affect a child process that is created later
and inherits its parent’s scheduling policy and priority. The priority returned is the old priority of the tar-
get process, though individual threads or lightweight processes may have a different value if some other
interface is used to change an individual thread or lightweight process’ priority.
Appropriate privileges are required to change the scheduling parameters of another process.
The calling process must have appropriate privileges or be a member of a group having
PRIV_RTSCHED
access to successfully call sched_setscheduler()
.
The
sched_setscheduler()
function is considered successful if it succeeds in setting the scheduling
policy and scheduling parameters of the process specified by pid to the values specified by policy and the
structure param, respectively.
sched_getscheduler()
The
sched_getscheduler()
function returns the scheduling policy of the process specified by pid.
The values that can be returned by
sched_getscheduler()
are defined in the header file
<sched.h> (see sched_setscheduler()
).
If a process described by pid exists, the scheduling policy is returned for the process whose process ID is
equal to pid.
If pid is zero, the scheduling policy is returned for the calling process.
If the process pid contains more than one thread or lightweight process (that is, the process is multi-
threaded), this function shall only return the process scheduling policy and priority. Individual threads or
lightweight processes in the target process will have their own scheduling policies and priorities which may
be different from the scheduling policy and priority of their process.
sched_yield()
The
sched_yield() function forces the running process to relinquish the processor until it again
becomes the head of its process list. It takes no arguments.
sched_get_priority_max()
sched_get_priority_min()
The sched_get_priority_max()
and sched_get_priority_min()
functions return the
appropriate maximum or minimum, respectively, for the scheduling policy specified by policy.
The value of policy must be one of the scheduling policy values defined in
<sched.h>.
sched_rr_get_interval()
The
sched_rr_get_interval()
function updates the timespec structure referenced by the interval
argument to contain the current execution time limit (that is, time quantum) for the process indicated by
pid under the
SCHED_RR policy, at which a scheduling decision will be made when another process at the
same priority is ready to execute. If pid is zero, the current execution time limit for the calling process is
returned.
PRI_HPUX_TO_POSIX()
PRI_POSIX_TO_HPUX()
These two functions serve to map (translate) the range of HP-UX priorities into the POSIX.4 model. These
translations are necessary because the POSIX.4 standard chose larger numbers to represent stronger prior-
ities and the existing HP-UX behavior, which must be maintained for backward compatibility, uses smaller
numbers for stronger priorities.
The PRI_HPUX_TO_POSIX() function returns the POSIX.4 scheduling priority corresponding to the
HP-UX priority passed in the argument pri. The value of pri can be any integer.
The PRI_POSIX_TO_HPUX() function returns an HP-UX process priority corresponding to the priority
passed in the argument pri. The value of pri can be any integer. The HP-UX priority returned is compar-
able to the values returned by getpriority() (see getpriority (2)).
Scheduling Policies
The scheduling policies described are defined in terms of a conceptual model, which contains a set of pro-
cess lists. There is, conceptually, one process list for each priority. Any runnable process may be in any
process list. Multiple scheduling policies are provided. Each nonempty list is ordered, and contains a head
as one end of its order, and a tail as the other. The purpose of a scheduling policy is to define the allowable
operations on this set of lists (for example, moving processes between and within lists).
HP-UX 11i Version 1: September 2005 − 3 − Hewlett-Packard Company Section 2−−289