HP-UX Reference (11i v3 07/02) - 2 System Calls (vol 5)
r
rtsched(2) rtsched(2)
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 thread
lists. There is, conceptually, one thread list for each priority. Any runnable thread may be in any thread
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 opera-
tions on this set of lists (for example, moving threads between and within lists).
Each thread will be controlled by an associated scheduling policy and priority. These parameters may be
specified by explicit application execution of the
sched_setscheduler()
or sched_setparam()
functions. (However, these functions change scheduling parameters at process level for multithreaded
processes).
Associated with each policy is a priority range. The priority ranges for each policy can (but need not) over-
lap the priority ranges of other policies.
When a thread is to be selected to run, the thread that is at the head of the highest priority nonempty
thread list is chosen. It is then removed from its thread list.
The following scheduling policies are defined:
SCHED_FIFO First in-first out (FIFO) scheduling policy.
Threads scheduled under this policy are chosen from a thread list that is ordered by
the time its threads have been in the list without being executed. Generally, the head
of the list is the thread that has been in the list the longest time, and the tail is the
thread that has been in the list the shortest time.
Under the SCHED_FIFO policy, the modification of the definitional thread lists is as
follows:
• When a running thread becomes a preempted thread, it becomes the head of the
thread list for its priority.
• When a blocked thread becomes a runnable thread, it becomes the tail of the
thread list for its priority.
• When a running thread calls the sched_setscheduler()
function, the pro-
cess specified in the function call is modified to the policy and priority specified
by the param argument. If the thread of a process whose policy and priority
have been modified is running or is runnable, it then becomes the tail of the
thread list for its new priority.
• When a running thread calls the
sched_setparam() function, the priority of
the process specified in the function call is modified to the priority specified by
the param argument. If the thread of a process whose priority has been
modified is running or is runnable, it then becomes the tail of the thread list for
its new priority.
• When a running thread issues the sched_yield() function, the thread
becomes the tail of the thread list for its priority.
• At no other time is the position of a thread with this scheduling policy within the
thread lists affected.
For this policy, valid priorities are within the range returned by the functions
sched_get_priority_max() and sched_get_priority_min() when
SCHED_FIFO is provided as the parameter. The priority range for this policy
HP-UX 11i Version 3: February 2007 − 4 − Hewlett-Packard Company 349