R 21_TSSref Man 21 TSSref
R-21_TSSrefMan R-21_TSSrefMan
User Manual: R-21_TSSrefMan
Open the PDF directly: View PDF .
Page Count: 105
Download | |
Open PDF In Browser | View PDF |
, .. ... tHo ~.~ " -I, .. c REFERENCE MANUAL TIME-SHARING SYSTEM L. Peter Deutsch Larry Durham Butler W. Lampson University of California~ Berkeley Document No. R-2l Revised October 22, 1968 Office of Secretary of Defense Advanced Research Projects Agency 20325 Washington, D. C. () TABLE OF CONTENTS ······ 1.0 Introductory • 2.0 The Scheduler. PAC TABLE. Phantom user queue entry. 3·0 Forks and Jobs 3.1 Creation of Forks Hierarchy of Processes 3·2 Memory Acquisition. 3·3 Panic Conditions. 3.4 Jobs. Job Tables • • • 4.0 Program Interrupts • 5·0 The Swapper and Memory Allocation. 6.0 Miscellaneous Features 7.0 Teletype Input-Output. • TELETYPE SYSTEM POINTERS TELE'rYPE ~LE • TELETYPE BUFFERS 8.0 Drum and Buffer Organization; Devices. 8.1 File Storage on the Drum. 8.2 File Buffers. 8.3 Devices Layout of a File Buffer. Format of an Index Block · Device Indexed Tables 9·0 Sequential Files · · 9·1 Sequential Drum Files 9·2 Other Sequential Files. 9.3 File Control Blocks • • • 9.4 Permanently OVen Files. 10.0 Random Drum Files. • 10.1 Direct Drum Access 11.0 Subroutine Files ...···· C) . · · · · · ·· ·· ·· · · · · · ···· ···· ······ ····· ···· ······· ··· ··· ·············· ···· · · · ······ ··· ·· ····• · ···· ·· ···· ···· ··· ·· . · · · · ·· ·· · · · ·· ··· ···· · ·· · . . · · ·· ·· () ···. . .' ·· ·· ····. ···· · ·· · ·· · ..... ·. . .· .· · · ·· · · ·· · · · · · . · .. .. • . .. ··· ··· . · ·· ··· ······· ···· ····· 1-1 2-1 2A 2B 3-1 3-1 3A 3-4 3-5 3-7. 3B 4-1 5-1 6-1 7-1 7A 7B 7C 8-1 8-1 8-2 8-3 SA SA 8B 9-1 9-1 9-7 9-11 9-11 10-1 10-3 11-1 iI I I I II i I I II .... ....... 12.0 File 12.1 12.2 12.3 12.4 12.5 TAPE Naming System • • • • • File Naming. • • • •• Accessing Other Users' Files, Special Groups ••• Pseudonyms . . . • . • • . • • . . . Doing I/O to Files, File Numbers Opening Input Files. • • . • • or PERMANENT FILES. . • • SCRATCH FILES. . . .. .. BUILT-IN FILES • SPECIAL GROUPS • PSEUDONYMS. • . FILE DIRECTORY DESCRIPTION • • USER DIRECTORY DESCRIPTION • .. 12.6 Opening Output Files ••. 12.7 Miscellaneous File Operations •• 12.8 Opening Scratch Files . • • . • • 12.9 Format of the File Directory, Some Implementation ... ..... .. . ... Details . . . . . . . . . . . . . .... . .. .... leA-2 l2A-2 ... ... . 12-13 12.. 14 13-1 14-1 14-1 14-1 14,,3 14-3 14-4 l5-1 l5-1 l5-2 15-3 l5-4 A.. l . B-1 .... .. leA-l leA-3 leA.. 4 12-8 12-10 12-12 12.10 Miscellaneous Services •••• 13.0 Miscellaneous Executive Features • • . . . . . . . 14.0 String Processing System. • • • . • • . . • • . J.4.1 String Pointer Load and Store Operations. • • . 14.2 String Read and Write Operations . 14.3 String Compe.re Operations ••• • . . 14.4 String Input/Output. • • . • • 14.5 Hash Table Lookup Instructions . l5.0 Floating Point Instructions • • • • • l5.1 Floating Point Representation •• l5.2 Floating Point Arithmetic ••• l5.3 Input/Output Formats and Conventions. .. .. 15.4 Input/Output Operations •• . . . BRS '1!A.BLE. .. SYSTEM PROGRAMMED OPERATORS. • . 12-1 12-2 12-4 12..5 12-5 12-6 leA-l leA-l . .... 1-1 1.0 Introductorl () (~/ The Berkeley Time-Sharing System is divided into three major parts: The monitor, the executive, and the subsystems. Only the firat two of these are discussed in detail in this manual. The manual attempts to describe exhaustively all the features of the monitor and in addition to give a number of implementation details. It also describes those features of the executive which can be invoked by a program. We use the word monitor to refer to that portion of the system which is concerned with scheduling, input-output, interrupt processing, memory allocation and swapping, and the control of active programs. The executive, on the other hand, is concerned with the control of the directory of symbolic file names and backup storage for these files, and various miscellaneous matters. Other parts of the executive handle the command language by which the u.er controll the syatem trom hil teletype, the identification of users and specification of the limits of their access to the system. These subjects are discussed in the executive reference manual, Document R-22. The next ten sections of this manual discuss various features of the monitor. The remaining sections deal with the executive. 2-1 2.0 The Scheduler C) ([) The primary entities with which the time-sharing system is concerned are called active ~ograms.Each active program is an abstract object capable of executing machine instructions. At least one active program is associated with each active user, but a user may have many programs, each computing independently under his control. An active program is defined by its entry in the program active table (PAC table or PACT). This table contains all of the information required to specify the instantaneous state of the extended computer which the user is programming, except for that contained in the user's memory or in the system's permanent tables. The structure of a PACT entry is displayed on the following page, together with brief notes about the significance of the various items. These matters will be explained in more detail in the following few sections. It will be observed that PACT contains locations for saving the program counter and the contents of the active A, B and X registers. It also contains two pseudo-relabeling registers for the user. A third one, which specifies the monitor map, is kept in the job tables. The matter of pseudo-relabeling is discussed in detail in Section 5. There is a word called PTEST which determines the conditions under which the program should be reactivated if it is not currently running. The panic table address in ~B and the three pointers called PFORK, PDOWN and PPAR are discussed in Section 3 on forks. The word called PTAB contains in bits 2 through 8 the number of the job to which this program belongs. The top of PQU contains information about the amount of time for which the program is allowed to canpute before it is dismissed. A job table called QUR countrthe number of clock cycles remaining before the program is dismissed, and three bits of QUTAB point to a table which specifies the length of time which the program should be allowed to run when it is activated. All times in the discussion are measured in periods of the 60-cycle compu·t.er clock. :1 2A PAC TABLE PNEXT PL c) next queue or next program in queue U 0 ~ 0 M 3" file 11= of 8 subroutine 0 file saved (p) PA saved (A) PB saved (B) PX saved (X) RLl first pseudo-relabeling register . RL2 second pseudo-relabeling register 11 12 0 PPTR PrEST PQU PTAB pm PF~RK PD¢WN 3activation condition 000 E li·· 2 tj QH X B 0 M 0 11.0 test word address, or other relevant parameter 11 12 9 PPAR QUTAB P.O 8 2 L tj job number T N E 14 T w T M M 0 23 23 23 23 panic table address 23 !EM UN • user mode (1) or system OV = overflow PD¢WN .. PACT address of lower fork (if an,y) PFPRK .. PACT address of' upper fork (if' any) PPAR III PACT address of parallel fork (ends with 0) QUXAB .. address of word in table indicating quantum lengths EB = exec BRS EX • executive type program QN = saved queue number if on QOV TW = waiting for termination !EM 1M MT I = interrupt = local enabled mask memory = add. no memory NT EM = non-terminable = destroy memory when fork is terminated 2-2 A program is allowed to run for a fixed period of t 1me I after which it i8 dismissed if any other programs are ready to run. This time is called a !2!li quantum. It may' be different for dirterent progr&llli. In tact, the size of the long quantum il determined by the entry in QTAB which 1s pointed to by the program's QU'!'AB in PACT. When a program is activated, it is tirst allOwed to run tor a short 9,U:antum. During this time it cannot be dismissed except by its own request. The length of the short quantum is tentatively going to be the lame for all users. It 18 put into a word called TIME; the long quantum is also put into a word called !TIME at this time. Both are decremented at every clock cycle. When TlME goes negative, a word called ACTR is checked to determine whether any program which is dismissed for I/O can be run. If not, the program is allowed to continue. At each subsequent clock cycle the program may be dismissed it MY programs dismissed for I/O are ready to run. It may alao be dismissed when the long quantum il exhaulted it any other programs are waiting to run. In either case it il said to be dismissed for quantum overflow. If AOTR indicates that another program dismissed for I/O is ready to .run at the end of the Ihort quantum" the program is also dismissed for quantum .overflow . In order to allow an effiCient implementation of this scheme, AC'm is incremented by every :l.nterruptrout:l.ne which takes action al1ow1ng a program which is waiting for I/O to run. ACTR is set to-l when a program is activated. When a program is dilDlissed tor I/O, TTIME is put into QUR. When the prograa is reactivated, TTJME i8 set trom Q,UR. TlME i. relet to the fuU short. quantum. That is, the long quantum is allowed to run down while a program computes, regardless of whether it has to wait tor I/O between ccmputations. On the other hand, a program is alN8 liven a full ahort q,uantum. If' a program is dilDlissed tor quantum overflow, it is given a new long quantum when it is reactivated. There are two operations available to the user which are connected with the quantum overflow machinery. BRS 4; causes the user to be di_used as though he had overflowed his quantum. BRS 57 guarantee. to the user upon return at least 16 msec of 2-3 C) c) C-) / uninterrupted computation. This feature is implemented by dismissing the user if less than 16 msec remain in his quantum. Ordinarily, the code which is being executed at any particular instant is that belonging to the program which is currently active. This situation may be disturbed, however, by the occurrence of interrupts from I/O devices. These interrupts cause the computer to enter system mode and are processed entirely independently of the currently running program. They never take direct action to disturb the running of this program, although they may set up conditions in memory which will cause some other program to be activated when the presently running one is dismissed. Interrupt routines always run in system mode. other code which may be running which may not belong to the program currently active is the code of system programmed operators or BRS routines. These routines are not re-entrant and therefore should not be dismissed by the clock. To ensure that they will not be, the convention is established that the clock will not dismiss a program running in system~. In order to guarantee that a user program will not monopolize the machine by executing a large number of SYSPOPs, the user mode trap is turned on when the clock indicates that a program is to be dismissed. The trap will occur and cause dismissal as soon as the program returns to user mode. The PACT word called PTEST contains the activation condition for a currently inactive program. The condition for activation i8 contained in the 6 opcode bits of this word, while the address field normally contains the absolute address of a word to be tested for the specified condition. (ThiS word is usually something like 'l'1'YBRK for a user I s teletype ~ It is poss ible, however, for the address to contain a time count, in the case where the activation condition is that a certain amount of time should elapse. It is also possible for the address to hold a mask indicating which program interrupt has occurred. The following activation. conditions are possible: o Word greater than 0 1 Word lesl than or equal to 0 2 Word greater than or equal to 0 3 Word les8 than or equal to teletype early warning 4 Special test. The address points to a special activation test routine. 5 Interrupt occurred. The address contains the number of the interrupt which occurred. 2-4 (') "-/ 7 Special: address 0 dead 1 running BRS 31 BRsl06 executive BRS BRS 109 2 = 3 4 5 11 12 An Bit 1 of word i8 1 (buffer ready) Word less than zero executive program can dismiss itself explicitly by putting a queue number (0 to 3) in X and a dismissal condition in B and executing BRS 72. The address of a dismissal condition must be absolute. There is normally one running program in the system, i. e., a program which c) is executing instructions, or will be executing instructions after the currently pending interrupts have been processed. An active program (1.e. a PACT entry) which is not running is said to be dismissed, and is kept track of in one of two ways. 1) If it has dismissed itself with BRS 31, 106 or 109 (cf. section 5) it is said to be in limbo and is pointed to only by the PFORK, PDOWN, and PPAR of the neighboring programs in the fork structure. 2) If it has been dismissed for any other reason, it is on one of the scheduler queues. QTI QIO QSQ QQE There are four queues of dismissed programs. programs programs programs programs dismissed dismissed dismissed dismissed for for for for In order, they are: teletype input/output other I/O exceeding their short quanta exceeding their quanta. Programs within the queue. are chained together in PNEXT, and PNEXT for the last program in each queue points to the beginning of the next queue. Whenever it is time to activate a new program, the old program is put on The scheduler then begins at QTI and scans through the queue structure looking for a program whose activation the end of the appropriate queue. condition is satisfied. ---------- When one is found, it is removed from the queue structure and turned over to the swapper to be read in and run. are no programs which can be activated the scheduler simp~ If there continues scanning the queue structure. Programs reactivated for various reasons having to do with forks (interrupts, rubbuts, panics) are put onto QIO with an immediate activation condition. They therefore take priority over all programs dismissed for quantum overflow. There is a permanent entry on the teletype queue for an entity called the phantom user. The activation condition for this entry is a type 4 condition which tests for two possibilities: a) the cell PUCTR is non-zero b)three seconds have elapsed Since the last activation of the phantom user for this condition. When the phantom user is activated by (b), it runs around the system checking that everything is functioning properly. In particular, it checks that the W-buffer has not been waiting for an interrupt for an unusual length of time, and that all teletype output is~eeding normally. Details of this procedure are described in sections 9 and 7. If the phantom user is activated by (a), it runs down the phantom user queue looking for things to do. A phantom user queue entry is drawn on page 2B; it is essentially a very abbreviated PAC table entry. Such an entry is made when the' system has 80me activity which it wants to carry out more or less independ.ently of any user PAC table entry: test.. for tape ready (on rewind) and card reader ready, and processing of rubouts (an interrupt routine kind of activity, but too time-consuming). activation condition. user queue. ~~~--~--- The second word ot' ttle entry is the PUCTR contains the number of entries on the phantom 2B C) Pointer to next entry p ~ test number 9 p 23 routine address 11 12 PACPl'R for user parameter for routine CJ Phantom user queue entry 23 3-1 c) 3.0 Forks and Jobs 3.1 Creation of Forks A program may create new, dependent, entries in the PAC table by executing BRS 9. This ERS takes its argument in the A register, which contains the address of a panic table, a 7-word table with the following format: Program counter A re~ister B register X register First relabeling register Second relabeling register Status. The statuI word may be: -2 dismisse.d for input-output -1 running t',', o di.missed on·rubout or BRS 10 1 dismissed on illegal instruction panic 2 dismissed on memory panic The panic table address must not be the same for two forks of the same program, or overlap 'a page boundary. If it is, BRS 9 :Ls illegal. The first 7 bits of the A regiate. have the following significance: c) o make fork executive if current program is executive 1 set fork relabeling from panic table. relabeling 2 propagate rubout assignment to fork (see ERS 90) 3 make tork fixed memory. It is not allowed to obtain a.ny more memory than it j.B started with. Otherwise use current 3A l. - UP 0 2 DOWN i'" ~ ACROSS 0 2. 1 .... 4'rI- 1 5· ... 3 0 6 4 5 0 t L t.... ,- C) ~ 3· 2 - .J 1 7. r-' 2 0 n 'r 0 6. f- '( 5 I- " ('" 10 0 lL 8. 1 I- 0 't. 10. /' t> -0 i'"' 9· .. ~- 6 0 1- 0 9 '--- "- Hierarchy of Processes 0 l- I· 3-2 4. 5· 6. make fork local memory. New memory will be assigned to it independently of the controlling fork. make fork ephemeral memory. Memory that it acquires will be released when the fork terminates. set interrupt mask from seventh word of panic table. When BRS 9 is executed, a new entry in the PAC table is created. This new program is said to be a fork of the program creating it, which is called the controlling program. The fork is said to be lower in the hierarchy of forks than the controlling program. The latter may itself be a fork of some still higher program. The A, B and X registers for the fork are set up from the current contents of the panic table. The address at which execution of the fork is to be started is also taken from the panic .table. The relabeling registers are set up either fram the current contents of the panic table or from the relabeling registers. of the currently running program. An executive program may change the relabeling as it pleases. A user program is restricted to changing relabeling in the manner permitted by The status word is set to -1 by BRS 9. The fork structure is kept tract of by pointers in PACT. For each program PFORK points to the controlling fork, PDOWN to one of the subsidiary forks, and PPAR to a fork on the same level. All the subsidiary forks of a Single fork are chained in a list. A complex situation is shown on the previous page. The arrows indicate the various pointers. The program executing a BRS 9 continues execution after the instruction. The fork established by the BRS 9 begins execution at the location specified in the panic table and continues independently until it is terminated by a panic as described below. It is connected to its controlling program in the following three ways: 1) The controlling program may examine its state and control its operation with the following six instructions: ERS C) 44. 3-3 BRS 30. reads the current status of a subsidiary fork into the panic table. It does not influence the operation of the fork in any way. BRS 31 causes the controlling program to be dismissed until the subsidiary fork causes a panic. When it does, the controlling program is reactivated at the instruction following the BRS 31, and the panic table contains the status of the fork on its dismissal. The status is also II/ put into X. BRS 32 causes a subsidiary fork to be unconditionally terminated and its status to be read into the panic table. All of these instructions require the panic table address of the fork in A. They are illegal if this address i8 not that of a panic table for some fork. BRS 31 and BRS 32 return the status word in the X register, as well as leaving it in the panic table. This makes it convenient to do an indexed .j"rnnp with the contents of the status word. BRS 31 returns the panic table address in A. BRS106 causes the controlling program to be dismissed until any subsidiary fork causes a panic. When it does, the controlling program is reactivated at the follOWing instruction with the panic table address in A, and the panic table contains the status of the fork at its dismissal. BRS 107 causes BRS 30 to be executed for all subsidiary forkS. BRSloB causes BRS 32 to be executed for all subsidiary forks. 3-4 2) If interrupt 3i8 armed in the controlling fork, the termination of any subsidiary fork will cause that interrupt to occur. takes precedence over a BRS 31. The interrupt If the interrupt occurs and control is returned to a BRS 31 after processing the interrupt, the fork will be dismissed until the subsidiary fork specified by the restored (A) terminates. 3) The fork. can share memory. The creating fork can, as already indicated, set the memory of the subsidiary fork when the latter is started. In addition, there is some interaction when the subsidiary fork attempts to acquire memory. 3.2 Memo;rAoluis1t1Gn If the fork addresses a block of memory which is not assigned to it, the following action is taken: a check is made to determine whether the machine size specified by the user (cf. Document R-22) has been exceeded. memory panic (see below) is generated. panic is also generated. If the fork is fixed memory, a memory Otherwise a new block is assigned to the fork so that the illegal address becomes legal. block is always asSigned. It so, a For a local memory fork, a new Otherwise, the following algorithm is used. The number, n, of the relabeling byte for the block addressed by the instruction causing the memory trap is determined. A scan is made upwards through the fork structure to (and including) the first local memory fork. If all the fOrks encountered during this scan have Rn (the Nth relabeling byte) equal to 0, a new entry 1s created in PMT for a new block of user memory. The address of this entry is put into Rn for all the forks encountered during the scan. 3-5 C) If a fork with non-zero Rn is encountered, its Rn is propagated downward to all the forks between it and the fork causing the trap. If any fixed memory fork is encountered before a non-zero Rn is found, a memory panic occurs. This arrangement permits a fork to be started with less memory than its controlling fork in order to minimize the amount of drum swapping required during its execution. If the fork later proves to require more memory, it can be reasSigned the memory of the controlling fork in a na.tural way. It is, of course, po as ible to use this machinery in other ways, for instance to permit the user to acquire more than 16K of memory, and to run different forks with non-overlapping or almost non-overlapping memory. 3.3 Panic Conditions The three kinds of panic condition which may cause a fork to be terminated are listed in the description of the status word above. When any of these conditions occurs, the PACT entry for the fork being terminated is returned to the free program list. in the controlling fork. it too is terminated. The status of the fork is read into1ts panic table If the fork being terminated has a subsidiary fork, This process will of course cause the termination of all the lower forks in the hierarchy. The panic which returns a status word of zero is called a program paniC and may be caused by either of two conditions: A) the ruboutbutton on the controlling teletype is pushed. terminates some fork with a program panic. This A fork may declare that it is 3-6 C) the one to be terminated by executing BRS 90. In the absence of such a declaration the highest user fork is terminated. !, When a fork is terminated J in this way its controlling fork becomes the,one to be terminated. If a user fork is tenninated by rubout the telepype input buffer is cleared. If the controlling fork of the one terminated is executive, the output buffer is also cleared. If the fork which should be tenninated by rubout has armed interrupt 1, this interrupt will occur instead of a termination. not be affected. If there is only one fork active, control goes to the location EXECP in the executive. user. This consideration is of no concern to the Executive programs can turn the rubout button off with BRS 46 and turn i t back on with BRS 47. A rubout occurring in the meantime will be stacked. A second one will be ignored. () The teletype buffers will A program which is running with rub out turned off BRS 26 is said to be non-terminable and cannot be terminated by a higher fork. skips if there is a rub out pending. If two rubouts occur within about .12 seconds, the entire fork structure will be cleared and the job left executing the top level executive fork. This device permits a user trapped in a malfunctioning lower tork to escape. Closely spaced rubouts can be conveniently generated with the repeat button on the teletype. B) A BRS 10 may be executed in the lower fork. This condition can be distinguished from a panic caused by the rubout button only by the fact that in the fonner case the program counter in the paniC table points to a word containing BRS 10. As an extension of this machinery, there is one way in which several forks may be terminated at once by a lower fork. provides a count in the A register. C) This may be done by BRS 73, which A scan is made upward through the fork structure, decrementing this count by one each time a fork is passed. the count goes to 0, the scan is terminated and all forks passed by are When 3-7 c) terminated. If an executive program is reached before the count is 0, then all the user programs below it are terminated. An executive program can clear the fork structure of a job by putting the job number in A and executing BRS 22. The effect is as though enough rubouts had occurred to send the job back to the top-level executive fork. The panic which returns a status word of 1 is caused by the execution of an illegal instruction in the fork. Illegal instructions are of two kinds: 1) N8chine instructions which are privileged 2) SYSPOPs which are forbidden to the user or which have been provided with unacceptable arguments. It interrupt 2 is armed and the fork is executive, interrupt 2 will occur inltead of an illegal instruction panic. A status word of 2 is returned by a memory panic. This may be caused by an attempt to address more memory than is permitted by the machine size which the user has set, or by an attempt to store into a read-only block. If interrupt 2 is armed, it will occur instead of the memory panic. Every complete fork structure is associated with a job, which is the fundamental entity thought of as a user o'f the system, from the syatem' s own point of view. The job number appears in the PAC table entry for every fork in the job's fork structure. In addition there are .everal tables indexed b:r job number. These are shown on pace 3B, and indicate more or less what it is that is specifically associated with each job. 3B c) TSDA drum address of TS block TTNO teletype associated with this job ETTB amount of CPU time used DBA drum blocks available QUR time left in long quantum Job Tables 4-1 4.0 ProFam Inte~t. Atacility i8 provided in the monitor to simUlate the exi.tence of hardware interrupts • There are 20 pos.ible interrupts; four are reserved, for special purposes and 16 are available to the programmer tor general use. A fork may arm the interrupts by exeouting BRS 78 with a 20-bit mask in the A register. Thi. causes the appropriate bits in PIN to be set or cleared according to whether the oorreapond.ing bit in the mask i. 1 or O. Bit 4 of A oorreapond.l to 'interrupt number 1, eto. No other action is talten at this time. When an interrupt occurs (in a Dlanner to be de.cribed) the execution of an SBBM* to location 200 plus the interrupt number il s~ulated in the torkwhich armed the interrupt. Note that the program counter which ia stored in the case is the looation ot the instruction being exeouted bY' the fork which is interrupted, not the location in the fork which causes the interrupt. . The proper return from an interrupt is a BRU to the location from which the interrupt occurred. This will do the risbt thing in allcal.a including interrupts out of inputoutput instruction•• A fork may generate en interrupt by executing BRS 79 with the num.ber ot the desired interrupt· in the A register. .This number may not be one, two, three or four. The effect is that the fork structure is scanned, starting with the forks parallel to the one causing the interrupt and proceeding to those above it in the hierarchy (1.e., to its ancestors). The first fork encountered during this scan with the appropriate interrupt mask bit set is interrupted. Execution of the program in the fork causing the interrupt continues without disturbance. If no interruptable fork is found, the interrupt instruction is treated as a lOP. otherwise, it skips on return. Interrupts 1 and 2 are handled in a special way. It a fork aru interrupt 1, a program panic (BRS 10 or rubout button) which would norma.ll.;v' terminate the fork which bas armed interrupt 1, will inatead cause interrupt 1 to occur, that is 1 will cause 4-2 C) C) the execution of an SBRM* to location 201. This pe~its the programmer to control the action taken when the rubout button is pushed without establishing a fork specifically for this purpose. If pushing the rubout button causes an interrupt to occur rather than te~inating a fork, the input buffer will not be cleared. If a memory panic occurs in a fork which has armed interrupt 2, it will cause interrupt 2 to occur rather than terminating the fork •.. If an illegal instruction panic occurs in an executive fork which has armed interrupt 2, it will cause interrupt 2 to occur rather than terminating the fork. Interrupt 3 is caused, if armed, when any subsidiary fork te~inates. Interrupt 4 is caused, if armed, when any inputoutput condition occurs which sets a flag bit (end of record, end of file and error conditions can do this). Whenever any interrupt occurs, the corresponding bit in the interrupt mask is cleared and must be reset explicitly if it is deSired to keep the interrupt on. Note that there is no restriction on the number of forks which may have an interrupt on. To read the interrupt mask into A, the program may execute BRS o 49. c) 5-1 5.0 The Swapper and Memory Allocation Pseudo-relabelins The 940 hardware allows the user's address space to be fragmented into eight pages of 2048 words each. This means that the monitor must keep track of eight drum addresses for each process. This is done by means of eight six-bit pseudorelabeling registers. Each of these registers is an index to a table which contains the drum address of the user's page. This table is called the Private Memory Table (:R4T) and is held in the job's TS block. Each of the 64 entries in PMT has the following format: H:i~ I~ I~ [ ~ EX RO SH EP o - 1 2 3 4 drum address I pI 17 23 Process must be executive to reterence the page. Read only (attempt to store will generate a trap). Shared. Will be destroyed when DOt in any map. During the startup for each user, the system copies the first NCMEM (currently 35) entries out of a resident table called the Shared Memory Table (00) into the new IMT. These entries describe memory that most processes will need, such as the monitor, the exec, and some of the subsystems. Thus, a program has a maximum of (64 - BCMEM) private pages. When a program is run, his TS blook is swapped and its pseudo-relabeling registers (in the PACT table) are used to read out the proper bytes from FMT and construct a list of drum pages that may need to be read from drum. When this list has been constructed, the current state of core is examined to determine Whether any blocks need to be written out to make roam for these which must be read 1u. If so, a list of blocks to be written out is constructed. The drum command list is then 5-2 o o set up with the appropriate commands to write out and read in the necessary blocks. In the course of optimizing the drum commands, the swapper may skip a sector. If this is the case, it searches through the memory tables and writes out a dirty page in that sector. The scheduler then simply hangs up until the swapping is complete. In the scan which sets up the drum read commands, the swapper collects from DHT the actual absolute memory addresses of the page called for by the pseudorelabeling and constructs a let of real relabeling registers which it puts in two fixed locations in the monitor. It then outputs these relabeling registers to the hardware and activates the program. There are two BRS' s which permit the user to read and write his pseudo-relabeling. BRS 43 reads the current pseudorelabeling registers into A and B. BRS 44 takes the contents of A and B and puts them into the current pseudo-relabeling registers. An executive program may set the relabeling registers in arbitrary :t'uhion by using this instruction. A user program, however, may add or delete only blocks which do not have the executive bit let in PMT. This prevents the user from gaining access to executive blocks whose destruction may cause damage to the system. Note that the user is doubly restricted in his access to real memory, firstly, because he can only access real memory which is pointed to by his pseudo-relabeling, and secondly, because he is only allowed to adjust those portions of his pseudorelabeling which are not executive type. The user can also set the relabeling of a fork when he creates it. See Section 3. The same restrictions on manipulation of .executive blocks of course apply. The system maintains a pair of relabeling registers which the executive and various subsystems think of as the user's program relabeling. For the convenience of subsystems, any program can read these registers with BRS 116 and set them with BRS 117. 5-3 o TPe memory allocation algorithm is described on page 3-2. A user can release a block which is in his current relabeling by putting any address in that block into A and executing BRS 4. The PMT entry for the block is removed and in any other fork which has this PMT byte in its relabeling, the byte 1s cleared to O. Equivalent to BRS 4 is BRS 121, which takes a pseudorelabeling byte in A rather than an address. An inverse operation is BRS 120, which takes a pseudo-relabeling byte in A, generates an illegal instruction trap if the corresponding PMT entry is occupied, and otherwise obtains a new page and puts it in that entry. This is an exec-only operation and is implemented particularly for the Exec 'RECOVER FROM FILE' operation. If A is 0, BRS 120 aSSigns a2K page and skips; this operation is not execonly. Shared Memorl. The system maintains a table called the shared memorl table (SMT) which describes all the memory which can be shared between jobs in the system. All the common subsystems occupy pOSitions in SMT, and lome part of SMT is copied into . each job's rtrl' permanently. To run a subsystem, the exec must determine if the subsystem map is already in PMT (whioh it will be if all. the bytes are below NCMEM) and, if not, arrange for the bytes to be put into M. The exec makes an entry in SMT by executing BRS 68 with a byte number in A. The block addressed by the specified byte in the pseudo-relabeling registers is put into SMT and the pointer in SMT of this byte is returned. By putting an index in SMT in A and executing BRS 69, the SMT entry is copied into the first free b~e of·a user's P.MT and the byte number is returned in A. The read-only bit in the SMT entry is propagated to the P.MT entry thus created. To delete an entry in SMT, the exec may deliver its index in A and execute BRS 70. The user may declare a block read-only by executing BRS 80 with the pseudo-relabeling byte number of the block in A and with bit 0 of A set. To make a block read-write, bit 0 of A 5-4 () C) should be clear. Bit 0 of A will be reset if the block was formerly read-write or set if it was formerly read-only. If the program doing this is not an executive program, then the block must not be an executive block. Only executive programs may make a shared page read-write. The drum is divided into 84 bands, each containing 16,000 words arranged in 8 blocks of 2K each. Up to 72 of these bands may be used by the swapper for program storage. A bit table is maintained to indicate the availability of 2K blocks in these bands. The table consists of 8 words, each containing 24 bits, one for each band. If a bit is zero, it indicates that the block is in use. If:1,t is set, the block is available. When the user's memory is acquired, it is written as nearly as possible '. in adjacent blocks, so that it may be read in without undue drum latency time. Rotational positions are chosen by adding, mod 8, the user's job number to the !MT byte number of the new block. It should be noted that whenever a user is activated, all of the memory in his current relabeling registers is brought in. The user does, however, have considerable control over precisely what memory will be brought in, because he can read and set his own relabeling registers. He may therefore establish a fork with a minimal amount of memory in order to speed up the swapping process if this is convenient. To· make a block executive, execute BRS 56 with the same argument as for BRS 80, malte block read-only. This instruction is legal only for executive type programs. Real memory is housekept by means of several tables. The most important of these is a table (hash)-indexed by drum address which describes all those drum pages which are currently in core. The Drum. Hash Table (DHT) has more entries than core pages. An entry has the following format: -- Drum Address Core Address l8 F :: Free entry 27 5-' ---\ C) The core addre~s field of' DHTindexes two tables called the real memory table (RMT) 8.I1d the real memory use count table (RMe). An RMC e~tr,y is -1 if a page is not in use; otherwise, it is one less than the number of' reasons why it is in use. Every occurrence of the page in the relabeling of a process which is running or about to be run counts as such .a reason. In addition, other parts of the system can increment an RMC word to lock a block in core. No block with non-negat4~ RMC will be used by the swapper. The f'ormat of an RMT entry (one per real page) is , 4 5 6 2 0 ~ D E I R 0 ;~" 9 :LO R R W R fJ 23 address of DHT entry responsible ! T I I y P P T RIP - drum r.ead in progress DIRTY - .Page has been modified WIP - drum write in progress ERRBIT - drum read error There i8 one more table indexed by real memory, called the , real memory aging table. Whenever the swapper is entered, every word in this table is shifted right one bit. All blocks which show up in the real relabeling computed fran the pseudo-relabeling with which the swapper was entered tben have bit 1 turned on. Tbeblocks with lowest RNA are sel.~4 for swapping out; of coune, the1r 111.: eV't" .... . . lJtO Ie. . ~.tIe . . . . . . a ....'U.,. _ be . . . .1". • real. •• "'7 tables aDd tor each ..... ot . . .tlou: It tb.e paae il not d1rty, the EMT/SMr entry is marked as on drum and RMT is emptied. . If the page is dirty, a write is started. This has the affect of forcing core and d.ruJrl copies of most pages to correspond. 6..1 6.0 Miscellaneous Features A user may dismiss his program for a specified length of real time by executing BRB 81 with the number of milliseconds for which he wishes to be dismissed in A. At the f'irst available opportunity atter this. time has been exhausted, his program Will be reactivated. This feature is 1m;plemented with a special activation condition and the value of the clock at the time when a user is to be reactivated is kept in PA. The activation condition causes the current value of the clock to be compared with this value. When the clock. becomes greater, it is time to reactivate the program. He can read the real-time clock into A by executing BRB 42. The number obtained increments by one every 1/6oth of' a second. c) Its absolute magnitude is not significant. He can read the elapsed time counter in A by- executing BRB 88. This number is set to 0 When he enterl the system and increments by 1 at every 1/6othsecond clock interrupt at Which his program is running •. To obtain the· data and time, be can execute BRB 39. This puts six 8-bit character.s into AB •. TheBe ohara.oters conta.in, in order, the year, month, day, hOUJ! (0.. 23), minute and second at which the instruction is executed. A user may dismiss his program until an interrupt occurs or the fork in question i8 terminated by executing BRS 109. A program can test whether it is executive or not byexecuting BRS 71, Which skips in .the f'ormer case. An executive program can dismiss itself' explicitly. See Section 2. There are sOlle operations designed for so-called executive BRBs, which operate in user mode with a map different from the one they are called trom. BRS lllreturna from one of these . . BRSs, tranlm.1tt1ng A, B and X to the calling program as it finds them. BRS 122 simulates the addressing of memory- at the location spec ilied in .It.. If new memory- is ass igned, it is put into the I I I ·1 6.. 2 c) relabeling of the calling program. A memory panic can occur, in which case it appears to the calling program that it comes from the BRS instruction. BRS 141 reads the panic table of the caller, and BRS 142 sets the state from a table specified iy X. An executive program can cause an instruction to be executed in system mode by addressing it with EXS. C) I 7-1 1.0 Teletzpe C) Xsgut~Output We begin with an outline ot the implementation of the teletype operations. This may serve to clarify the exact disposal of the oharacters whiob are beiq read and written. Every teletype bas attaohed to it a table which i8 shown in Figures 7A and 7B,' No bufter. are attached to the teletype unless input trom. Or output to the teletype is taking place. As characters are output by the program.~ buffers are attaohed to the teletype •. These buffers are released as soon as they are emptied by the teletype intertace. On input butfers are attaohed to the teletype as characters are received trom the teletype, and they are released &SIOon as the program empties them. Input and output bufters are logically and physioally independeo.t, although they come out of the same buffer pool. When a oharaoter i8 typed in on a teletype, it is oonverted to internal torm and added to the input buffer unless it is rubout on a controlling teletype. The treatment of rubouts i8 d1.oussed in Seot10n 3. The echo routine address is then . obtained trom TTYTBL and Called. It figure. out what to echo and whether or not the oharacter is .. break character. The ava1lable choices ot echosand break characters are listed below. If the oharacter i8 a break character I and i f a user's program haa been d1am1lsed for teletype input, it will be reactivated regardless of the number of words in the input buffer. In the absence of a break oharacter, the user's program. is reactivated only when the input buffer is nearly full. If tbeteletype is in the process of outputting (TOB2 > -1) then the character to be echoed i8 put into the last byte of the butter word which contains the input character. When the charact.lr 11 read trom the bufter by the program~ the echo, if &Q1, will be seneratld. Thi. mechanism, called deferred echo;ns, perm1ts the uaer to type in while the teletype i8 outputting without having hi8 input mixed with the teletype output. o o 7-2 There are four standard echo routines in the system, referred to by the numbers 0, 1, 2 and 3. 0 is a routine in which the echo for each character is the character itself, and all characters are break characters. Routine 1 has the same echoes, but all characters except letters, digits, and space are break characters. Routine 2 again has the same echoes, but the only break characters are control characters (including carriage return and line feed). Routine 3 specifies no echo for any character, and all characters are break characters. This routine is useful for a program which wishes to compute the echo itself. To set the echo routine, put the teletype number in X and the echo routine number in A and execute BRS 12. Note that BRS 12 is also used to turn on 8-level mode (see below). To read the echo routine number into A, put the teletype number in X and execute BRS 40. This operation returns in A the word listed as TTYTBL on page 7A. To input a character from the controlling teletype (the teletype on which the user of the program is entered) into location M in memory the SYSPOP M (teletype character input) i8 used. This SYSPOP reads the character from the teletype input butfer and places it into the 8 rightmost bits of location M. The remainder of location M is cleared. The character is also placed in the A register, whose former contents are destroyed. The contents of the other internal registers are preserved by this and all the other teletype SYSPOPs and BRS's. To output a character from location M, the SYSPOP TOO M (teletype ~haracter output) is used. This instruction outputs a character from the rightmost 8 bits of location M. In addition to the ordinary ASCII characters, o 7-3 all teletype output operations will accept 135 (octal) as a multiple blan.k character. The next character will be taken al a blank count, and that many blanks will be typed. The TTlTlM cell in the teletype table is let to the current value of the clock whenever any teletype a.ctivity (interrupt or output SYSPOP) occurs. The top bit is left clear unless the activity i. a rubout input. This cell is checked by the rubout processor to determine whether the rubout should reset the job to tbe exec. See p. 3-6. Every teletype in the system is at all times in one of three Itates:. a) It may be the controlling teletype of some user's program. It sets into this state when e. user enters on it. b) It may be attached to some user in a. manner about to be . described. c ) It may be canplete ly free. The Itatus of the teletype is reflected by the contents of' TTYASG. There are mech&Dilm. to be described by which the user may direct outpUt to any teletype in the system which is willing to accept it and receive input fran any teletype which is not free. If', however, be wishes to have better control over a teletype (for instance, to prevent other users from accessing it) he may attach it by executing the instructions LDA =teletype number BRS 'i!7 If the indicated teletype is free, it is attached to the user whoae program executes the instruction, and the BRS will skip. otherwise the teletype status is not affected, and the BRS does not SkiP.' In the following discussion we will lay that a teletype ia attached to a ulereven if it is the controlling teletype. To release an already attached teletype, execute the instructions L'DA C) BRS =teletype number 28 If the specified teletype is not already attached to the user, this is an illegal instruction and causes a panic. All attached teletypes are, of course, released when the user logs out. 7-4 c) C) C) A teletype becames a controlling teletype if it ,is dormant and rubout is pushed on it. It can be returned to its dormant state by BRS 112, which takes the job number of the job associated with the teletype in X. A job may terminate itself. This operation also releases all teletypes attached to the job. The user may specify tor his controlling teletype or for one which he has attached, whether or not messages from outside will be accepted, and whether or not input from outside will be accepted. The former condition 1s governed by the accept measages bit, ,the latter by the accept input bit. The accept message bit controls execution ot OST instructions and the setting ot teletype output ltDkl. The accept input bit controls e~ecution of STl instructions and the setting of teletype input links. To set these bits, the user may execute LOA -teletype number LOA Br.rS BRB ~ The last bit ot Br.rS will set the accept input bit, the next to last the accept messages bit. Setting or clearing these bits will not aftect any teletype ltDks currently' active. To do input and output to specified teletypes (rather than implicitly' to a controll1nc teletype as in Tel and TeO) the SYSPOPs IST and OST are available. To input a character trom a specitied teletype, execute the instruction lST -teletype number (input from specified teletype) which brings the character into the A register. ' This instruction is illegal unless the teletype is attached to the user. To output a character to a specitied teletype, execute the instructions LOA -character OST -teletype number (output to specified teletype) This instruction is illegal it the tollowing three conditionl are sati.tied: (1) The .pecified teletype is not attached to the user, (2) The specitied teletype does not have itl acoept meslages bit let, (3) The program executing an in.truction is a user rather than an executive program. If these condition. are 7-5 satistied, an illegal instruction panic will be generated. liote that attached teletypes do not have the same statu. as the controlling teletype for a user. In particular, pushing the rubout button on an attached teletype Will have no effect. The instruction om -teletype number + 1000 is exactly equivalent to IST The instruction om c =teletype number. -teletype number + 2000 18 exactly equivalent to OST =teletype number. This mechanism permits the user to do I/O to specified teletypes within the framework of the sequential file machinery. The user has con.iderable control over the state of the teletype buffers for the teletypes attached to h:lm. In particular, he may execute the following BRS' s. All the.e talte the teletype number in X. Recall that -1 may be used tor the controlling teletype. BRa 11 clears the teletype input butter. BRS 29 clears the teletype output butter. BRS 13 skips it the teletype input butter i8 empty. BRS 14 waits until the teletype output bufter il emptyBRS ·138 waits until a process gets dismis.ed because the input bufter 1s empty. , There 18 one additional piece of machinery which permits output to go to a teletype other than the controlling teletype. This machinery i. implied by the top bit. of TTYTBL, which specify whether any link bits are .et. Associated with each teletype are two words called the absolute input link control word (LeW) and the absolute output LOW. Each of theae words contain. one bit for each teletype in the system. If the bit tor teletype m il Bet in the input LeW for teletypen, .very character which goes into n's input bufter will also go into m'. input buffer. If' the bit i8 set in the output row, every character which i8 output to n, including echoes, will also be output to m. 7-6 Allo assooiated With each teletype are relative LCW's tor input and output. The bitl inth••e LCW'I are set by BRS 23. Each time any relative ICW is changed , the absolute LOW's are all recomputed. The Boolean matrix formed by 'the absolute input (output) ICW's 1s the infinite product of the matrix of the relative input (output) LCW til. The instructions LUX =teletype number LDA -TABLE LDB CTL 23 will let ODe ot the relative LOW' ••or the indicated teletype. TABLE is the address ot a list of teletype numbers terminated with -2. The bits ot CTL are interpreted as follows: O o - o u t p u t LCW l=input ICW o-clear all linkl first 1 1-40 not clear 11nk.1 first o-set link bits for teletypes WhOle numbers 2 are in the table. l=clear link bit. for teletypes whoae numbers are in the table. Fran the old relative LeW and the information supplied by BRS 23 a new relative LeW i. created. New absolute LOW'.s tor aU teletypes are then computed. An output link can be set up between two teletypes only it each of the teletypes satiafies at least one of the following BRS conditions: . a) It i. the controlling teletype of the program executing C··) ./ b) c) d) An input BRS 23 It i. attached to the program It. accept ..slage8 bit il on (destination only) The fork executing the BRS is executive. link can be set only if the same conditions are satisfied for the accept input bit . 7-7 To clear all links, input and output, to or from a teletype, execute LDX BRS =teletype number 24 Special provision is made for reading 8-bit codes from the teletype without sensing rubout or doing the conversion trom ASCII to internal Which is done by Tel. To switch a teletype into this mode, execute LDX LDA BRS =teletype number =terminal character + 40000000B .12 This will cause each 8-bit character read trom the teletype to be transmitted unchanged to the user's program. The teletype can be returned to normal operation by 1. Reading the terminal character specified in A, or 2. Setting the echo table with BRS 12. No echoes are generated while the teletype is in 8-level mode. Teletype output is not affected. A parallel operation, BRS 85, is provided for 8-level output. BRS 86 returns matters to the normal state, as does any setting of the echo table. To s~late teletype input, the operation STI =teletype number is available. STI puts the character in A into the input buffer of the specified teletype. It is legal if the accept input bit C) is on. To steal teletype output, the operation aTO =teletype number takes a character from the teletype's output buffer and returns it in A. STO is legal only if the accept input bit is on. To disable output from a buffer to a teletype, execute BRS 139 with the teletYl*- number in X. H bit ¢ <>f A is 1, the NO bit will be set; otherwise, the NO bit will be cleared. 7A C) TELETYPE SYSTEM POINTERS, TTYOB TTYOBC Pointer to next available buffer in buffer pool Count of a'V"ailable buffers in buffer pool N N A S 0 P TTYTBL TTYBRK S S I I 0 0 L L 10 A A A K I M address of echo routine 23 Waiting for break character when -1 TTY Status PACPTR TTYASG of fork to terminate on rubout 3 7 7 o 7 active inactive "( Iltl controlling job 23 attached ROLCW RIICW TTYTlM TTYDEV Relative output link control word Relative input link. control word R B value of clock when last action occurred on this tty device (normally physi,cal teletype) using this buffer, NS = not linked or 8-level AM = accept message IL = input linked Ot = output linked NO :: don't output to TTY interface AK :: accept input links AI = accept input SI = 8-level input SO = 8-level output RB ~ last action was input of rubout AP :" accept .output links 7B C) TELETYPE TABLE TIS2 TIS4 number of characters in input buffer next available space in input buffer (pointer) 7 I 8 10 I 23 WORD ADDRESS bits 7 and 8: TIS5 TIS6 C) TIBBl TIBB2 TIBLC TOS2 TOS3 TOs4 TOff) Tos6 TOBBl 0 TOBB2 TOBLC TTYPN TTYLN o 1 1 o 1 1 byte 1 byte 2 byte 3 next filled space in input buffer (pointer With same format as TIS4) deferred echo byte count. Input characters are echoed when the NO bit is set in TTYTBL and this count goes negative. It is decremented when a character is taken out of the input buffer. word pointer to the oldest acquired input buffer: =0 no buffer attached word pointer to the last acquired input buffer count of input buffer that can be acquired number of characters in output buffer: -1 = inactive < 0 .. not u1 multiple blank mode; 400 = just saw 135 (multiple blank character); other = number of blanks next filled space in output buffer (pointer same as TIS4) next available space in output buffer (pointer same as TIS4) < 0 • not terminated during output to links; ~ 0 = next link that output has to be sent to. word pointer to oldest acquired output buffer; = 0 no buffer attached word pointer to last acquired output buffer count'of output buffers that can be acquired contains physical teletype number associated with this buffer, or 4B7 if no phySical teletype attached contains logical teletype buffer associated with this physical teletype or zero (¢) if no buffer is attached. 7C C) TELETYPE BUFFERS TTYOC [ 1 ~'I 2 1. 2. 1-----1 3 t------4 N 1------1 BUFFER POOL POINTERS 1 TOBBl C) 1. 2 3 TOBB21 2. ) 3 Tos41 3· lXl= byte count in word N = word displacement in buffer. PROGRAM OUTPUT BUFFER POINTERS lXl 1.+N I TO~ IlXl 3.+N J c) 8-1 ~.o Drum and Buffer Organization; Devices The drum is divided into two major sections, program swapping and file storage. The organization of the program swapping area is discussed in Section 5. The file storage area is divided into 256 word blocks which form the physical records for storage of files. Every file has one or more index blocks which contain pointers to the data blocks for the file. An index block is a 256 word block, as are all other physical blocks in the file area. Only the first 141 words of the index block are used, however, for data storage. A couple of additional words are used to chain the index blocks for any particular file, both forward and backward. The index blocks for a file contain the addresses for all the physical blocks used to hold information for the file. Available storage in the file area of the drum is kept track of with a bit table similar to the table used to keep track of program swapping storage. Since there are sixty-four 256-word blocks around the circumference of the drum and a maximum of 72 drum bands {out of the 84 available} may be used for file storage, a 192-word bit table which contains 3 words of 72 bits for each row of physical blocks suffices. If a bit in this table is set, it indicates that the corresponding block on the drum is in use. Again, as with program swapping storage, the organization of this table makes it easy to optimize the writing of files. This is done by putting consecutive physical blocks in the file in alternating rows on the drum. The intervening row between each two phYSical blocks provides the time for the channel to fetch a new coumand and the heads c) to switch. The result of this organization is that information may be transferred from a file on the drum into core at onehalf core memory speed if conditions are right. 8-2 8.2 File Buffers Every open file in the system with the exception of purely character-oriented files such as the teletype has a file buffer associated with it. The form of this buffer is shown on page BA. Part (a) of this figure shows the buffer proper, and part (b) shows the index block buffer and pointers associated with it. Part (b) is not used only by drum files, but is present in all cases. Each job has associated with it a temporary storage block, wllieh is always the first entry in the job's PMT. This block is used to hold information about the user and for the system's temporary storage. It also has room for three buffers. An additional block may be assigned with room for five more buffers if more than three files are open at one time. The pseudo .. relabeling for the extra buffer block and the TS block is held in a table called RL3 which is indexed by job number, and is put into the monitor map whenever any fork belonging to that job is run. Note that the amount of buffer apace actually used is a function of the device attached to the file. In all cales the two pointer words at the, head of the buffer indicate the location of the data. The first word points to the beginning of the relevant data and is incremented as data are read from an input buffer. The second word points to the end of the data on input or end of the buffer on output or written in an output buffer. When the buffer 1s in its dormant state, both words point to the first data word of the buffer. Whenever any physical 1/0 operation i8 completed, the first pointer contains the address of thiS word. B-3 B.3 Devices C) Every different kind of input-output device attached to the system has a device number. The numbers applicable to specific , devices are given in Section 9; here the various tables indexed by device number are described. The entries in these tables addressed by a specific device number together with the unit number (if any) and the buffer address, completely define the file. All this information is kept in the file control block (Section 4.3) which is addressed by the file number •. Page BB shows the tables indexed by device number. Note the multiplicity of bits which specify the characteristics of the device. Some of these call for comment. A device may be common (shared by users, who must not access it s~ultaneously; e.g., tape or cards) or not common (e.g., drum); this characteristic is defined by NC. It may have units; e.g., there may be multiple magtapes. The U bit specifies this. The DIU word indicates which file i. currently monopolizing the device; in the case of a device with multiple units, DIU pOints to a table called ADIU which contains one word for each unit. The major parameters of a device are: - the opening routine, which is responsible for the operation nec,e·ssary to attach it to a file. - the GPW routine, which performs character and word I/O. - the BIO routine, which performs block I/O. Minor parameters are: - physical record size (determining the proper setting of buffer pointers and interlace control words for the channel). - the expected time for an operation; the swapper u.es this number to decide whether it 18 worthwhile to swap the user out while it is taking place. C) 8A Ci pOinter to first data word in buffer pointer to last data word I""" 1st data word · ·· ·· ~ · - 256th data word a) layout of a file buffer () ¢ drum address of data block, or · ··· · ··· · · t drum o address of data block, or ¢ BFP pointer to next index block BBP pointer to previous index block BDS log 2 (data block size!256) BLX file length BCK check sum b) format of an index block data block o (\ (\ () :i)EV'tlord or character I/O @ ]. ! 2 0 f 3 4 5 CHI nru.f IRX I~ 6 ~ \~ I~ I BUFS buffer size B 9 RX random access BF requires buffer max. unit number 1U I WB r 9 ~ f output : physical. record size ~ I ~ 23 W buff'er OUT BC not common (i.e. don't set DIU) () bl.ock I/O routine GP\'f routine BF U check unit number BDEV l.~ I IW1l1our I~ I CH char oriented DRM drum routine 7 J ~ BIO routine I ¢ DIU device in use 1 OPrIDEV opening routine 0 \0 2 I~ f'il.e number using this device or -1 u=o points to ADID (has unit number added) U=1 3 expected wait tiffie Lll cl.ock cycles EO 23 ~ 0 opening subroutine exec only allowed to open DEVICE INDEXED TABLES fB ) ,~-.- ..-----"""------- ----"""------""""" ----- --- 9-1 2.0 Se~uential Files 9.1 Sequential Drum Files 1.94 c) includes a major revision to the drum file system. Basically, a file appears as an address space with an arbitrary upper bound called its "length." The maximum possible length is around four million words (22 bits). The file is internally paged into an arbitrary number of data blocks whose size may be any power of two larger than 256 words. The following discussion will be of interest to .those who need to make efficient use of large, randomly accessed files: 1. The data blocks are kept track of by the use of index blocks chained together. Each index block can describe about l4p data blocks. Random access will be slow if there are several index blocks to chain through. A large data block size will minimize this source of ineffiCiency. 2. Block transfers are implemented in the most efficient manner, with as much as possible of the data requested transferred directly into the userts memory. The slop on either end is buffered in 256... word blocks. Programs cognizant of the structure of their files can avoid all buffering. All word operations use the 256-word buffer. The userts access to an open file is housekept by means of a position pointer to the file. This pointer may be moved explicitly by the user or implicitly by any of the I/O operations. The I/O operations always leave the pointer pointing at the word following the last transfer. CIO is a confUSion factor. When a file is opened, any of three types of access to that file may be given to the user: read, write, or position. Position accel. il intended to implement append-only files. You may not move the pointer or perform random operations unless you have position access to the file. c) c) 9-2 file opened as sequential input sequential output random read-only random read-m'i te access given r p w r p r w p The mechanisms for setting the length, data block lize, or for moving the pointer are described under BRS 143-144. BRS 66 deletes the contents of an open drum file. In the case of a sequential output file, it sets its length to zero. You must have write access to the file to use BRS 66. BRS 67 takes a file number in A and deletes all traoe of the tile~ Use of this BRS is limited to the EXEC. BRS 143 1 144 have been implemented as general .read and set statuI of a thingy. The oalling sequence is; . A: table address or data (depends on ~) If a table address, A is incremented to point to one past the last word transferred. X: thingy number B: decodes as follows bit ¢: ~ if A has data, 1 if A pOints to a table .bits l-ll: "type" of thingy bits 12-23: "attribute" "type" is .1 for a drum. fl1e, 2 for a job. No other thingies have been implemented as yet. For drum. files, the attribute field specifies the following: 1. (Position) One may read or set the sequential I/O pointer. The bottom 22 D.its are the current word pointer, the top two the character offset. (~means a word boundary.) The offset must be ¢ if the pOinter is set. 2. (Length) Reads or sets the length of a file. 3. (Sequential Ilo mode) The sequential Ilo operations (CIO, WIO,BIO) are interpreted as input if the sequential mode 1s ~, output if the mode is 4B7. 9-3 4. C=) (Capabilities) Opening a file may give read/write/position access to the tile. These bits may be read in bits 21-23. It you try to set them, they are ANDed with the existing capabilities. ,. (Data Block Size) Returns n where 2n+8 is the. number ot words in a data block. May be set only if the tile length is p. 6. (User words) Eaoh tile in the system has tive arbitrary word a aaaociated with it. Anyone may read'them but only the exec may set them. 7. ( "structure") A tile may have voids in it. It you are interested, you can find out where theae are. BRS 143 returns the number of worda trom the current sequential pOinter to the next transition. It also moves the pointer. If you are oroa.ins a void part ot the file with this operation, the Sign bit of the number is turned on. Setting thia state with BRS 144 is interpreted by releasing this many warda beyond the pointer. This also move. the pointer. 8. (count data) Can only be read. Sets the pointer to the beginning of the tile. 9. (copy the index block) Can only be read. Give.s a copy ot the entire index block. For jobs (type = 2) BRS 143 and 144 interpret the attribute field thusly: 1. (files) Returns a bit word telling which files are open. This word may not be set. 2. (PMT) Reads the private part of lMT. C) 9-4 The Exec opens a sequential drum file by the following sequence of instructions: LOX LOA BRS C~) =device number, 8 (input) or 9 (output) =unit number, address of first index block 1 If the file is opened successfully, the BRS skips; otherwise, it returns without skipping. Use of this BRS is restricted to executive type programs. User programs may access drum files only throUgh the executive file handling machinery. BRS 1 can also be used to open other kinds of files. The device and unit numbers are used to determine the physical location of the file. See Section 9.2. If BRS 1 fails to skip, it returns in the A register an indication of the reason: -2 too many files open -- no file control blocks or no buffers available. -1 device already in use. For the drum, produced by an attempt to open a file for input if already open for output or for output if already open at all. o no drum space left. This inhibits opening of output files only. See Section 9.2 for other error conditions. BR~ 1 returns in the A register a file number for the file. This file n~er is the handle which the user has on the file. He may use it to close the file when he is done with it by putting it in the A register and executing BRS 2. This severs his connection with the file •. BRS 2 is available only to executive programs, user programs should use BRS 20 instead. To close all, his open files an executive program m~ execute BRS 8. The oorresponding operation for normal user programs is BRS 17. Three kinds of input~output may be done with sequential files. Each of t~ese is specified by one SYSPOP. Each of these SYSPOPs handles input and output indifferently, since the file 9-5 must be specified as an input or an output file when it is opened. It is not possible to have a file open for both input and output at the same time: this may be circumvented by using random :files. To input a single character to the A register or output it from the A register, the instruction CIO C) o =file number is executed~ On input an end-of-record or end-of-file condition will set bits 0 and 8 or 7 in the file number (these are called --------~!1!i~) and return a 134 or 137 character, respectively. If interrupt 4 is armed, it will occur. The end-of-record condition . occurs on the next input operation after the last character of the recor~ has been input. Note that an end-of-record condition only occurS for type files and is of concern only to· the Exec. The end-of-tile condition occurs on the next input operation after the end of record, which signals the last record of the file. The user m~ generate an end of record while writing a tile by ul1ng the co~trol operation to be described. To input a word to the A register or output it from the A register, WIO =file number is executed. An end-of-record condition returns a word of three 134 characters as well as setting the flag bit, and an end of file returns a word of three 137 characters. If the condition occurs when a partially filled-out word is present, the word is filled out with one of these characters. Mixing word and character operations will lead to peculiarities and is not recommended. To input a block of words to memory or output them from memory, the instructions LOX =first word address LOA =-number ot' words BIO =£ile number should be executed. The contents of A and X will be destroyed. 9-6 C) C) The A register at the end of the operation contains the first memory location not read into or out of. Ii' the operation causes any of the fla.g bits to be se't, it is terminated at that point and the instruction fails to skip. If the operation is completed successfUlly, it does skip. Note that a BIO cannot set both the EOR and the EOF bits. BIO is implemented with considerable efficiency and is capable of reading a file at one-half the maximum drum transfer rate. The flag bits (0 and 7) of the file number are set by the system whenever end of file is encountered and cleared on any input-output operation in which this condition does not occur. Bit 0 is set on ~lY unusual condition. In the case of a BIO the A register at the end of the operation indicates the first memory location not read into or out of. Bit 6 of the file number may be set on an error condition. Whenever any flag bit is set as a result of an input-output operation in a fork, interrupt 4 will occur j.n that fork if it is armed. The user may delete all the information in a drum file by executing the instructions LDA -file number BRS 66 He may also eliminate the file entirely by giving an executive command described in Document R-22, or via BRS 63 (vide infra). The index block for a sequential drum file contains one word for each p~VBical record in the file. This word contains the address on the drum of the physical record in the bottom bits. Three operations are available to executive programs only. They are intended for use by the system in dealing with file names and executive commands. A new drum file with a new index block can be created by BRS 1 with an index block number of 0 in A. The file number is 1_ _ _ _ _ _ _ _ _ _ _ _, . -_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ __ 9-7 C) returned in A as usual and the index block. number in X. The initial settings of the r, w, and p capabilities, and the lequential I/O mode flag, should be given in B. To read an index block into core BRS 87 may be used. It takes the address of the block in A and in X the first word in core into which the block is to be read. 9.2 Other Sequential Files 0 In addition to drum sequential files, the user has some other kinds of sequential files available to him. These are all opened with the same BRS 1, except for the device number. Available device numbers are Paper tape input 1 Magtape input 4 Magtape output 5 6 PDP-5 link input PDP·5 link output 7 The device number is put into X. The unit number, if any, 1s put into A. The file number for the resulting open file is returned in A. If BRS 1 fails, it returns an error condition in A as described in Section 9.1. Three error conditions apply to magtape only: o Tape not ready Tape file protected (output only) 1 2 Tape reserved (see p. 9-8). BRS 1 also accepts the following three character mnemonics instead of' the device numbers. Either the rlame or. the number goes in X tor the call. 9-8 C) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Ml'I MTO PDI PDO FSI FSO FIL LPO MDI MOO paper tape input paper tape output (not available) card input (not available)* mag tape input* mag tape output* PDI5 input PDI5 output drum input* drum output* drum input and output* line printer out (not available)* direct mag tape input* direct mag tape output* controlling teletype input controlling teletype output specified teletype input specified teletype output 19 20 CSI CSO TTl TTO NON lOS SNP * requires executive status 16 Ci PrI PrO CDI 17 18 nothing subroutine file snooper counters (Berkeley only) ms 1 is inverted by BRS 110, which takes a file number in A and returns the corresponding device name in X and unit number in A. These files may also be closed and read or written in the same manner as sequential drum files. The magtape is only available to executive-type programs. LOA CTRL o =1 (end of record) =file number is available for physical sequential file 5 (magtape output). Several other controls are also available for maptape files only. 9-9 o These are: 2 3 4 5 6 7 8 c C) backspace record forward space file backspace file write three inches blank tape rewind write end of file write 15 inches blank tape These controls may be executed only by executive type programs. I/O operations to the magtape may, of course, be executed by user programs if they have the correct file number. An executive prograDl may arrogate a tape unit to itself by putting the unit number in A and executing BRS 118, which skips 11' the tape is not already attached to some other job. BRS 119 releases a tape so attached. It i8 possible for magtape and card reader files to set the error bit in the tile number. The first I/O instruction after an error condition will read the tirst word of the next record--the remainder of' the record causing the error is ignored. The magtape .routinea take the usual corrective procedures when they see hardware error flags, and signal errors to the program only as a last resort. The phantom user's three second routine checks to see wnether a W-butfer interrupt has been pending for more than three seconds. If so, it takes drastic and ill-defined action to clear the W-buffer. BRS 114 also takes this drastio action; it can be used if a program is aware that the W-buffer i8 malfunctioning. Direct tape I/O package. A mechaa1am for accessingarb1trarily formatted mag tape 1s available. ~he appropriate operations are: BRS 1 open BRS 2 (or 17 or 2P) close BIO block input/output CTRL control 9-10 C) o BIO is used in the nor.al way, with a word count in A and core address in X. BIO will not live you more data than specified by A. In no case may the block requested cross a page boundary. On input, BIO will skip if the word count presented is exactly right; otherwise, it will not skip, and will leave tne number of words actually transferred in A and the next core address in X. The flag bits (EOR and EOF) in the user's file number are set as with the normal BIO for tapes. In addition to controls 3-8 for tape in the CTRL operation, CTRL 9 has been implemented to allow the user to set the mode for the tape. This operation takes a ~ .or 1 in B21 for setting the tape in odd or even parity. (TSS tapes use odd. pa.rity.) B22 and B23 contain the. "trame count," a mysterious feature of the W-buffer. Use one less than the number of 6-bit characters per word to be shipped. On reading the characters 'are stored right-justified in memory. On writing they are taken out lettjustified. The word count for transfers covers the numbers of words in core actually used. When the tape is opened, the mode is set to odd parity, four characters per word. Snooper Counters. The Berkeley system has a collection of hardware counters which monitor external signals. These may be opened 'as a file with BRS 1. In addition, two operations are provided. CTRL fn requires a 1 in A, and 1/32 of the number of machine cycles to be monitored in B. BIO fn reads in the counters. o i I 9-11 C) 9.3 File Control Block! Every open file in the system has associated with it a file control block. This block consists of four words in the following format: FA FW FD FC FB o Drum files only 9.4 0 0 2 0 Cl 7 r~ first index block address or 0 subroutine address 15 10 C C2 normal file subr. files 23 3 IC D R R H F X D 0 0 U T 0 device 0 0 0 0 0 0 0 2 3 job B 9 drum buffer address or 0 char number 0 count 0 busy count (-1 it file not busy) normal file subr. file Cn .. word being packed or unpacked char count .. -1 to 2 OR .. character oriented OUT .. output DF • drum tile RX = random access { RD = read only ERR • error Permanent~ Open Files There are a few built-in sequential files with fixed file numbers: o controlling teletype input 1 controlling teletype output 2 nothing (discard all output) . input from teletype n 1000+11 output to teletype n 2ooo+n These rile. cannot be ol,ened and need not 'be closed. C) 10-1 o C) o 10.0 Random Drum Files A random drum file is identioal in physical struoture on the drum to a sequential drum file. The only major differenoe is that the non-zero words of the index blook are not neoessarily compact. The reason for this is that information is extraoted from or written into a random file by addressing the speoifio word or blook of words which is desired. From the address whioh the user supplies, the system extraots a physical block number by dividing by the data 'block size and a looation of the word within the block Whioh is the remainder of this division. Further division by 144 yields the appropriate index block. A file may have any number of index bloc~s. A random file may be opened by using BRS 1 with a devioe number of 10. No distinction is made between input and output· to a random drum file. A random file may also be closed by BRS 2, like any sequential file, and CIO, WIO, and BIO may be used for input-output to random files. The sequential I/O mode (input or output) is controlled with BRS 143 and 144. The following additional operations are available: To read a word from a random file, execute the instruotions LDB =address DWI =file number The word is returned in A. To write a word on a random file, put the word in A and execute the instructions: LDB =address DWO =file number Block 1nput-outp~t to random files is also possible. To input a blook, exeoute the instruotions: LDX =first word address . LOA =number of words LDB -first address 1n file DBI -rile number To output a block of words to a. random fHe, execute the instruction DBO =file number 10-2 with the same parameters in the central registers. These block input-output operations are done directly to and from the user's memory, &8.i8 BIO. Drum buffers are not involved and the operation can go very quickly. It is possible to define a random file which has been previously opened as the secondary memory !lli.. To do thi.s, execute the instructions LDA =file number BRS o o ;8 The specified file remains the secondary file until another secondary memory file is defined or until the file is closed. To access intormation in the secondary memory, two SYBPOPs are provided.. These POPs work exactly like DWI and DWO except that . they take the drum address from memory instead of requiring it to be in B. To read a word of secondary memory into the A register, the instruction IAS address should be executed. To store a word from A into the secondary memory, the ins'cruction BAS address should be executed. The word addressed by either one of the.se SY8POPs should contain the drum address which is to be reterenced. This word may also have the index bit set, in which case the contents of the index register will be added to the contents ot the word to form. the effective address which is actually used to perform the input-output operation. The mechanism for acquiring and releasing random drum file space is very similar to the mechanism for allocation of core memory. Whenever the user addresses a section of a random drum tile which he has not previously used, the necessary blocks are created and cleared to O. Note that the user should avoid unneoessarily large random drum addresses, since they may result in the crea.t:i.on of' an unnecessary number of ind.ex blocks. To relea.se random drum memory, use BRS 144. 10-3 C) 10.1 Direct Drum Access An even more efficient method of accessing information on the drum is provided by an interface which allows the user to acquire 2K pages on the drum. and read. or write on them directly. This space is ass igned from the swapping area on the drum and referred to directly by its drum address; a bit table private to the user is used tor validity cheoking. To acquire a 2K page, execute BRS 126 with the desired angular position on the drum ot the page to be assigned in the bottan bits of A. BRS 326 returns without skipping. o If' no more spaoe is available, otherwise, BRS 126 skips and returns, in A, the drum address of a 2K page as a word address (1. e. , with the bottom U bits zero). A page may be released by putting this address in A and performing BRS 127. - To release all pages acquired in this manner, execute CLA BRS 7. This is done automatically by the RESET canmand in .the executive, as well a8 by RECOVER and by a oall for a new subsystem. It should be noted that DUMP does ~ preserve pages acquired by BRS 126. To read or write on a page acquired with BRS 126, use LDA LDB o LDX c:: =core address =drum. address aword cO'U;nt 124 to read'\. 1~'5 to write] ,10.4 These BRS'. preserve all the central registers and normally skip. A no-skip return,tadicates an uncorrectab1e transmission error. The following restrictions are checked by the monitor and will result in an illegal instruction trap if violated: 1) The drum address must be a multiple of' 256 (decimal) and lie within some page aSI1gned to the user via BRS 126. (The latter restriction does not apply to executive programs.) 2) The transfer must not cro.1 a 2K page boundary either in 'core or on the drum. 3) It is illegal to attempt to read into a read-only page with BRS 124 (this produces a memory trap if violated). c) o 11-1 C) 11.0 Subroutine Files An addition to the above-mentioned machinery for performing c) o input-output through physical files, a facility is provided in the system for making a subroutine call appear to be an inputoutput request. This facility makes it possible to write a program which does input-output from a file and later to cause further processing to be performed before the actual inputoutput is done, simply by changing the file from aphysical.to a subroutine file. A subroutine file is opened by executing the instructions LDX parameter word + subroutine address BRS 1 This instruction skips or returns an error code, as for sequential files. The opcode field of the parameter word indicates the characteristics of the file. It may be one of the following combinations: Character input subroutine 11000000 Character output subroutine 11100000 Word input subroutine 01000000 Word output subroutine 01100000 I/O to the file may be done with CIO or WIO, regardless of whether it is a word or a character-oriented subroutine. The system will take care of the necessary packing and unpacking of characters. BIO is also acceptable. The opening of a subroutine file does nothing except to create a file control block and return a file number in the A register. When an I/O o·peration on the file is performed,the subroutine will be called. This is done by simulating an SBRM to the location given in the address field of the X register given to the BRS 1 which opened the file. The contents of the B and X regi.ters are transmitted from the I/O SYSPOP to the subroutine unchanged. 'llhe contents of the A register may be changed by the packing end unpacking operations necessary to convert from character-oriented to word-oriented operations or vice versa. The I/O subroutine may do an ar'bitrary amount of I c.) " o computation any m&¥ call on any number of other I/O device. or other I/O subroutines. A subroutine tile should not call itself recursiveJ.,y. When the subroutine i. ready .to return, it should execute BRS 41. This. operation replaces the SBRR which would normalJ..y be used to return from a subroutine call. The contents of B and X when the BRS 41 is executed are transmitted unchansedback to the calling program. The contents of A may be aitered by packing and unpaoking operationa, A subroutine file. i8 cloled with BRS 2 like any other file. In order to implement BRS 41, it 1s necessary to keep track of which I/O subroutine is open. This informati.on is kept in s1x bits of the PAC table. The contents of these s1x bits 18 transferred into the opcode field of the return addre.8 When an I/O subroutine is called, and is recovered trom there When the BRS 41 11 executed. The u.er should be warned that a .ubroutine tile should not be uled b1 a program in a different address apac, from the .ubroutine it.elf. In particular, subroutine fil•• may not be given to the BRS. which involve accce.1 to named files (de.cribed in the next section). 12-1 C) 12.0 File Naming System Because of the possible conflicts which may ari.se when several users are s~ultaneously trying to access the same peripheral device, such devices cannot be handled directly by users at the level offered by BRS 1 -- which is available only to programs with executive status. At the user level, storage devices can only be referenced in an indirect manner, by writing or reading a "file." o Files are the pr~ary means by which the user establishes continuity between one computer run and the next. A file is. any named block of information which the user finds it convenient to regard asa single entity; the commonest example of a file is a program. To provide a check against inappropriate use, files created by the Exec and TSS subsystems are classified, according to the nature of the information in them, into one of four types, numbered 1 to 4. This type number is carried along with the information content and may be checked whenever the file is referenced. The file types are: 1. Core Image - The information in this originates from specified segments of core memory. 2. Binary - The information has the form of an assembled, but unloaded program. 3. Symbolic - The informat ion is of a form which can be readily listed on some printing device. 4. Dump - Comprises all the information in memory necessary to restart the user from his ctITrent Situation, i.e., the situation at the time of creation of the dump file. Symbolic information may come directly from paper tape or teletype. These devices may be referenced as type 3 files by using the name of the corresponding physical medium, viz. PAPER TAPE o TELETYPE 12-2 C) C) These names are built into the system and are always appropriately recognized. Another built-in tile name is NOTHING which al~s contains precisely nothing and whose function is to aot as an intinite sink in which limitless unwanted output can be lost. A commoner source for symbolic files is the output trom some subsystems, notably the text editor, ~D. Type 2, binary tiles normal.ly arise as the output from the machine-language assembler ARPAS. Until the actual process ot output from the subsystem occurs, identification ot the information is handled by the subsystem and is usually implicit since the subsystems can handle only one file at a time. However, when the information is ejected into a. context involving many other blocks of information ot a similar kind, some explicit identification must be attached to it. 12.1 File N~i~ The names which the user is tree to invent and assign to files are of two types: 1. Permanent names 2. Scratoh names Scratch names differ trom permanent names in that they and the files associated with them are lost when the user leaves the system, using the LOGOUT command; they are otherwise treated identically. A permanent name is an arbitrary string of characters not beginning with / or:. A scratch name is an arbitrary string of characters beginning with / or :. To those users who have drum file privileges, a / identifies a drum file, : a disk tile. As p8l'11anent names we have ABC PROGRAM 1 124 while as scratch names we have - /ABC :421/ 12-3 C) C) o Any permanent or scratch file name may be quoted by surrounding it with single quote markS. Thus, 'ABC' and '/001/' are quoted file names. The quoted name refers to exactly the same file as the unquoted one; it differs only in the way it is recognized by the exec. Control A (backspace) is legal on any name being typed to the file system unless command recognition is taking place. When reference is made to an unquoted name, the exec will anticipate the user and consider the name to be fully delivered as soon as it has received sufficient characters to distinguish the name fram all others currently defined by the user. This means that a new name can never be introduced in its unquoted form. A quoted name, on the other hand, is always accepted in its entirety tran the user. The initial and terminal' quotes are then removed and the name compared with the directory of names currently defined by the user. If it matches one of them, it is taken to refer to that file, just as though it had been presented in unquoted form. If it is new, however, it will normally give rise to an error message unless it appears in one of the' following contexts: a) In the DEFINE NAME command (c.f. Doc. R-22, Section 5.5) b) As an output file name, in which case a new file with the specified name will be created to hold the output. For example, let XYZ be the name of an existing file and /123 be a new unattached file name. Then the exec command ~Opy XYZ TO '/123'. has the effect of creating a new scratch file, called /123, having the same information content as XYZ. If /123 is, however, already attached to same existing file, then the information content of that file is replaced by that of XYZ. In summary, it will be seen that the exec's file name recognition apparatus works in two ways, depending essentially on whether the name is quoted or not. Quoted names must always be given in entirety; the exec waits for the terminating quote before attempting to recognize the name. Unquoted names are anticipated; the exec recognizes or rejects them as soon as it can, insisting that they match some name already in the user's directory of file names. Note that the BEGINNER, NOVICE and EXPERT commands apply t,(j file na'l1e recognition (see R-22,Section'.7). 12-4 12.2 Accessing other Users· Files, .special Grou12s C) The naming system described is adequate to reference all the files belonging to the current user, in whose name the exec was entered. Ifowever, to refer to files belonging to another user, it1s possible to augment the file name by that user's name together with, optionally, a special accessing code called the s,rou12 ~. To do this the basic file name must be prefixed by one of: ( < user name > ) or (. <: user name >, < group name > ) Thus for example: (JONES) t FILE1' or (JONES, GROUP1) 'FILEl ' When such a string as the last is collected from a teletype by BRS 15 or 16, the characters II, GROUPl r! are not echoed to the teletype so that the secrecy of the special group name is preserved. The access that any other user may have to each of Jones t files is in the ha.nds of Jones himself. Jones may declare that a member of the public at large who tries to access his 'FlLEl f . using (JONES)'FILE1' has entire (read-write) a.ccess, read-only access, or no access at a.ll. It is also open to Jones to define independently a greater degree of accessibility to a user who supplies the group name. Specia.l groups can be created by BRS 61 and the command SET MODES FOR FILE (R-22, Section 5.5) or deleted by BRS 62 and. the same command. BRS 61 - Define Special Group Takes a string pOinter in AB. The string is an arbitrary string of characters and is taken to define a new special-group name. The BRS associates with it a number, n, in the range 1!S,.~ 15, which it skip returns in A. A file may. then be placed in that special group by setting this number in the appropriate bits of the file mode wo~d (see BRS 48). A user may have up to 15 currently def'ined, distinct special groups; an attempt to define more results in a no skip return with A=O. An attempt to define an aheady existing special group name also results in a no skip return, but with the group number in A. I i I ,\ 12..5 BRS 62 - Delete Special Group Takes a special group number in A. The associated special eroup name is deleted and the number made available for reassignment to a new name. All files belonging to the special group are released from it. If no name is attached to the number, the BRS has no effect. 12.3 Pseudonlffis By means of the command USE NAME it is possible for a user to insert in his file directory a pseudonym, that is, a name which, instead of being a tag for a real file, is a tag for , another name possibly including a user name and group name. If he later uses the pseudonym, the action taken is exactly the same as if he had typed the entire name for which the pseudonym stands. c) 12.4 Doing I/O to Files, File Numbers The file name is an unwieldy and inconvenient handle for the I/O routines to use in transferring data. These routines instead reference the file by a compact, l-word file number which is more closely related to the file's whereabouts. Thus system subroutines are provided to assign to a given file name some temporary file number. The user may find it useful to remember that the system subroutines which perform information transfers to .and from sequential files are the same for input as for output. The distinction is carried by the file number with which they are used--whose character is in turn determined by whether it was returned by BRS 15 (input) or BRS 16 (output). Hence a program which was deSigned to output information can, without ill-effect, be delivered an input file number. The effect will be to lose the characters which the program would be trying to output, while taking in characters in their place--these too, due to the nature of the program, will in general be ignored and lost. Names are recognized and a file number provided, if required, by the system subroutines BRS 15, 16; they may be deleted by 12-6 C) ERS 63. The preceding description of the manner in which file names are recognized largely assumes that they are being typed in on a teletype. They may, however I be presented to the BRS' s as a ready-made string of characters in core. Entry parameters for the BRSs include a string pointer to a string in core together with an input-file number (most commonly teletype). The character string may be null or an initial part of a file name or an entire file name. In the first two cases sufficient characters are appended from the input file to ensure recognition or rejection of the name. [A Remark on "Random" Files on Tape C) Random and sequent:i.al files may be stored and accessed with equal facility on "random" storage devices, such as the drum and disk. On the other hand sequential devices, such as magnetic or paper tape, cannot be oonveniently or efficiently accessed in the manne~ of random files and are restricted to holding only sequential files. However, the command 'COPY FILE' wil.l allow a user to copy information :eran an existing random file, say on the drum, to a sequential but has a special format which does not allow it a sensible interpretation as a sequential file but permits the original random format to be restored when it is copied bac~ to a random device. Such a "random" file on a sequential me.dium will result in the return of the apparently paradoxical information, 1-0 in bits 0,1 of X when the file is opened by BRS 15, 16. Before accessing information in such a file the user should copy it (using the Exec command or ERS 92) to a non-sequential medium.] 12.5 Ope~ing Input 1"iles BRS l,5 - Open named file for input: Take. in A a control word in B the address of' a string pointer, or ¢ in X a dual file number. The function of this ERS is to recognize an existing file name, optionally, open the tile for input and return a file number for use with iubsequent data-input commands. 12-7 c) o C) Designation of the File The string ad.dressed by B must be the complete or incanplete name of a predefi.ned file. If the name is incomplete, characters will be appended from the input file whose number is given in the least significant 12 bits of X -- until sufficient characters are available to determine uniquely a file name (or no such name). If the f'ile name :1.s unquoted so that prerecognit10n occurs, the "tail" of' the name is echoed back to the output file whose number is given in the most significant 12 bits of X. If B=O on entry a null string is assumed and characters collectedfram the input file are not transmitted to the caller's memory. If bit 0 of B is set, the string delivered is considered null--its position being defined by the,first word of the string pointer. Unless B=O on entry the completed or, in the case of non-recognition, partially completed file name will be transmitted to the caller's memory. If a pseudonym was delivered, it will be replaced by the string for which it stands. Unless the f~le name was complete on entry (i.e., no characters need be taken fran the input file), a terminating character must be delivered to confirm or abort the file name. Confirming characters are those with an internal code representation 0 to 168, also semicolon, tab, line feed and carriage return; the aborting character is 1. All other characters cause? to be output and are otherwise ignored. Action: This is dependent on options which are specified by bits 1 and 2 of A on entry_ These are: Bit 1, if. set, suppresses opening the file (no file number is returned) Bit 2, i~ set, suppresses the need for a terminating character; when these bits are not set, the action is as follows: If the name is recognized and a valid terminating character is received, the file is opened for input. There is a skip return' with In A, a file number In B, the terminat1.ng character In X, is a composite word comprising l2A-l o 1. TAPE or PE~NT FILES WORD 0 WORD 1 WORD 2 ~ TAPE SYSTEM NUMBER WORD 3 DRUM ADDRESS 0 for BRS48 Mask ~ ~ 1 :: random SR ::: sequential or random PRA :: private accessibility PUA = public accessibility o 1 :: rea.d only o :: denied to public 1 :: public read only 2 :: public read and write SGA = special group accessibility 0 = re~ and write 1 :: read only SGN :: special group number 0 = none S = status 0 ::: file permanently on drum 1 = , file on drum 2 = file'on system tape 3 = file on private tape U • unused c) 2. SCRATCH FILES WORD 1 .. -1 WORD 0:: 0, WORDS 2, 3 as for TAPE Fn.ES 3. BUILT-IN FILES WORD 3:: -2; WORD 2 .. a. Device WORD WORD WORD WORD 0 0 =0 1 (9 to ll] :: no. of tape unit ' 1 (12 to 171 -= devtce no (O/P) 1 [18 to 23] '" device no. (I/P) 12A-2 C) r b. 4. = -1 == 0 WORD 1 = creation date PSEUDONlMS Description Block Format o (lip) WORD 3 [20 to 23] group no. WORD 3 = -1 WORDS 0,1 == string pointer to real string C) (O/p) SPECIAL GROUPS WORD 2 WORD 0 5. Permanent file no. WORD 0 0 WORD 1 (6 to 11] == file no. HORD 1 [18 to 23] == file no. WORD 2 =0 == l2A-3 c) FILE DmECTORY DESCRIP.rION (A) PREAMBLE AND STORAGE ARRANGEMENTS 0 FLTH 1 cm 2 SGUS ZRO ZRO ZRO 3 FDJX FUNO BSS SRO ZRO ZRO 10 HTL EHTL FDSS ZRO ZRO ZRO 12 EFDSS ZRO ZRO 4 5 6 7 () 13 File directory length Address of compressed file input table (CFIT) (Bits set to indicate special group numbers in use) Drum index block address for this file directory User number Address of beginning of description block storage Beginning of hash table (BRS 5 I 6 table) End of hash table Character address of beginning of string storage (WCH table) End of string storage Garbage collection option The remaining parts of the file directory appear in the following order: Hash table (HTJJ, EHTL) String storage (EHTL, BSS) File description block storage (BSS, CFTA) c) l2A-4 c) USER DIRECTORY DESCRIPrION (A) PREAMBLE AND STORAGE ARRANGEMENTS 0 1 2 3 4 ZRO EUHT ZRO ZRO BUDSS ZRO BURT 5 6 EUDSS ZRO ZRO BUDBT ZRO 7 BUDB ZRO Beginning of hash table (BRS 5,6 table) End of hash table BRS 5,6 link Character address of beginning of string storage (WCH table) End of string storage Garbage collection option Address of beginning of description block table Length of each user description block The remainder of the directory appears in the following order: C Hash table (BUHr, EUHT) String storage (EUHT, BUDBT) User des,cription blocks (BUDBT, end of directory ) (B) TYPICAL HASH TABLE ENTRY °2l~_____________________STR__ G~~~S~~~~~T_O__________~ lN __ . (C) C) :~ USER NUMBER TYPICAL DESCRIPrION BLOCK ENTRY 0 HTA 1 FDL 2 DA 3 AW 4 :PW 5 6 CTW LTW ZRO ZRO ZRO ZRO ZRO ZRO ZRO Address of hash table entry File, directory drum address Maxtmum drum block allowance Access word Password hash code CPU time word (6Oths of a second) LOGm time word (seconds) c) ACCESS BITS ARE 0 c) 1 WAIT } IDIOT BRS 37 mode 2 PRFFLG permanent file flag 3 4 XMOK exec mode OK NTFFLG new tape file flag 5 UTTFLG new files to user tape 6 OPTFLG operator flag l2-8 6 to In bits 3 to Bit 0 is set Bit 1 is set sequential In bits 23, the file length 5, the file type if the file is random if the file is not stored on a medium. Error Conditions C) All error conditions are followed by a no-skip return with an indioator in X; A and B are undisturbed. -59C~-1 shows that the file could not be opened. The possible reasons correspond one-one With those associated With a no-skip return from BRS 1 with -~~2 (see pp~ 9-1, 9-7). X=l This exit occurs if the name given is not a predefined name in the specified userts file directory. X=2 Indicates that the file name 'Was aborted by delivering ? as a. termina:t ing character. X=O Any such error ~ls accompanied by one of' the following 'error messages' being sent to the command output file (normally the teletype). ? ILLEGAL USE OJ!' PSEUDONYM -NOT PUBLIC -NO GROUP NAME ATTACHED -WRONG GROUP NAME When the requested file exists on magnetic tape it is possible to receive a.l)out 20 different error messages, most of which are self explana:tory. The position check message, "(re: n)" means only tha.t the tape has reset its position after becoming "lost" and should be of no coneern. 12.6 Q2ening OutEHt Files BaS l6 - Open named file for output Takes in A a control word In B the address of a string pointer, or ¢ In X a dual file number. This BRS is provided to read an existing or new file name and, optionally, open the file for output and return a file number for use with subsequent data-output instructions. 12-9 C; Designation of the File The file name is obtained from B and X in exactly the manner of· BRS 15 (q.v.) except that if the name is enclosed between quotes and is not delivered in association with some other user's name, then it may be new. Action This is again dependent on the control word in A, on entry. Bit 0, according as it is or 1, specifies that the file to be created is sequential or random. Bit 1 is normally zero, to indicate that the specified file should be opened and a file number returned in A. If the user does not wish to open the file this bit should be set. Bit 2 if set suppresses the need for a terminating character. It also suppresses output of the message OLD FILE or NEW FILE, which is normally produced after identification of a quoted file name. Bits 3 to 5 -= t, ind:!.cate the file type. The type of a new file j.B always set to be t. The type of an old file is changed to t unlesst::O, when the old file type is retained. An attempt to open the teletype as anything but a type 3 file is an error. Bits 6 to 23 = S, significant only for tape files. S is taken to be the number of words of information about to be written. If a new tape file is specified, a space of 3/2 S words is reserved after the current last file on tape. For an old tape file, S is compared with the amount of tape space currently reserved for the fi.le. If it is greater, an error message - TOO SHORT is produced, followed by a no-skip exit; the file is not opened. The normal return from the BRS is with a skip,the same parameters being returned in A, B and X as for BRS 15 viz. in A a file number number (if opened) in B the terminating character (if delivered) in X a composite word comprising the file length, type and logical structure (random or sequential)--See ° C) c) BRS 15. R-2l 12-10 Error Conditions All error conditions are followed by a no-skip return with an indicator in X; A and B are undisturbed. -5~~-1 shows that the specified file could not be opened. The possible reasons correspond one-one with those associated with a no-skip return from BRS 1 with -~~2 (see pp.9-l, 9-7). X:O This exit follows the printing of one of the following error messages on the command output file (in addition to the possible messages given for BRS 15): READ ONLY WRONG TYPE FILE TOO SHORT FILE DmECTORY FULL X=l if the file name is new and either unquoted or is delivered in association with the name of another user. X=2 if the abort terminator (?) is delivered. Notes: 1) Although new tape files for the ordinary user will be created on the standard user's tape, some users can specify the tape on which a new file is to be created. For such users a message TAPE SYS. NO. = is printed and a decimal number must here be delivered through the command-input medium. 2) If the tile name is quoted and not built in, one of the messages OLD FILE or NEW FILE is sent to the command output medium. As described above, this message may be suppressed by setting bit 2 of A on entry. 3) An attempt to change the ·logical structure of an old file (tromrandom to sequential or vice versa) will elicit a meslage to notify the user before the name terminator is delivered. C\ 12.7 Miscellaneous File Q2erations BRS 63 - Delete name from file direqtory Takes in B a string pointer in X a dual file number 12-11 (\ The entry parameters are used to designate a name in the file directory in the manner of BRS 15. The name is removed from the directory subject to the following conditions: A built-in file cannot be deleted. The ERS will, however, allow the user to delete all its names except the last. When a pseudonym is delivered to the BRS the pseudonym itself is lost. When the last name of a file is deleted, the file's contents are also lost. A successful deletion is followed by a skip return. c) A no-skip return indicates that the attempt to delete failed. The contents of X will indicate the reason for failure as follows: X=3,-2,-1 correspond to nO-Skip returns from BRS 1 with A=-2,-1,O respectively. Such an exit results only from an attempt to delete a drum file. indicates an attempt to delete the last name of X=O B. built-j.n file. Xcl i.f the name is not in the file directory. BRS 60 - Interrogate file description block Takes in B the address of a string pointer in X a dual file number The entry data are used, in the manner of BRS 15, to determine a file. The first three words of the description block for that file (see p. 12A) are skip-returned in A, B a.nd X respectively. BRS 48 - Set file model Takes in A a file mode word in B a string pointer address in X a dual file number. B and X are used, in the manner of BRS 15, to determine a file name. BRS 48 will then use the information in A to set or change the special group membership, type and ac(!essibility of the specified file (which mUllt belong to the caller). All of these characteristics are determined by bits 1 to 4, and 6 to 16 of the third, "xl".ode", word of the description block 12-12 (; associated with the file (see p. l2A). BRS 48 directly replaces these bits by the corresponding bits of A after checking A for consistency and existence of the specified special group. A successful mode change is denoted by a skip return, failure by a return without skipping. 12.8 Qpening Scratch Files Scratch files are all kept on the drum. They differ from ordinary files in that they disappear completely when the user who created them logs out. A fixed amount of drum space is available to each user for scratch files, which he may allocate as he se~s fit. If he attempts to exceed the allocation a message will be given. A scratch file may be created by BRS 16 or any of the commands c) c) which create a new file, by delivering to them a new scratch name (see 12.1). Alternatively, for a scratch file with a name of the form /ddd/ where d is any decimal digit, the elaborate string delivery and recognition procedure of BRS's 15,16,63 can be bypassed by USing BRS's 18,19,65 respectively. Instead of a string pointer and dual file number, these three BRSs take, for file identification, an integer in X. The decimal equivalent of this number is a string of three digits enclosed between slashes is then used as a file name to refer to the file in the conventional way. BRS 18 Takes in A a code word in X an integer This provides an alternative way of referencing and opening for input scratch files whose names are decimal integers. The number in X is transformed into its equivalent string of three dec1m&l digits enclosed between slashes, 5 characters in all, (a number which exceeds 999 is taken to designate the string /999/). This stri.ng should be a predefined name in the caller's file directory. The subsequent action of this BRS is to open the file for input in exactly the manner of BRS 15, i.e., dependent on bits 1 and 2 of A; the return conditions are the same as for BRS 15· 12-13 c) BRS 12 Ta.kes in A a code word in X an integer By means of this BRS a scratch file with a decimal-integer name can be opened for output. As for BRS 18, the number in X is first transformed to a string of three decimal digits enclosed between slashes. The name is then treated as a possibly new name for a scratch file, belonging to the caller., in exactly the manner of DRS 16. Hits 0 to 5 of A also have the same Significance as for BRS 16. BRS 6.i Ta.kes in X an integer The integer is converted into a string of three decimal digits, as in BRS 18, 19. The action thereafter is exactly as for BRS 63, successful deletion being indicated by a skip return. () 12.9 _Format of t,he Pile Direotory, Some Implementation Details File names, group names a.nd pseudonyms are contained in a hash structure of the tYl)e described in the SeeM-on 14 of this manua.l. The f:i.:rst two words of each hash table entry are the conventional string pointers to the file name. The third word (the string "value") is a pointer to a 4-word "description block." In these four words is held all the information necessary to characterize the name, whether it be the name of a drum file, tape file, special group, pseudonym, etc. Notice that severai entries in the hash table may point to a single description bloek; the associated names are then synonyms f6r the same object, which can be referenced by anyone of them. The command DEFINE NAME creates a new name to point to an existing description block; conversely DELETE NAME detaches the name from its descrjption block, the description block itself is lost only if' this was the only name po1nttng to it. The format of a single hash table entry with attached file description bloek is sketched on page 12 A. I 12-14 C~) Executive commands and BRSs are available for interrogating and changing parts of the user's file directory. The commands FILE DIRECTORY and SET MODES FOR FILE are described in the manual for the TSS Executive (Document R-22). BRSs are BRS 60 and 48. The corresponding 12.10 Miscellaneous Services BRS 92 - Copy file to file By means of this BRS information can be copied from one file to another. The entry parameters consist of an input file number, an output file number and some bits to determine the nature of the files. If the information transfer is successfUl,there is a skip-return; if unsuocessfUl, a no-skip return, possibly preceded by a message. On entry, the contents of A are taken to refer to the input CJ file as follows: bits 15 to 23 bits 3 to 5 bit 1 bit 0 give the input file number give is 0 or is 0 the file type for a sequential device (tape, teletype) 1 for a randbm device (drum, disk) for a sequential file, 1 for a random file The contents of B refer to the output files. Only bits 0, 1, and 15 to 23 are significant and have a similar interpretation to the corresponding bits of A. The necessary information for setting bits 0 and 1 correctly is returned by BRS's 15, 16 as bits ¢, 1 of X. The copy will be successfully terminated when any of the following terminators is read from the input file. 1) Input file sequential a) An EOT (144 ) character, if and only i f the input file 8 c/! b) c) is a teletype. An EOF (137 ) character for ofher type 3 files. 8 2 consecutive 1;ermwords (27&57537p,) for all other sequential files. 12-1".5 2) Input file random a) 1 termword i f the file is stored on a seq,uential device. b) Otherwise the copy terminates when the end of the index-block chain is reached. The return after a successful copy 1s with a skip. Errors Errors may be a) Calling BRS 92 with inadmissible parameters. b) Unusual conditions detected during a data transfer. Errors of type (a) may be anyone of the following: Attempt to copy a sequential file to a random file. Attempt to copy a. "random" file on tape to a sequential file. Attempt to copy a non-symbolic file to teletype. Attempt to copy directly from magnetic tape to a teletype C) or v1.ce-versa. They are all followed by a no-skip return. Errors of type (b) are all signalle(l by a message, which is sent to the command output medium. The message,s may be any of: -END OF TAPE UNTTh1ELY EOF IN INPUT UNTTh1ELY EOR IN INPUT RANDOM FILE TOO BIG, TRANSFER TERMINATED AT ADDRESSFAILED TO READ INDE.'X BLOCK INPUT ERROR OUTPUT ERROR All but the last two are followed by a no-skip return. In the case of the last two the transfer continues from the point at which the transfer error was detected until the entire file is copied. () BHS 23 - Ms.,ite a "save II file Takes in A the address of a core-bounds list in B the address of a 2-word map in X a sequential output file number 12-16 This BRS may be used to preserve the contents of' specified ranges of core (in the map given by B) to the output file given by X; note that this file must be sequential. The core bounds list addressed by A, is a contiguous list of positive numbers terminated by any negative number. The first entry of the list is taken as a "starting address" - and is the address to which a transfer of control will be made when the data preserved by this BRS is read back into core by the GO TO command. Subsequent entries in the list are taken in pairs--each pair defining a range of memory from which information is to be saved. The two addresses in each pair may be given in either order. All addresses are taken with the map whose core address is given in B--if B is zero, it will be assumed that the user's current program memory 1s to be saved. C) If the information there is a skip return. in an immediate no-skip The formats of the file are: is successfully transferred to the file, Any failure in the data transfer results return. core bounds list and the resultant save !2!mat of Core Bounds LisJ:!. Starting Address ml nl ~ n2 ··· ~ ~ negative num.ber Format of Save File 11 == min (ml,n l ) max (ml,n l ) Starting Address ul == ·· data· from core range 11 to ul 12 u2 data from. core 12 to u 2 · data from core lk to ~ term word term word 12-17 BRS 94 ~ Restore a save file to core Entry AlB • relabeling X • file no. of sequential save (type 1) file The save file, which should have the fo~at described in BRS 93, is transferred -to the memory given by the map in A,B. If the transfer is successful, there is a skip return with the starting address (see BRS 93) in A and the file number in X. An unsuccessful data transfer results in a no-skip return. BRS 131/132 - (open tape for input/output) [privileged] Given in: C) Return No Skip: Skip: A B = the = the desired tape position (0:"..A<2;6) user number of the file owner (BRS 132 only) X = the tape system number or the tape unit number with bit 0 set. A:: error flag (-2CLB, WCH will write the character in A into character position CLB+l and increment CLB. If CL~CUB the character is not written and control is transferred to the third word of the table with A and X undisturbed and the address of the offending WCH in B. This can be an error trap or an exit to a routine which allocates more memory, by garbage collection or otherwise, for fUrther WCHts. 14.3 String COmpare () Operation.~, SKSE ADDR skips if the string addressed by the pointer in AD is identical with the string addressed by ADDR. If the strings are of different lengths or have different contents, SKSE does not skip. This instruction is essentially identical to SKE, except that it acts on stringt.. rather than numbers. A, B, X are not disturbed by SKBE. SKSG ADDR skips if the contents of the string addressed by AD is greater than the contents of the string addressed by ADDR and ADDR+l. Comparison :1.8 made character by character, and terminates with the first unequal characters; the numerical, internal code representation of characters is used to determine inequality. If the strings are equal for the entire length of the shorter one, the longer one is indicated as the greater. A, B and X are not disturbed by SKSG. 14.4 String Input/Output BRS 33 accepts a string pointer address in A, a file number in X and a "terminal character" in B. It collects characters from the file and appends them to the string until the terminal character is seen; this is not added to the string. It then returns the updated string pOinter in AB; the string 14.4 pointer in core is also updated. If bit 0 of A ::i.s set on entry the string is taken as null with the second pointer equal to the first. BRS 34 accepts a file number in X, a ~ address in A and a count in B. It outputs B consecutive characters starting with the first character of the specified word. If B=-l on entry characters are output until I is encountered a.nd the character $ is interpreted as carriage return, line feed. BRS 35 accepts a f:i.le number in X and a string pointer in AB. It outputs the string to the file. 14.5 !J!I.sh Ta.ble Looltup Instruct ions The ha.sh table is a structure for minimizing the effort required to perform certain scan-and~compare operations when the operands are strings. A hash table is a contiguous set of 3-word "augmented string pointers. " The addresses of the first and last-plus-one locations of' the hash table we shall denote by BT, EBT respectively. Each augmented string pointer occupies three consecutive locations of the hash table. Bits 8 to 23 of' each of the first two locations hold the actual string pointer; bits 0 to 7 of these two words, as well as the entire third word (the so-called string "value") may hold a.rb i trary inf'orme.tion. Note, however, that bits 0 to 7 of' the string pointer words ~ be zero if used with Gel or WeI. There are three BRSs to perform operations on a hash table: they are BRS 5, BRS 6, BRS 37. BRS 6 is used to introduce new strings into the table. BRS 5 and BRS 37 each perform a scan of' the hash table for a string to match a given string. Bef'ore using BRS 5 and BRS 6 to insert string pointers into an initially empty hash table, the hash table area. must be cleared to zeros. BRS 5 takes a. string pointer in A, B, a. table address in X. The table compr:lsea 1 wnrus: ZRO ZRO HT EHT ZRO 0 14-5 c c () The first two define the hash table bounds, the third is used for communication with BRS 6. BRS 5 searches the hash table for a string to match the given one. If successful it returns in B the address of the hash table string pointer (the string "index")--and in A the string "value"; it skips on return. If the search is unsuccessful, BRS 5 returns with A, B unchanged and the address of the next free table entry in word 3 of the table (this will be -1 if the table is full). X is not disturbed. BRS 6 takes a string pointer in A, B and. a table address in X. The table is as for BRS 5. This operation inserts the string pointer into the hash table at the point determined by the last BRS 5 which failed (i.e., at the location specified by the third word of the table). If this word is -1, there is an illegal instruction trap. BRS 6 is intended for use only in inserting into the hash table a string pointer for which BRS 5 failed to find a match and should not be used except after a failing BRS 5. Furthermore, string pointers should not be placed in the hash table except with BRS 6 (otherwise the sGanning algorithm used in BRB , will not work). Note that BRS 6 does not physically move the characters to which (AB) points. On exit, BRS 6 returns in B the address of the first word of the new hash table entry and in A, the "value" word of the entry; X is not disturbed. To delete a hash table entry, put -1 (E2i 0) in the first word. BRS 37 takes a dual file number in A, a string pointer address in B and, in X, the address of two words containing table bounds HT, EHT. A dual file number is a single word holding an output file number in the first 12 bits and an input file number in the second. If the output file number is zero, the user'. teletype will be used. The table has the same form as a hash table, but the string pointers may be put into it in arbitrary order; it is E2i neoessary to use BRS 5 and BRS 6. The behavior of BRS 37 depends on the (~omme,rld recognition mode currently set in the exec (see R-22, Section 5.5). If the 14-6 c) c) mode is BEGINNER, the hash table is scanned for a string to match exactly the given one. If none is found but the given string matches the initial part of some hash table string, characters from the input file are appe~ded to it until either an exact match is obtained 2! a match becomes impossible. The exit is described below. If the mode is NOVICE, the hash table is scanned for a string to match the given one. If none is found but the given string matches the initial part of some hash table· string, characters .from the input file are appended until the string is long enough either to determine a unique hash table string, with a matching initial part, or for no match to be possible. In the former case, if the hash table string now contains three or less as.yet-unmatched characters, more characters are taken from input until an exact match is obtained or no match is possible; if the hash table string contains four or more as-yet-unmatched characters these unmatched characters are sent to the output file. If the input file is the teletype, BRS 37 waits until all the characters have been output, and the input file buffer is cleared before exit. If the mode is EXPERT the hash table is scanned for a string to match the given one. If none is found but the given string matches the initial part of some hash table string, characters from the input file are appended until the string is long enough either to determine a unique hash table string, with a matching initial part, 2!. for no match to be possible. In the former case the remaining characters of the hash table string are sent to the output file. Exits are as follows: The no~match condition causes a no-skip exit with a str1ng pointer in ABto the string so far collected; X is undisturbed. If a match is found there is a skip exit with the address of the matching t_ble entry in A and the string value in B, X is undisturbed. The following aubrout1ne illustratos a. use o·r the hash table taa1.11ty. A .tr1n~ is input from the tel{~type. and appended to WeH string storage unt:tl a carriage return 1s encountered; 14-7 () it is assumed that string storage does not overflow in the process. The hash table is then searched for the string; if it is not already there it is inserted. In any case, an exit is made with the value of the string in A and the address of the string pointer in B. On entry X contains the address of the table for DRS 5, 6. CTt is the address of a table for WCH. LOOP ZRO INPL LDA STA CTt Tel SKE =155B terminator? BRU WRITE TEMP yea LDA LDB BRS BRS SBRR WRITE WCH BRU () remember beginning of string TEMP CHAR CTL 5 6 INPUT CTL LOOP 15-1 15.0 Float1ns POint Instructions This section describes the floating point operations which are available in the system. SYGFOPs are provided to do floating addition, subtraction, multiplication and division and to convert under format control between the internal floating point representation and an external representation as a string of digits, decimal points and E (tor exponent). BRS' s ex1stwhich perform input-output and conversion automatically without involving the user With the external string representation. All ,these operations preserve the X register, except input routines which return the terminal character in X. Most destroy AB by leaving a result there. 15.1 Floatins Feint ~epresentat1o~ A float1ng point number is held internal.l..y as two 24 .. b1t machine words. The format "is f (:: "'ellD'ilr 11 a1""'11 DOrmal1zed : i.e. ~ the most aisn1f1cant bit of the mantilsa differs from the sign bit. All floating point operations expect normalized operands and produce normalized reaulta. Both mantiasa and exponent are treated, as two.,. complement numbers. The two words of the floating point number appear in the Ai relister or in memory in the order indicated. 4 floating point DUmber i8 represented externally as a str1Dg ot character.. This string has the following forml [:1 rltl"lDs of digits] [.[string ot di~itBJJ [E[:]atring of digits] The braabt•. tDd1cate optional constituents: At least one digit must appeU'. Imbe4d.e4 blanks are not allowed. The E indicates that the preceding number 18 to be multiplied by the power of 10 .pec1fl.4 ~r the E. In general a floating point number being input may tllte any torm which matches the template above. On output the form produced Will be determined by t~e format specified. :1,5-2 c) 10.2 Floating POint Arithmetic There are fou~ SYSPOPs to perform floating point a~ithmetic. Each of these taltes one operand from AB and the other from M and M+l where M is the effective address of the instruction. The result is lett in AB in normalized form. If its magnitude is sreater than 5.7896Q44E+76, the overflow indicator will be turned on and this value will be returned. The overflow indicator is not cleared by any of theae tDltructionB. In this respect the floating point POPs behave exactJ¥ like the integer machine instructions: a sequence of' operations can be performed before the overflow bit il teated. The bit will be on if any operation caUled an overflow. If the :IIesult il less than 0.803616E-77, it will be let to O. No indication will be given. The four operations are: FAD FSB FMP FDV () Floating Floating Floating Floating add subtract multiply divide An attempt to divide by 0 will produce an overflow. Two SYSPOPs are provided for loading and storing double words. The words involved need not be floating point numbers, of course. Load 'JOinter: puts the contents of M and M+l into AB. Store pointer: STP M puts the contents of AB into M and M+l. Three BRS's provide for unary operations involving floating LnP M point numbers. Floating negate: Fix: c) Float.. BRS 21 returns in AB the negative of the floating point number supplied in AB. BRB 50 converts into a double preciSion fixed point number. The int~ger part appears in A. The traction part appears, lett justified, in B. If' the integer is too larse, the moat significant bits will be lost. The :i.nteger part is the next smaller integer. ~s I.e., IP{-1.2)=-2. 51 converts the integer in A to floating point number in AB. Ii. normalized 15-3 15·3 IniBt!OutEut Formats and Conventions Every I/O operation allows the user to specify a format in the X register. Format specifications are based on Fortran conventions, and are specified as follows: Bit of X c··.\ Field Name 0-2 T 3-8 D 9-14 w 15 16-23 o ~_/ N S1snificance Format types: 1 integer. 2 E format with the number right justified within the specified field. 3 F format with the number right justified within the apecified field. 4 E format with the number left justified within the specified field. 5 F format with the number lett justified within the specified field. Number of digits following the decimal point. Total field width If the field width is 0, the I/O will be done in free format. Overflow action. I/O file number. 0 always refers to the te letype . ISC and SIC ignore this f1eld. -. Examples: ,6.3 30306000 21121000 E1.7 ·9 10005000 15 On input only the W and N fields are significant. Note that exactlyW characters will be read on input (unless W=o). Leading blanks and any trailing characters are ignored. Free format input will accept as many characters as it can in constructing a number which fits the external representation described above. The in,put operations always return a floating point result. They 'ld.p unless overflow occurs, in which ca.se they return the largest possible number and do not skip. .Any number of digits may be provided: the first 11 digits after anY' leading zeros will be the oneBused. On output the W field should be made large enough to accommodate Sign, dec±mal point, E, sign of exponent and exponent (if thef'o:rm.a.t type requires anY' of these E!lements) a.s well a.s c) 15-4 the digits of the number itself. See the discussion of error conditions belo",. The sign is printed only if the number is negative. There are two ways to output an integer: (1) integer format, or (2) F' format with 0 in the D field. The former requires that the number in the A register be in integer form; the latter expects a floating point number in AB. Free format output generates between 11 and 16 characters. If the magnitude of the number is between lEO and 1E9, ten digits are output with the decimal point properly placed. Otherwise, exponential format is used; in particular, the format E15.9. For example, the following numbers might be generated by the free format output. 5.789604462E+76 5 .379605400 15.4 c) C) <' InPqt/Out~ut Operations Two SYSPOPs are available to convert between the internal binary representation of a floating point number and its external decimal representation as a string of characters. The string is stored and addr.essed according t,o the standard system conventions. String to internal conversion (SIC): Characters are read from the string pointer addressed by the pop under control of the format in X. The internal representation of the number is returned in AB. 'l'he first character after t.he number is returned in X if free format was specified. / Internal to stri.ng conversion (ISC): The number :i.n AB is converted according to the format in X and the result:lng external representation is written onto the end of the string addressed by the POP. The string pointer is updated. Two BRS's arc available to do input/output and conversion at the same time: Floating input: BRS ~j~~. Input takes pla..ce according to the fo:rmat word in X.l'l1e operation of th:ls HRS is identical to that of SIC. 15-5 Floating output: BRG 53. Output takes place accord.ing to the format word in X. 'J.'he operation of this BHS is identical to that of'ISC. (., ,,-) 15.5 Output Error Conditions There are four possible error conditions. When one of these conditions occurs the following action 1s taken: a) Interrupt 5 is generated b) An error code is put into location 200B c) The indicated corrective action is taken and execution continues. Condition Action ~ . /--', ( 'I " - ,J 1 2 T fielq is not 1,2,3,4 or 5 Exponent field is too small 3 Integer exceeds 8388607 in magnitude Field for F-conversion too sma.ll 4 Assume 2(E format) Discard characters from the left or ta.k.e overflow action. Use 8388607 Discard characters from the left or take overflow action. If either of error types 2 or 4 occurs and bit 0 in the format word is set,then the output field will be filled with *'s. c) A-I (i / BRS TABLE MONOPN mMBER MONCLS 2 MPl' 3 4 NAME SSCH ssm 5 6 DCLR 7 IOH FKST 8 EXSOFN 9 10 11 12 13 14 1.5 16 17 18 19 CFm 20 FHA 21 LNK8 23 24 PPM () ClB CET SKI DOB EXGD'N EXOOFN UABORT EXSIFN LNKC MaGS SKROUT ASTT RSTT C~B (- . ~) 1 2.5 26 27 28 29 FUNCTION Open file Close file 9-4, 9-8 9-4 Release memory SPS search SPS insert Release all space acquired via BRS 126 Close all files Open fork Programmed panic Clear input buffer Declare echo table Skip if input buffer empty Wait for output bufter e~ty Symbolic input file name Symbolic output file name Close all files Scratch input file Scratch output file Close file Floating negate Link TTY Unlink Set AM and AI bits Skip if rubout waiting (exec) Attach TTY Release TTY Clear output buffer 5-3 14., 14-5 10-3 9-4 3-1 3-6 7-5 7-2 7-5 7-' 12-6 12-8 9-2 12-12 12-12 9-2 15-2 7-6 7-7 7-4 3-6 7-3 7-3 7-' . ! A-2 c) NAME FKRD GETSTa 30 31 32 33 ~U1'MSG 34 ~urSTR 35 36 37 FKWT FK'J)1 ~UTNUM GSI¢f6K GETNUt1 C) 38 RMDY 39 RDET 40 I~RET 41 42 43 RREAL RDRL STaL SQ9S NRPUT SR~UT SE'l'FDC SRIR FFIX FFLT FFI F~ FUNCTION NUMBER 44 45 46 47 48 49 50 51 , 52 53 " Read fork Wait for fork Terminate fork Collect string Output message Output string output number General string lookup Read number 3-3 3-3 3-3 14-3 14-4 14-4 13-1 14-, 13-1 Read date and time Read echo table Return from Ilo subroutine Read clock Read relabeling Set relabeling Dismiss on quantum overflow Turn rubout ott (exec) Turn rubout on (exec) Set fd control word Read interrupts ~ed Fix Float Formatted floating input Formatted floating output 6-1 7-2 11-2 6-1 5-2 5-2 2-3 3-6 3-6 12... ll 4-2 15-2 15-2 15 .. 4 15-5 54 MRSB 55 MBEX 56 57 58 59 60 61 62 C~ SSMF CJ RFOC SGDEF SGDEL Make or release resident block Make block executive Guarantee 16ms computing Define secondary memory Read PMT Read tile directory entry Define speCial group Delete special group 5-4 2-3 10-2 12-ll 12-4 12-5. A-3 C) NAME NUMBER FUNCTION EXDEL 63 64 Delete named tile EXSFDL ~ DFDL 66 67 Delete scratch tile 12.. 13 Delete drum tile (contents only) 9-4 EBSM GBSM 68 smc EXPMS *EPPAN 12-10 '-3 69 Enter block in SMT (exec only) Get SMT block to EMT (exec o!ll1) 70 71 72 73 74 Skip it executive Exec diami8sa1(exec only) Economy panic 6.. 1 Arm. interrupt. Cau.e interrupt Make blook RO Dismiss for specified time Sys go 4.. 1 4-1 5.. 3 6-1 Set special teletype output Clear special teletype output Read execution time 7-7 7-7 6-1 3-5 13-1 12-14 94 Declare fork for rubout Time to string Copy Save Place 95 Dump 96 Recover ' .. 3 2-' 3.. 4 75 ·76 C; SAm SIIR NBRO 'WUA.L SET8p 85 cLR8P S6 RTEX 88 89 90 91 92 93 DFR EXRTIM ECCOPY BeSAW C) 77 78 79 80 81 82 83 84 ECPIAC ECDUMP ECRECV 12-35 12-17 A-4 (~) -NAME ECFNDU NUMBER !:~CTION 97 lind user 13.. 2 Read subsystem relabeling 13-3 Convert name to user number Convert user number to name Wait for any fork to terminate Read all fork statuses Terminate all forks Dismiss Read device and unit Return trom exec BRS (exec only) Turn off teletype station (exec only) 13-2 13-2 3-3 3-3 3-3 5-1 9-5 6-2 7-4 98 KBl~~ EXCNUN EXCtmN FKWA FKRA FK'm IMS RDU BRSRET C) TSOFF MTDI CKDOPN RURL SURL mET TREL APM'l'E DH4TE MPAN RTUN RDRM WDRM DGET DOL (i ---. 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 ll,5 116 117 118 119 120 121 122 123 l24 . 125 126 lZf 128 Disconnect W-butfer (exec only) 9-6 Skip if no drum files open Read user relabeling '-3 Set user relabeling 5-3 Reserve tape unit (exec only) 9-6 Release tape unit (exec only) 9-6 Assign EMf entry (exec only) '-3 Release specified FMT entry '-3 Simulate memory panic (exec only)6-2 Read teletype and user number 13-2 Read 2K block 10-3 Write 2K block 10-3 Allign 2K page 10-3 Release 2K page 10-3 A-5 () - NAME RDBA PTR PTW SKUEX WIR NTOS MFLSH CJ c! RSCP SSCP RDSS STST NUMBER 129 130 131 , 132 133 134 135 136 137 138 139 140 141 142 143 111-4 FUNCTION Read drum assignment Position tape to read file Position tape to write file (exec only) 12-17 12-17 Skip if caller executive Wait for input request Suppress or allow output Force drum/core correspondence Read status of caller Set status of caller Read status Set status 7-5 7-7 5-5 6-2 6-2 9-1 9-1 B-1 C) C~) SYSTEM PROGRAMMED OPERATORS BIO TCO TCI BRS CTRL SBRR SBRM STP LDP Gel WCH SKSE SKSG CIO WIO WCI FAD FSB FMP FDV EXS ¢ST IST SAS LAS DW¢ DWI DBO DBI ISC (-i ~"---_/ SIC 176 175 174 173 172 171 170 167 166 1&.5 164 163 162 161 160 157 156 155 154 153 152 151 150 147 146 145 144 143 142 141 140 Block input-output Teletype character output Teletype character input Branch to system Input-output control System branch and return System subroutine call Store pointer Load pointer Get character and increment Write character Skip on string equal Skip on string greater Character input-output Word input-outp~t Write character and increment Floating add Floating subtract Floating multiply Floa.ting divide Execute instruction in system mode Output to specified teletype Input from specified teletype Store in secondary memory Load from secondary memory Drum word output Drum word input Drum block output Drum block input Internal to string conversion (floating output) String to irlternal conversion (floating input) 9-3 7-2 7-2 Appendix 1 9-4, 9-6 14-1 14-1 14-1 14-3 14-3 14-3 9-2 9-3 14-2 15-2 15-2 l!5-2 15-2 6-2 7-4 7-4 10-3 10-3 10-1 10-1 10-2 10-2 l!5-4 15-4 II: Ii :1 II II II II il II I B-2 /'---." ~) STO 137 136 135 134 BPT 135 GCD STI weD C) Get character and decrement Simulate teletype input Write character and decrement Steal teletype output Breakpoint (BRS 10) 14-2 7-7 14-2 7-7
Source Exif Data:
File Type : PDF File Type Extension : pdf MIME Type : application/pdf PDF Version : 1.4 Linearized : No XMP Toolkit : Adobe XMP Core 4.2.1-c043 52.372728, 2009/01/18-15:56:37 Producer : Adobe Acrobat 9.13 Paper Capture Plug-in Modify Date : 2009:09:21 07:57:48-07:00 Create Date : 2001:08:19 11:03:11-06:00 Metadata Date : 2009:09:21 07:57:48-07:00 Creator Tool : Acrobat 5.0 Paper Capture Plug-in for Windows Format : application/pdf Document ID : uuid:25f65e7b-339b-4787-9195-e5d6a2d20932 Instance ID : uuid:ae64c104-722d-4e8b-90f0-7bf1d6bd3914 Page Count : 105 Creator : Acrobat 5.0 Paper Capture Plug-in for WindowsEXIF Metadata provided by EXIF.tools