- 30 -

            P10 has several entry points, of which one (the "normal" one, JSP10)
            is conditional, in the sense that the subprogram is only suspended if
            a peripheral holdup is present: all the other entries are guaranteed
            to suspend the subprogram. The following requirements apply to all

            (i)   the correct parameters must be in Q4, and when the subprogram is
                  number 2,4,6 or 8, the correct priority number must be in M5 (to
                  address V25P104M5, etc.).

            (ii)  entry must be made using a "jump to subroutine" instruction.
                  If the subprogram is actually suspended, the link thus planted
                  will be stored in SHUL, so that when the subprogram is re-entered
                  (and this applies even if it is not suspended) it will be at the
                  instruction immediately after the "jump to subroutine".

            (iii) a parameter must be supplied which states how many items (up to
                  3) are to be transferred from SJNS to SHUL* if this entry causes
                  the subprogram to be suspended.

            (iv)  if the subprogram is suspended, P10 is left (after having deposited
                  the appropriate items in SHUL, SHUL* and SHUP) by obeying EXIT 1
                  or EXIT 2, and a further parameter must be supplied to say which
                  of these two alternatives if required. This parameter, and the
                  number of items n (0≤n≤3) which are to be transferred from SJNS to
                  SHUL*, are combined in. one word, referred to below as the "link
                  parameter", which takes the value n or ñ (i.e. -1-n) respectively,
                  according to whether EXIT 1 or EXIT 2 is to be obeyed when leaving

            Thus if P10 is entered with a link parameter of 2, and the subprogram is
            suspended, the overall effect on the SJNS after P10 has finished is that
            3 items have been erased: the top two go to SHUL*, and the third is used
            when EXIT 1 is obeyed to leave P10.   The link planted on entry to P10
            does not count as it goes straight to SHUL. When the subprogram is re-
            entered subsequently by P11 the SJNS will contain (starting at the top and
            working down): the 2 items from SHUL*, a link to return control to P11,
            and links to return control from P11 to P5 and from PS to the long path.

            Note that if a subprogram enters P10 but is not suspended, it will
            continue at the next instruction after the "jump to subroutine" with the
            SJNS, SHUL, etc., unaltered.

            The use of the SJNS to determine where control shall be transferred when
            P10 is left, means that P10 can be used to initiate a subprogram, i.e to
            suspend an activity in such a way that it can be re-entered as a sub­
            program by P11: provided that this initiation, or initial suspension,
            takes place within a subroutine, so that there is in SJNS a link which may
            be used, by EXIT 1 or EXIT 2, when transferring control from P10 after
            the latter has set up SHUL, SHUT,* and SHUP. Because there may be some
            significance in whether this link is used by EXIT 1 or EXIT 2, the choice
            must be specified in the link parameter.

            Once the subprogram has been initiated, and re-entered by P11, any
            subsequent suspension by P10 will cause control to revert to P11, via the
            link planted by the latter - i.e. the subprogram behaves like a subroutine

