Ability to Use Various Sources of Wakeup Information
Most processes exhibit preferences toward certain quantities of input data. This preference is reflected in the amount of computing time that can be expended for a given amount of input. For example, a character translation routine might prefer eight bit quantities of input. With seven or less bits no processing is possible, but once a complete character is available an entire translation cycle can commence. This preference is independent of the function of the routine. Otherwise equivalent routines could be written that would accept one bit at a time. In other examples, a command interpreter might require a complete line of input, a linking loader a complete file.
Every executive system must face the problem of deciding at what times enough input is available for a given routine for it to run efficiently. This decision can not be taken lightly. Issuing a wakeup to a dormant process carries with it considerable overhead -- room in core storage must be made available, the program must be swapped into memory, tables must be updated, active registers exchanged, and the entire procedure done in reverse once the process has finished. To issue a wakeup when there is insufficient input for the program is inefficient and wasteful. The amount of computing that can be done does not justify the overhead that must be expended.
The problem of determining a priori the best time to issue a wakeup has no general solution. It depends critically upon the relationship between waiting costs and running costs. Attempts to make reasonable predictions must contend with the tradeoff between accuracy and overhead. The more system code that must be run, the more overhead incurred and the less the final prediction means.
Although there is no general solution, help is available to the scheduler in specific cases. A commonly found instance is that of using the receiving process to specify the number of bits that it is expecting. Thus, a process may inform the supervisor/scheduler that it requires fifty bits of input from some source before it is able to continue. The process can then go into the shade and it will be awakened when the required input is available.
In cases where input lengths are predetermined, this technique is quite satisfactory. Elsewhere, problems arise. In the case of unknown input sizes, too short a prediction will give rise to the inefficiencies of premature scheduling, and too long a prediction may produce input deadlocks.
Under these circumstances it is common to have the process tell the scheduler a simple criterion that can be applied to determine if there is sufficient input -- the appearance of a carriage return in the teletype input stream, for example. The criterion is tested either by system routines or by a low overhead user supplied routine (which in turn must have a criterion of its own for being awakened). Once the criterion is met, the main routine is awakened and processing continues.
Sometimes the system and user criteria work in conjunction with one another. A user may specify a maximum character count, corresponding to available buffer size, and the system may look for line terminators. Wakeups to the user process may appear from either source. At other times the system may preempt the user's criterion. For example, if a process while trying to put a single character into a full buffer is forced into shade, it will typically not be awakened again until buffer has been almost emptied. Even though the user program only wished room for a single character, the system imposed a much stronger criterion, namely room for N characters, on the assumption other calls to output characters will follow. Thus the program is forced into outputting in bursts and, rather than going into the shade and being awakened N times, each time when there is only room to output one character, the program is awakened once and sends N characters. Program efficiency is appropriately improved.
A third source of criteria for deciding when to awaken the user process is the device or routine that is producing the input data. This source is frequently utilized in hardware design. Many computer peripherals have the ability to send an end of record indication. For variable length uninterpreted records this is an absolute necessity. For fixed length records it is a convenient double check. In the world of interprocess communication an analogous feature should be available. If the routine that is generating the data knows how much the receiving routine will require, then this information should be made available for scheduling purposes. Implementing this requires a standardized way of denoting logical boundaries on the stream of data flowing through a communication channel. The markers must be recognizable by the scheduler/supervisor in the receiving host computer so that wakeups can be issued as desired. To simplify the task of input interpretation, marker placement should also be visible to the receiving process.
The data between boundaries we shall call a logical message, since it is a natural unit of information exchange and since the markers travel with the data through the channel. The additional information the markers provide about data flow yield many useful consequences. Consider, for example, two processes that always exchange 100 bit long logical messages. If the receiving process is able to determine the length of each logical message that arrives, there is available a simple facility for error detection. If a 99 bit message arrives, it is obvious that a bit has been dropped somewhere.
It should be noted that it is not always possible for the receiving process to compute the positions of boundary markers in the input stream. There is no reason that the information implicit is marker position must also be found as part of the coded input data. Even in cases in which there is coding redundancy, it may be more difficult to extract boundary information from the rest of the input than it is to use the markers explicitly.