Page:CTSS programmer's guide.djvu/25

 program, the supervisor uses a multi-level scheduling algorithm. The basis of the algorithm is the assignment of each user program, as it enters the system to be run (or as a response to a user is completed), to an $\ell$ th level priority queue. Programs are initially entered into a level $\ell_O$ corresponding to their size, such that $$\ell_O = \left[ \log_2 \left( \frac{w_p}{w_q} + 1 \right) \right]$$ where $w_p$ is the number of words in the program, $w_q$  is the number of words which can be transmitted in and out of the high-speed memory from the secondary memory in the time of one quantum, q, and the bracket indicates "the integral part of". Ordinarily the time of a quantum, the basic time unit (currently about 200 ms.), is as small as possible without excessive overhead losses when the supervisor switches from one program in high-speed memory to another. The process starts with the time-sharing supervisor operating the program at the head of the lowest-level occupied queue, $\ell$, for up to $2^\ell$ quanta of time, and then if the program is not completed (i.e. has not made a response to the user) placing it at the end of the $\ell+1$  level queue. If there are no programs entering the system at levels lower than $\ell$, this process proceeds until the queue at level $\ell$ is exhausted; the process is then iteratively begun again at level $\ell + 1$ , where now each program is run for $2^{\ell + 1}$  quanta of time. If during the execution of the $2^\ell$ quanta of a program at level $\ell$, a lower level, $\ell^\prime$ , becomes occupied, the current user is replaced at the end of the $\ell$ th queue and the process is reinitiated at level $\ell^\prime$.

Change of Program Size
Similarly, if a program of size $w_p$ at level $\ell$, during operation requests from the time-sharing supervisor a change in memory size to $w_p^{\prime\prime}$ , then the enlarged (or reduced) version of the program should be placed at the end of the $$\ell^{\prime\prime}$$ queue where $$\ell^{\prime\prime} = \ell + \left[ \log_2 \left( \frac{w_p^{\prime\prime}}{w_p} \right) \right]$$  11