- 31 - of P11. Whether EXIT 1 or EXIT 2 is used to return control to P11 is immaterial, as either will reenter P11 at the point where it updates Q4 and goes on to examine the next subprogram. Whenever P10 suspends subprogram 2,4,6 or 8, it also sets D47 of the appropriate member of V25P104M5 so that during its suspension, the priority of which this is the main subprogram is also held up. P10 is not used to close down a subprogram, because, as explained in 4.1.5, when a subprogram is re-entered its SHUL is cleared. All that a subprogram needs to do to close itself down is to obey EXIT 1 or EXIT 2 using the link planted by P11. The full power of the P11-P10 combination will be shown in the examples of its uses in connection with FLEX and OUT interrupts. Entries to P10 are as follows:- (a) JSP10: obeyed with the link parameter in N1.. The subprogram is suspended if, and only if, the store area defined by the absolute addresses in I7 and M7 is locked out, or (if C7 is nonzero) if the peripheral unit, whose number is in C7, is busy. The suspension will be the first type of subprogram hold-up, i.e. D0 of SHUL is made zero, and Q7 is transferred to SHUP, by P10. When the subprogram resumes, at the instruction after JSP10, the link parameter will have been erased from N1 and Q7 will be in status quo. (b) JS2P10: obeyed with the link parameter in N3. N2 contains a quantity which P10 will OR with the link before transferring the latter to SHUL. N1 contains the quantity to be transferred by P10 to SHUP. Suspension is unconditional. P10 will erase N1, N2, N3. When the subprogram is reentered by P11 (at the instruction following JS2P10) the disposition of items in Q7, the Nest, etc., will of course depend on the type of suspension determined by D0 of SHUL, and SHUP (see 4.1.5). (c) JS3P10: obeyed with the link parameter in N1. This entry is exactly equivalent to obeying ZERO; Q7; JS2P10; (i.e. like JSP10, with suspension guaranteed). (d) JS4P10: exactly equivalent to obeying ZERO; ZERO; ZERO; JS2P10; This is a simple method of suspending, or initiating, a subprogram so that its re-entry next time P11 is entered is guaranteed, since D0 of SHUL=0 and SHUP.O. SHUL' is also cleared. Apart from the link parameter, the entry JSP10 is the almost exact equivalent of the JS/RWL5/; used in the non-Time-Sharing Director (N6.2). Entry 2 (JS2P10) is so flexible, permitting any type of suspension to be set in SHUL and SHUP, that it is used to set up almost all the subprogram hold-ups implicit in other subroutines, e.g. P8 and P58. P8, the subroutine to set a typewriter query in the flexowriter queue (4.1.3), requires the link parameter in N3 on entry, and its last instruction, after inserting the transfer parameters in the queue, is J2P10. P58 is a subroutine used by OUT 4 and OUT 10 which, given a 2-word identifier in N1
- 32 - and N2, will suspend the subprogram in the correct manner if the required tape is not available. To do this it will obey: REV; (interchange 2 words of identifier) =E20M4; (store 2nd word in SHUP*) SET1; (link parameter - to preserve link for P58 in SHUL*) ZERO; NOT; STR; NEV; (sets D0 in N1) CAB; (1st word of identifier to N1, for SHUP) JS2P10; (to hold up subprogram - SHUL has D0=1) When the subprogram is reentered by P11, which will occur when the new identifier marker, V0P101, is non-zero, the identifier will be transferred by P11 from SHUP and SHUP* to N1 and N2. The link for P58 will be in SJNS, so that the position is exactly as it was when P58 was first entered. The next instruction is therefore: JP58; Note that a subprogram may address its SHUL, SHUP, SHUP*, SHUL*, as E0M4, E10M4, E20M4 and E30M4, respectively. 4.2 FLEX. The action of P4 The subroutine P4 is entered from the long path if FLEX has occurred, i.e. if V16P0 is found to be non-zero. Its first action is to set V19P0 (the EDT marker) non-zero, to ensure that by pressing the Interrupt key on the Flexowriter the operator can force an "artificial" EDT. Subprogram 0 will be used to type the query "TINT". If this subprogram is found to be active (i.e. its SHUL word, V1P11, is non-zero) P4 exits to the long path without clearing V16P0 - this will cause the Director to cycle round the inner loop of the long path until the FLEX RFI can be dealt with. If V1P11 is zero, P4 sets up Q4 with the correct parameters for subprogram 0 (a copy of V0P11) and enters P8 to put the parameters for typing the "TINT" query into the Flexowriter queue, with a link parameter of zero. As explained in 4.1.6, this will cause SHUL (with D0=0) and SHUP (with D0=1) for subprogram 0 to be set up, and will then cause control to be returned to the long path when P8(P10) obeys the link (using EXIT 1) which was planted by the entry to P4. The subsequent actions of P4 therefore take place in subprogram 0, following re-entry by P11 after the query has been answered (giving EDT automatically) and checked. The reply to the query is checked to ensure it is a letter in the right range. If it is not, the query is typed again (preceded by AGAIN): this time, P8 transfers control back to P11 rather than to the long path. When a satisfactory answer is received, a branch is made depending on the value of the letter typed. This branch is made to look like a subroutine jump, so that in effect each TINT is dealt with by a subroutine of P4. These subroutines are: TINT A - P33 " B - P34 TINT M - P45 " E - P37 " P - P48 " G - P39 " R - P50 " H - P40 " S - P51 " I - P41 " T - P52 " J - P42 " U - P53 " L - P44 " V - P54
- 33 - and when each is entered in this context, there will be four links in SJNS: the links to return control to P4, from P4 to P11, from P11 to P5, and from P5 to the long path. Each of these subroutines has two exits. EXIT 2 is the normal exit for a successful execution. EXIT 1 is obeyed when any check fails and causes the TINT query (preceded by AGAIN) to be repeated. To illustrate the ways in which these TINT subroutines exploit P10 and the subprogram system, P33, P41, P45, and P52 are discussed below in some detail. The other TINT subroutines are quite straightforward, and examination of any of them will show that they work in a simple way, and finish by obeying either EXIT 1 (failure) or EXIT 2 (successful execution). Following the successful execution of any of these subroutines, Q4 is liable to have been altered, so the instructions to which EXIT 2 leads are: V0P11; = Q4; EXIT 1; which reset Q4 to the value required by P11, and then return control to P11, leaving subprogram 0 closed down. The value of M5 is immaterial when P11 is resumed. The subroutines P31 (fetch character) and P32 (fetch octal number) are much used by P4 and by the TINT subroutines (they are analogous to /RFC/ and /RFN/ in the non-Time-Sharing Director - see N5.3). Also useful is P56, which extracts a program letter from C7 (where it will have been left by P31) and sets the corresponding priority number in M5. 4.2.1 P33 - TINT A (Terminate program) P31 and P56 are entered to get the priority number of the program concerned into M5. V29P104M5 is examined to see whether the program is in process of termination (V29P104M5 nonzero) or not. If the program is already being terminated, P33 merely sets a 1 in D1 of V29P104M5 if D2 of that word is nonzero (see 2.5), and then ends EXIT 2. If the program is not already in process of termination, TINT A must end it. To do this, it first clears D45 of V25P104M5 (see 2.4) and then, by obeying JS2P10 with a link parameter of -1 (which makes P10 clear SHUL*, and end by obeying EXIT 2) sets up the main subprogram of the priority to be terminated, closing down subprogram 0 as shown below. The steps performed by P33 in doing this are: JSP30; (this most useful subroutine sets up in Q4 the parameters appropriate to the main subprogram of the priority whose number is given in M5) ZERO; NOT; (link parameter) ZERO; (to ensure D0 of SHUL=0) C7; (the character following the program letter; if it is +, the TINT A procedure is different. Here it is masquerading as the final absolute address (in the range 0-63) of a potentially locked-out area, and will thus be stored in SHUP. Since locations 0-63 are never locked-
- 34 - out this is more or less legitimate). JS2P10; (this causes SHUL and SHUP of the priority's main subprogram to be set up as indicated by the parameters in N1 and N2. SHUL* is cleared and P10 obeys EXIT 2 to return control to P4. P4 now restores Q4 to its original value, for subprogram 0, and obeys EXIT1 to return control to P119 Which will soon come to deal with the subprogram newly set up. Subprogram 0 is left closed down since its SHUL is still zero. When the new subprogram is re-entered by P11, M7 will now contain the character following the program letter. If this is + (octal 35), an ending number(4) is placed in V0P29 and P2 entered at reference 2 (see 5.1), causing the Nest and SJNS to be typed out before entry to P15 which sets off the normal termination procedure. Otherwise P15 is entered direct. Note that TINT A does not check whether the priority's main subprogram is suspended or closed down, before taking it over. This characteristic is shared by TINT I (see 4.2.2). It implies that any activity carried out by the main subprogram while its parent program is not being terminated must always suspend itself in such a way that it does not matter if it is closed down (because of program termination or restart) during any suspension. 4.2.2 P41 - TINT I (Restarts) Like P33, P41 uses P31 and P56 to set up the appropriate priority number in M5, and then examines V29P104M5: action is only taken if the latter is zero. This action consists of adding an extra link to the program's SJNS, causing it to resume at syllable 0 (even restart) or 3 (odd restart) of word E4. In the former case, P41 clears the SHUL of the priority's main subprogram, and removes D47 of V25P104M59 by obeying: JSP30; ZERO; =M0M4; SET 1; JSP114; 4.2.3 P45 - TINT M (Store Post-Mortem) TINT M has to carry out two operations which may cause hold-ups: it must allocate itself (the Director) a paper tape punch, and it must output a sequence of messages on that punch. It uses subprogram number 1 for these activities, and accordingly sets up Q4. It may, or may not, be suspended, in the process of obtaining the paper tape punch, and so the first suspension could occur then, or during the output of paper tape: for this reason, a link parameter of -1 has to be used both for suspending the subprogram if a paper tape punch is not available (in which case SHUL is negative and SHUP = D0+D47: JS2P10 is used) and also for the conditional suspension (JSP10) occurring during the actual punching of paper tape. The first suspension closes down subprogram O. Care must be exercised when using P45 because it does not check that subprogram 1 is already in use before using it itself.
- 35 - 4.2.4 P52 - TINT T (Input B program) P52 must read in the priority number at which the B program is to be input, and check that it is not occupied or involved in a priority swop, and that B-program input is not proceeding at any other level. Other checks must be performed on the "operator's store limit", if present, and also on whether 32 words are available for reading the B block. If all the checks are passed, P118 is used to set up the Base Address in V0P104, and the priority number in V0P52 (indicating which priority is involved in B program input). Then the main subprogram of that priority is set up (just as P120 sets up this subprogram when initiating the input of an A program - see 4.1.4). A point of interest about the way this subprogram is set up is that it uses P134 to do it. P134 itself uses JS2P10; the significant thing is that P10 must preserve an extra link (that from P52 to P134) in SHUL*, because this is part of the subprogram rather than the procedures outside it. Also the link parameter must be negative since EXIT 2 is required: so its value is actually -2. Another interesting point is that, once the subprogram is re-entered, it may return to the same setting-up point (in P52 this is:- 3; SET -2; ZERO; ZERO; JSP134;) to suspend itself if a paper tape reader is not available. The same link parameter is used because the P52-P134 link must still be preserved in SHUL*, and it does not matter that P10 returns control to P11 using EXIT 2. Note that when the subprogram suspends itself because there is no paper tape reader available, it does not use the convention of setting D0 of SHUL =1, and SHUP . D0+type number, because this does not give the operator any opportunity of using TINT A to terminate the input request (hence the use of P134). If TINT A occurs, the subprogram clears V2P52 and enters P121 (CRNP FO). Until a paper tape reader is actually allocated and its number stored in V2P529 this V-store is used to hold an indication of whether the PTR is to be pre-allocated (status P) or not. If the unit is not pre-allocated it retains status U but the program letter is inserted in its descriptor to prevent it from being allocated for any other use. It will be noted that, in these four examples, some other subprogram, besides 0, is involved. However the other subprogram is never set up until all the necessary checks have been performed - the failure of a check leads to EXIT 1 and the repetition of the TINT; query. After the new subprogram is set up (using an altered value of Q4) P10 transfers control back to P4 via EXIT 2; this resets Q4 and then returns to P11, leaving subprogram 0 closed down.
- 36 - 5. OUTS (P3, etc) Program Failure (P2) When P3 is entered from the long path following an OUT, its first action is to clear V20P0, the OUT marker. Then it adds 3 syllables to the programs return address which is stored in V16P1, and checks that there is an "OUT number" in the right range stored at the top of the Nest, in V0P1. A copy of this is transferred to the SJNS, and this is used to perform a branch to one of a set of routines dealing with individual OUTS. Unlike the branch following a TINT, this one is not performed like a "jump to subroutine", and the only item in the SJNS when one of these OUT routines has been entered is the link to return control from P3 to the long path. This link will be used by EXIT 1 at the end of an OUT routine, or at its first suspension, At this stage the OUT number, in V0P1, has not been erased from the program's Nesting store, whose contents are in the V-stores of P1. The individual OUT routines are permitted to refer to the program's Nest in these locations, but only until the first suspension occurs, after which P29 must, of course, be used to refer to these items. Each OUT routine must make its own arrangements to remove the OUT number (and any other erasable parameters), and to insert "results", in the program's Nest. The convention is followed that should a program failure occur in one of these OUT routines, P2 (the Program Failure routine) will be entered after the OUT number has been erased from the programs Nest, but will find other parameters as they were on entry to Director. Any OUT routine may want to initiate the main subprogram of the interrupted priority. Anticipating this, the long path will already have stored this priority number in M5, and using P30 will have set the correct parameters for this subprogram in Q4, before entering P3. Also, before branching to the appropriate OUT routine, P3 will set V19P0 (the EDT marker) non-zero, so that after P3 has returned control to the long path, P5, and hence P11, will subsequently be entered, giving the opportunity of re-entry to a suspended subprogram. By causing any OUT activity which involves a hold-up to be carried out by the appropriate subprogram, the Director ensures that the activity has the correct relative priority. The quartets V45P104M5 and V49P104M5 can be used by these subprograms to hold parameters, The OUT routines are: OUT 0 - P15 OUT 6 - P21 OUT 1 - P16 OUT 7 - P21 OUT 2 - P17 OUT 8 - P23 OUT 3 - P18 OUT 9 - P24 OUT 4 - P19 OUT 10 - P61 OUT 5 - P20 Before describing a few of them in detail, it is worth having a closer look at P2, the "Program Failure" subroutine.
- 37 - 5.1 P2 (Program Failure) P2 is entered (using JSP2) from the long path, if a LIV, NOUV, Time Expiry, RESET or "Spurious Interrupt" failure occurs in a program; and also (using JP2) if a check fails in one of the OUT routines, or following a CRNP failure (P121) after OUT 1 - in these cases, there is already a link in SJNS which P2 can use to return control to the long path or to P11. On entry to P2, M5 should contain the failed programs priority number, and Q4 the parameters for its main subprogram. There must be a failure indicator in N1, which is typed out either just as it stands (D0-38 non- zero), or, if D0-38 = 0, as the two-digit octal number in D39-44, followed by L, N, T according to which, if any, of D45, 46, 47 are non-zero (this is the same as the failure indicator required by /RW8/ in the non-Time­ Sharing Director - N7.1). If program termination is unconditional, V0P2 must contain a non-zero "Ending number"; otherwise the familiar "REACT;" -query will be typed later, and termination only occurs if the answer to this query is "A". P2 has a second entry point at reference 2, which occurs after the failure indicator has been typed. This entry is used by TINT A (P33 - see 4.2.1), which sets the ending number "4" in V0P2 before obeying J2P2. At this point P12 is entered to type out the, contents of the programs Nest and SJNS. P12 uses P29 for all references to the Nest and SJNS, except when V6P12 is non-zero: this only occurs following a NOUV interrupt, when it is certain that the contents of the Nest and SJNS are still in the V-stores of P1. After being typed, the program's Nest and SJNS are cleared. If V0P2 is non-zero, this ending number is set in N1, and control now passes to P15 (see 5.2.1) using J1P15. If V0P2 is zero, as is the case for most program failures, the "REACT;" query is typed using the priority's main subprogram. Because this query has to be typed in a different form for each program, it is stored in its four different forms in the V-stores of P2, thus: V2 - 4 - Program P V5 - 7 - Program Q V8 - 10 - Program R V11 - 13 - Program S This avoids falling into the trap mentioned in 4.1.3. The query is typed using P8 with a zero link parameter. If the first character of the reply (in V4, 7, 10 or 13 of P2) is "A", the program must be terminated - the ending number 7 is set in N1, and control passed to P15, using J1P15. Otherwise, the value 4 is stored in the program's SJNS (to act as the re-entry address), and the programs time limit is replaced by its run time to date plus 4 seconds. P2 ends by obeying EXIT 1, thus closing down the main subprogram.
- 38 - 5.2 OUT Routines All these routines act as extensions of P3, and, in the case of P15, of P33 (TINT A), and P2 (Program Failure). All are expected to end EXIT 1, and therefore to use a positive link parameter at any subprogram suspension. P23 has features intended for use by all OUTs, present and future, which perform peripheral transfers on a programs behalf, and is discussed separately in section 5.3. Before describing individual routines, mention should be made of the useful subroutine P62. This is used before any suspension occurs. It erases the OUT number from the programs Nest, checks that the latter contains at least one more item, and leaves two copies of that next item in N1 and N2, without erasing it. 5.2.1 P15 (OUT 0) and P17 (OUT 2) P15 has 3 entry points. The initial actions of P15 are described below, with the entry points indicated. - main entry (JP15 - used by OUT 0): set ending number of zero in N1; - second entry point (J1P15 - used by P2 and P33): given the ending number in the Nest, sets 5 (the termination marker, to be stored in V29P104M5), in N1; - third entry point (J2P15 - used by P17 (OUT 2)): at this stage the ending number is in N2 and the termination marker is in Nl. The latter has the value 5 unless termination is by OUT 2, in which case it is 8 (A-program) or 9 (B-program). From this point the important actions of P15 are:- - to add D0 to the termination marker, store it in V29P104M5, and set D46 of V25P104M5 non-zero. - to dispose of peripheral units. Any unit allocated or pre- allocated to a program has its current transfer cleared. If it is a magnetic tape, a "block-counting" rewind is performed. Units of other types revert to status U, unless OUT 2 is being performed for an A-program, in which case these units revert to status P. Note that it is possible to find a unit in status A even after the program has obeyed OUT 6 to deallocate it, because the unit must stay in that status until it is no longer busy (the program being prevented from continuing by reason of a suspension of its main subprogram). If, while the unit is still busy, TINT A is executed, the subprogram is forcibly closed down, the unit remains in status A, and, if it is still busy, will have its transfer cleared. Thus there is a slight danger that if a busy unit is de-allocated by OUT 6, the transfer may still be cut short if TINT A occurs before it has finished. This could not
- 39 - arise with the non-Time-Sharing Director because no TINT could be performed while the Director was waiting for the transfer to end. - if the second (OUT 8) subprogram of this priority is closed down, i.e. if E1M4 is zero, P15 sets it up again so that its SHUP (E11M4) and SHUL* (E31M4) are zero, and its SHUL (E1M4) contains a (positive) link causing it to be entered at reference 99 of P23 (see 5.3). P15 now suspends itself (using JS4P10) until V29P104M5 is positive. It will be recalled that D0 of this word was made non- zero at the third entry point to P15. This is interpreted by the second subprogram as a signal that the program is to be terminated and accordingly it winds up all OUT 8 - type processes. When it has done this and the programs store area is free of lock-outs, it clears D0 of V29P104M5 and closes itself down. P15 can now resume and it types out on the log the details of the last program. If OUT 2 is in progress, P15 next modifies the program's NOL if required, using a value left by P17 in V45P1O4M5, and ends by obeying J44P120 - this causes P120, the program input routine, to be joined at the point where the details of the new program are typed on the log, and, inter alia, V29P104M5 and D46 of V25P104M5 are cleared before EXIT 1 is obeyed, closing down the main subprogram. If not initiated by OUT 2, P15 obeys J10P121 - this transfers control to the last stage of the CRNP failure routine, in which BA and NOL (V9P0M5) are cleared, the "program present" bit is removed from V0P104, the area the program occupied is checked to ensure no lockouts remain, and that priority's PHU store is cleared. EXIT 1 is obeyed to close down the main subprogram. V29P104M5 is left with the value 5 in it. P17 (OUT 2) first carries out various checks on the new program identifier, store size, etc. before setting an ending number of 2 and a termination marker value of 8 (A-program) or 9, and obeying J2P15. Any failure will lead to P2, an ending number of 6 first having been placed in V0P2. One interesting feature is the preservation of the contents of D24-47 of E0 in V33P104M5. This is a buffer used by TINT B, if executed while a program is in process of termination, and its contents will be restored to E0 by P120 when it is eventually entered at reference 44. The value of NOL for the new program is left by P17 in V45P104M5, to be used by P15.