
{ PURPOSE:
{   The purpose of this procedure is to pre-select a CPU for a ready task
{   to execute on, or place the ready task into the dispatch_control_table (DCT).
{
{ DESIGN:
{   Integer representation of dispatching priorities:
{     To accommodate dispatching allocation (guaranteeing minimum and maximum
{     percentages of the total CPU time to specified user dispatching priorities),
{     each dispatching priority falls into one of three sets.  The sets are defined
{     in one word of memory in the following order:
{
{     BYTE:    63...............................................................0
{     PRIORITY:                  15    ..      0 15     ..      0 15    ..      0
{               _________________________________________________________________
{              |                |               |                |               |
{              |________________|_______________|________________|_______________|
{                                     SET 3            SET 2           SET 1
{
{     SET 1:  Tasks of priorities in this set have exceeded their maximum dispatching
{             priority allocation.
{     SET 2:  Tasks of priorities in this set have achieved their minimum dispatching
{             priority allocation, but have not exceeded their maximum allocation.
{     SET 3:  Tasks of priorities in this set have not yet achieved their minimum
{             dispatching allocation.
{
{     When the word containing the dispatching priority sets is normalized and
{     converted to an integer, any SET 3 task has a higher dispatching priority integer
{     than any SET 2 task, which in turn has a higher dispatching priority integer
{     than any SET 1 task.  Thus, a SET 3-P4 task has a higher dispatching priority
{     integer than a SET 2-P8 task.
{
{     NOTE:  Sub-system and system priorities (P9..P14) are always placed in SET 3, so
{            they will always have a higher dispatching priority integer value than
{            any user dispatching priority.
{
{   Task pre-selection or placement in the DCT:
{     Task pre-selection will be attempted only if the job with the ready task allows
{     multiprocessing or has no other tasks currently executing.  If the ready task
{     is going through task_switch and is still ready (its time slice has expired),
{     pre-selection will be attempted only if the job allows multiprocessing or has
{     no other ready tasks.  (This prevents a non-multiprocessing job with a CPU bound
{     task from shutting out other tasks of the job.)
{
{     The ready task will be pre-selected to run on the first idle CPU that is found,
{     or on the the lowest dispatching priority (integer) CPU currently executing, if
{     the ready task has a higher dispatching priority integer.  If the CPU that is
{     pre-selected is currently executing another task, that CPU will be interrupted.
{
{     If the ready task cannot be pre-selected to execute on a CPU, the task is inserted
{     into the DCT.
{
{   The dispatch_control_table (DCT):
{     The DCT is an array of singularly linked lists. There is a list for each
{     dispatching priority.  There are four different pointers into each list:
{     the head pointer, the tail pointer, the minor priority pointer, and the
{     major priority pointer.
{
{     Each job class has a major and a minor timeslice. The major and minor
{     timeslice of a job class can be modified by using the change_class_attribute
{     command. When a task is initially dispatched, it is placed after the minor
{     priority pointer in the DCT. "Ready tasks" are placed after the minor
{     priority pointer as long as the minor timeslice in the tasks XCB is greater
{     than one_eighth of the job class minor timeslice. Both the minor and the
{     major timeslice in the XCB of a task are decremented by the amount of time that
{     the task uses the CPU. Once the minor timeslice in the XCB is zero, the task
{     is placed after the major priority pointer in the dispatch control table.
{     The minor timeslice in the XCB is also reset. When a task finally uses all
{     of its major timeslice, it is next dispatched at the tail of the DCT. Both
{     the major and minor timeslice in the XCB are then reset.
{
{     |----------|
{     |   HEAD   | ------------->  TASK
{     |----------|                 TASK          Example of a DCT with five
{     |  MINOR   | ------------->  TASK          tasks waiting to be dispatched.
{     |----------|
{     |  MAJOR   | ------------->  TASK
{     |----------|
{     |   TAIL   | ------------->  TASK
{     |----------|

