|
|
Processes in the time-sharing class which are
running in user mode (or in kernel mode
before going to sleep) are scheduled according to the parameters in
a time-sharing dispatcher parameter table
(ts_dptbl).
(Time-sharing processes running in kernel mode after sleeping
are run within a special range of priorities reserved for such processes
and are not affected by the parameters in the ts_dptbl until they
return to user mode.)
The ts_dptbl consists of an array of parameter structures
(struct ts_dpent
), one for each of the n priority levels
used by time-sharing processes in user mode.
The properties of a given priority level i are specified
by the ith parameter structure in this array (ts_dptbli).
A parameter structure consists of the following members. These are also described in the /usr/include/sys/ts.h header file.
ts_globpri
ts_globpri
is the only member of the ts_dptbl which
cannot be changed with
dispadmin(ADM).
ts_quantum
ts_tqexp
ts_slpret
ts_maxwait
ts_dispwait
is initialized to zero each time a
time-sharing process is placed
back on the dispatcher queue after its time quantum has expired
or when it is awakened (ts_dispwait
is not reset to zero when
a process is preempted by a higher priority process).
This counter is incremented once per second for each process on
the dispatcher queue.
If a process's ts_dispwait
value exceeds the ts_maxwait
value
for its level, the process's priority
is changed to that indicated by ts_lwait
.
The purpose of this field is to prevent starvation.
ts_lwait
ts_dispwait
is greater than
ts_maxwait
.
An administrator can affect the behavior of the time-sharing portion of the scheduler by reconfiguring the ts_dptbl. There are two methods available for doing this.
ts_globpri
all of the members of the ts_dptbl
can be examined and modified on a running system
using the
dispadmin(ADM)
command.
Invoking dispadmin for the time-sharing class allows the
administrator to retrieve the current ts_dptbl configuration from
the kernel's in-core table, or overwrite the in-core table with values
from a configuration file.
The configuration file used for input to dispadmin must conform
to the specific format described below.
Blank lines are ignored and any part of a line to the right of a #
symbol is treated as a comment.
The first non-blank, non-comment line must indicate the resolution to be
used for interpreting the ts_quantum
time quantum values.
The resolution is specified as
RES=res
where res is a positive integer between 1 and 1,000,000,000 inclusive
and the resolution used is the reciprocal of res in seconds
(for example, RES=1000
specifies millisecond resolution).
Although very fine (nanosecond) resolution may be specified, the time quantum
lengths are rounded up to the next integral multiple of the system
clock's resolution.
The system clock's resolution is hardware-dependent;
this resolution can be calculated from the value of HZ,
which is defined in the file /usr/include/sys/param.h.
HZ gives the number of clock ticks per second of the system clock.
For example, an HZ of 100 specifies 100 clock ticks per second,
or one tick every 10 milliseconds (that is, this system clock has a resolution
of 10 milliseconds).
If the -t and -r options
are used to specify a time quantum of 34 milliseconds, it is rounded up
to 4 ticks (40 milliseconds) on a machine with an HZ of 100.
The remaining lines in the file are used to specify the parameter values for each of the time-sharing priority levels. The first line specifies the parameters for time-sharing level 0, the second line specifies the parameters for time-sharing level 1, and so on. There must be exactly one line for each configured time-sharing priority level.
No sanity checking is done on the ts_dptbl values specified in the ts master file. Specifying an inconsistent or nonsensical ts_dptbl configuration through the ts master file could cause serious performance problems and/or cause the system to panic.
# Time-Sharing Dispatcher Configuration File RES=1000# ts_quantum ts_tqexp ts_slpret ts_maxwait ts_lwait PRIORITY LEVEL 500 0 10 5 10 # 0 500 0 11 5 11 # 1 500 1 12 5 12 # 2 500 1 13 5 13 # 3 500 2 14 5 14 # 4 500 2 15 5 15 # 5 450 3 16 5 16 # 6 450 3 17 5 17 # 7 . . . . . . . . . . . . . . . . . . . . . 50 48 59 5 59 # 58 50 49 59 5 59 # 59