. . $31.55.... 1 v . c 5.9.9.5 a 4 .11.. . ...h....? fa. .. ...? :. R UTE =E‘XPERIM D... W .. . . L mi... . _ mm. ...wm . . . . , H... P e N K _ . . My . w... m m . . ., , T. .. M H ., . . _ a. m . Tl. M .../....5memmamm. VSYSTE .1; rl 57:1. CS . ..5. ..L p n .. u’HESlS L I B R A R Michigan State University This is to certifg that the thesis entitled Janus: A Realtime Timesharing Computer System for use in Nuclear Physics Experiment. presented by John Oscar KOpf has been accepted towards fulfillment b of the requirements for M4— degree in MS l [595.5 Major: professor Date [”7" 6:3 0-169 ABSTRACT JANUS: A REALTIME TIMESHARING COMPUTER SYSTEM FOR USE IN NUCLEAR PHYSICS EXPERIMENTS By John Oscar Kopf A computer program called JANUS has been deve10ped for use on a Scientific Data Systems Sigma Seven computer. JANUS is a computer op— erating system, designed to permit many different users to share the resources of the computer, such that each user is apparently in sole control of the machine. These resources include the time available for operation, the program and data storage available, and communi- cation links with the world external to the computer. A comparison of the means and mechanisms of resource management provided by various computer operating systems, including JANUS, is presented. Descriptions of inadequacies, both in hardware and in op- erating systems, are given, with suggestions on possible improvements in future implementations. In those cases where it has been possible to measure various parameters under JANUS operation, the measurement and a comment on its significance is provided. Reference manuals for JANUS and various control monitor tasks are appended, as well as thoughts on the possible implementation of other desireable processes. A novel method has been developed to handle realtime processes. The computer may be used to simultaneoushy control devices, acquire data, and perform analysis and computation. Any process may be start~ ed or stopped at random, irrespective of the other usage of the machine. The flexibility introduced into the use of the computer, compared with conventional realtime systems, is impressive, since, if necessany, all John Oscar Kopf of the resources of the computer may be directed toward any goal, using a single operating system, without the overhead normally associated with such systems. This is accomplished by providing within the resident monitor only those primitive functions dealing with resources common to all usage. Higher level functions, such as Input/Output, are provided by independent timeshared tasks. These tasks, with the features normally associated with conventional monitors, provide those functions neces- sary and sufficient to the operation of a specific set of problems. JANUS: A REALTIME TIMESHARING COMPUTER SYSTEM FOR USE IN NUCLEAR PHYSICS EXPERIMENTS By John Oscar Kopf A THESIS Submitted to Michigan State University in partial fulfillment of the requirements for the degree of DOCTOR OF PHILOSOPHY Department of Physics 1968 4" / \ a J” 4/53 (is? f, Dedication: For my wife Peggy Who minded the kids. 11 ACKNOWLEDGMENTS I wish to acknowledge my indebtedness to all the people who helped make JANUS, and this thesis, possible. First and foremost, I am grateful to my advisor, Professor Aaron Galonsky, for his patience and encouragement, and for allowing me a free hand in the design and implementation of JANUS. Secondly, I acknowledge the great assistance of Mr. Phillip Plauger, whose familiarity with other computers and computer opera- ting systems, and_whose willingness to engage in many all-night bull sessions, helped immeasurably in the design of JANUS, to say nothing of the fact that the original idea to write the timesharing mystem which became JANUS was his. Third, I wish to thank Richard Au, Douglas Bayer, Carolee and William Merritt, Francis Schiffer, and Laurence Wilbur for their pro- gramming assistance in coding tasks, libraries, symbionts, and other parts of JANUS, as well as their aid in finding and correcting errors in JANUS. In leaving, I feel that JANUS is in good hands, and will continue to grow in use. Fourth, I acknowledge the assistance of Mr. Lester Hanson and Mr. Donald Freedman. who, as on—site engineering representatives of SDS, were instrumental in quickly verifying, redesigning, and changing those design errors which are always present in a new computer. With- out these changes, the Sigma 7 would be incapable of running JANUS. I iii also wish to cite SDS, which delivered an operating system with the computer, without which it would have been impossible to even begin to start JANUS. Fifth, I wish to thank Mr. Robert Belgard, who drafted most of the figures presented, and Mrs. Susan West, who typed the thesis. I also wish to thank all of the other people at the M.S.U. Cyclotron Laboratory, too numerous to name, who in one way or another helped with JANUS. My thanks especially to those people whose con- stant insistance that I Justify JANUS, thereby forced me to re-evaluate the design of JANUS at all stages, and caused me to formulate a flexible and self-consistent system. Finally, I wish to acknowledge the financial assistance contri- buted by the National Science Foundation and by Michigan State University. iv TABLE OF CONTENTS Chapter Page Table of Contents. . . . . . . . . . . V List of Figures . . . . . . . . . . . V11 1. Introduction . . . . . . . . . . . l 2. The Use of Core Memory . . . . . . . . . 12 3. Bulk Storage . . . . . . . . . . . 28 4. Scheduling of Time . . . . . . . . . . 35 5. Design Goals of JANUS . . . . . . . . . 42 6. Unique Features of JANUS . . . . . . . . . an 7. The Target Computer . . . . . . . . . . 46 8. Structure of JANUS . . . . . . . . . . 52 9. Address Spaces . . . . . . . . . . . 6O 10. JANUS and RPM: A Comparison . . . . . . . . 66 11. Measurements . . . . . . . . . . . 72 12. Conclusions . . . . . . . . . . . 76 Bibliography . . . . . . . . . . . 80 Appendix A. Glossary of Terms . . . . . . . 82 Appendix B. JANUS Reference Manual . . . . . . 86 1. Resident Tables and Lists . . . . . . 86 2. Resident Routines . . . . . . . . 98 3. Demand Paging . . . . . . . . . 105 4. Program Optimization . . . . . . . . 115 5. Signals and the Message Center . . . . . 117 V 10. 11. 12. Timekeeping . . . . . . . . Unique Resources . . . . . . . Prefices and the Console Teletype . . Disk Files . . . . . . . . Symbionts . . . . . . . . Control Commands and the Amperscaner Task The Housekeeper Task . . . . . . Appendix c. The JANUS Basic/File Control Monitors Appendix D. Appendix E. Under JANUS . . . . . . . . . vi Notes on Cyclotron Control Implementation Notes on Conventional Terminal Implementation 119 122 127 131 13h 136 138 141 1H6 151 LIST OF FIGURES Figure Page 1. 2. 7. Memory allocation under a foreground—background scheme of timesharing. The vertical column represents core memory. The monitor is used to provide all control functions. The area of core devoted to background timesharing is successively occupied by a number of processes, all limited to the size of the back- ground area. The realtime foreground area may be occupied by any one of a set of processes, (or divided to thatrit may be used by more than one pro- cess), but any realtime process generally locks out all other realtime processes. . . . . . . . 7 Memory allocation under JANUS. As in Figure l, the column represents core memory, with JANUS at the bot- tom. Two tasks are shown, with the independent task address spaces twining through memory. Est all pages of a task need be in core at one time. The darkened pages of core are dedicated to realtime processes specific to the task which has the page . . . . . 11 Key to subsequent figures. (Note the use of the word active, which in this context refers to a task executing a. time'lices) o s s s s s s s s s e s O 13 Memory allocation-~proJect MAC. User execution alternates with swapping (the process where the program is trans- ferred to or from memory) . . . . . . . . . 15 Memory allocation--Dartmouth project. .A new program is swapped into core memory while the current program is executing. HOwever, an imbalance in the number of Jobs assigned to high and low storage causes a delay at the end of the third timeslice, as there is nothing to do but wait between.USER 3 and USER 1. . . . . . . 19 Memory allocation-~PDP-6 computer. Swapping occurs concurrently with execution, but the efficiency is higher than in Figure 5, as no limitation is im— posed by the use of specific areas. Note that a sig- nificant part of memory is rarely or never used. . . 22 Memory allocation--project GENIE. Problems are initially brought into free core. When no more core vii 9s 10. 11. 12. 13. l“. 15. is free (TASK h), those pages are chosen which are not currently in use and are identical to the copy on the disk (unmodified), to be overwritten by new pages. The resultant fragmentation of Jobs is off— set by the use of a memory map. Not until the sixth timeslice is it necessary to write a page out to the disk (TASK 1, Page 5). This scheme is also used in JANUS. (The P numbers are pages within each user's address space. M signifies that the page is modi- fied, W indicates that it must be written onto the d1Cks) s s s s s s s s s s s s 2“ Gross memory allocation under JANUS. showing real- time processes. Using a large time scale, all short- term details of memory usage are omitted. Shown instead are areas dedicated for realtime processes. The blank area is available for swapping. The ac- tivation of fourttasks is shown, each of which im- mediately initiates a realtime data input process. These tasks, in order of appearance, might be MOIRAE, JBCM, DATA TAKER, and JFCM. the the in- terleaving of lineprinter output of tasks 1 and 2. The variable size scope display is a measure of the amount of realtime buffer area required as a display is expanded to show relationships instead of detail. . 2? Characteristics of various bulk storage media . . . 29 Linear bulk storage structure. (Used by CDC 6600 (extended core storage) to hold programs and non- executable I/C buffers.) . . . . . . . . 31 Hierarchical storage structure. Access time de— creases with height. Each storage medium has an independent address space . . . . . . . . 31 Hybrid storage structure . . . . . . . . 33 Priority scheduling. A task in a high priority ring will be accessed more rapidly than one on a lower ring . 38 “Timesharing” by interrupts. Execution alternates between the background (lower) and foreground (upper) line, on the basis of interrupts. While a simple case is shown, interrupts need not all belong to the flame foreground process . . . . . . . . 40 Typical world line of JANUS operation. The path of Operation (heary line) proceeds through a task 1 from T to T :, interrupted by the swapper. At each T', it passes to the Jobchanger, which.performs operations (interruptable by the swapper, as between Tu: and T5), and returns to the next task in the ring. Each interrupt by the Swapper is used to initiate a viii new RAD operation, or finish an old operation. These RAD operations are used to ready the next task. . . . . . . . . . . . 53 16. JANUS form of control structure. Operations are divided into three parts; mapped slave, mapped master, and unmapped realtime. Paths of communica- tion between the three parts are shown by arrows . . 56 17. Tree structure of tasks. The first rank of tasks below JANUS are the system tasks. One of these (the Amperscaner). can start subtasks, which may start subtasks of their own. These subtasks may be identical copies of tasks which may be started by the Amperscaner, or they may be unique . . . . 57 18. Examples of address space usage, including files. The vertical columns are independent task address spaces, resting on the JANUS block common to all . tasks. Two tasks are shown, with TASK 2 being a subtask of TASK l. The two tasks have one page in common (TOP 2) which appears in different parts of the two task address spaces. The two tasks share a driven stream file, which is also refer- enced from different parts of the two address spaces. It differs from the TOP 2 usage, however, in that file driver (TASK 1) may be several pages ahead of the file receiver (TASK 2). The files are a collection of diskpages, each of which may be used as the same address space page. Only one page of a file is actually within the task address space at any given time, however. Files may be linked internally, or may be linked through a table residing within the task, as is shown in the keyed file 0 O O O O O O O O O O O O 62 19 s Th0 Jab Changer "" flow Chart s s s s s s s 92 20. The Swapper - flow chart . . . . . . . 98 21. Demand paging - flow chart . . . . . . . 107 ix sssssssssssss sssssss 1. INTRODUCTION Physicists have used digital computers for as long as computers have existed. Indeed, long before the first computer was built physi- cists were suggesting that computing machines would be useful for gen- erating astronomical and mathematical tables. More recently, with the advent of quantum mechanics, people such as Hartree called for the de- velopment of machines to perform computations for the calculation of wavefunctions and energy levels of atomic structures. As soon as electronic digital computers became available, they were set the task of performing physical calculations. The usage of computers took great strides with the successive introduction of as- semblers (which freed the programmer from the nuisance.of bookkeeping relevant to the computer but not to the Operation he wished to perform), and compilers (which permitted the programmer to forget all details of a specific computer, but instead to write programs usable on.a11 computers which had a similar compiler available). The earliest languages (FOR- TRAN, ALGOL) were developed as aids to computation. Their success lead to the development of larger and faster computers. This in turn per- mitted the development of more powerful programs, which 142d to concepts of batch processing. Batch processing was a logical development of the observation that, over reasonably long periods of time, the computer averages as much time spent reading cards and printing as it does computing. Since the bulk of the operations involved were read, print and punch, the computer 2 could obviously do more computation if these operations could be done faster. However, there are limitations to how fast a device may be oper— ated. Further, these operations could be performed by a tiny computer. Thus multiple computer systems were developed, where a small computer copied cards onto magnetic tape which was later read by the large com— puter at much higher speed. The large computer then.wou1d write the output on other magnetic tapes to be printed later by the small computer. This provided improved usage of the large computer, and the value of the additional computation more than offset the cost of the additional small computer. However, since the computer now performed all operations auto- matically, it was no longer possible for the programmer to know Just when his problem was being processed, and to interact with it. Furthermore, a fairly long time delay was required between submission of a problem and the return of the results. People soon discovered that the small computers were useful in their own right, and that for many simple problems, results could be re- turned faster than with the large batch processing systems, since almost no computation was required. Thus a continuing development of small computers paralleled the develOpment of the large computer’systems. With the rise in computer technology, it became possible to build spe- cial purpose computers, usually consisting of a hard-wired program and a memory. In nuclear physics, these were best typified by multichannel and later multiparameter analyzers. While extremely useful, the allow- ed sequences of Operations were built into the machine and were relar tively inflexible, being limited to specific configurations which could be changed only with great difficulty if at all. It ... usually neces- sary to do complex operations external to the analyzer. Further, it was 3 not possible to manipulate the data once taken, but only to dump it onto a secondary storage medium. As computer technology improved, small computers became more power- ful and less expensive. By the early 1960's, it became both feasible and desirable to attempt to interface a small digital computer to a nu- clear physics experiment 1). This was successful, and proved to be much more flexible than a hard-wired analyzer. Similar systems began to spring up in many places. As programs were written and used, it became apparent that the main value of a computer attached to an experiment lay not in its flexibility as an analyzer, but rather in its use in an inter- active mode with the experimenter. For the first time it became possible for the experimenter to provide flexible and elaborate checks on the ex- periment, such that the computer could inform the experimenter of ques- tionable operation or malfunction, or provide, on demand, a list of parameters which would aid him in determining the status of the experi- ment. Further, it became possible to analyze data as soon as it was col- lected, and compare the experimental results with theory. Parameters could be varied in both the theoretical calculations and the experiment, allowing more accurate measurements of the quantities of interest. There was a definite possibility that an experiment would proceed faster, since it might be possible at an early state to determine that the effect of varying one parameter was negligible, and could be ignored. Data analy- sis could be completed with the experiment, and questionable data could be retaken if necessary while the experimental configuration was still operative. There was, however, one serious drawback to this aystem. The com- puter was dedicated exclusively to the use of only one person at a time. m . s R v . . . x r . s _ . ‘ . a a .. O - ,1 a, Q s i s .. . s .. . ... . s s . i. . I A s .. . 7 u 5 . . . I v . l l . . g . .. 1 , u . . I . _ . . . _ .. . _ v . . . .. u . . . a; .1- a . t s . _ o r w . .o s . a The period involved might cover days or weeks, during which time no other person could use the computer. Since the experimentalists nor- mally discovered a few days after their experiment that they would like to vary another parameter with respect to the data they had collected, since they already knew how to operate one computer, and since they knew that they could analyze their data under an interactive system much faster than by sending it to a computation center for batch pro- cessing, computer usage became saturated. A struggle invariably devel- oped between the person who was using the computer and those who wished to use it for data analysis, data reduction, simple computation, and development of new programs to make use of the computer. Each time a new program was developed and added to the library of useful programs, saturation increased. Furthermore, it was apparent that the computer was not being used at full efficiency, since programs rarely used all of the resources of the computer, and for long periods various resources could be seen standing idle. Two or more people who required non-over- lapping resource subsets could easily share the computer, if a mechanism suitable for sharing were provided. Then “A" could analize his data using a graphic display and teletype, "B" could be reading cards and printing out the results of a computation based thereupon, while "C" could copy a magnetic tape. Such a mechanism exists, namely timesharing, based on the observa- tion that if in an interactive mode of operation, a computer is normally idle while waiting for a person to respond, then during this time it could easily be responding to each of several users, without appreciable degradation of response to any one. As a result, each user would feel that the computer is devoted exclusively to his use. The computer could still be providing a batch processing facility in the background of its 5 Operation, or any other processing which was not time dependent. This background usage would be degraded by the interactive usage, but would still be keeping the computer busy and productive. Timesharing schemes fall generally into three categories. These may be classified as follows: 1. Systems where all users are running independently, but where each is performing identical operations of computation, control, and in- put. Such a system would use the same program for all users, each dif- fering only in the unique storage area he was using. In this scheme, the program is reentrant, such that it always assumes one or more pointers to the current area of storage it is manipulating. This scheme is ef- fective where each terminal that may interact with the computer is identical in its capabilities and operation. Added flexibility may be provided by allowing the individual user to use his own programs, exe— cuting them from his storage area, to manipulate his data. However, any interaction between the user and his program must be handled by the main resident program, or monitor. Further, all allowed functions must be built into the monitor, and adding or changing a function is a non- trivial programming problem. A common example of such a timesharing system is that used by airlines for ticket reservations. Such a scheme is relatively easy to produce, since there is a finite set of operations allowed and desired. Its greatest deficiency lies in its lack of flexi- bility. 2. A second scheme is that of foreground-background usage, shown in Figure 1. Here an area of the memory is set aside for one or more foreground programs, which interrupt the program operating in the back- ground as necessary to perform a specific set of functions and return" Figure 1. Memory allocation under a foreground—background scheme of timesharing. The vertical column represents core memory. The monitor is used to provide all control functions. The area of core devoted to background timesharing is successively occupied by a number of pro- cesses, all limited to the size of the background area. The realtime foreground area may be occupied by any one of a set of processes, (or divided so that it may be used by more than one process), but any realtime process generally locks out all other realtime processes. Figure 1. L l g I I N J g V ‘ 4--——MON|TOR \/ CONVENTIONAL TIMESHARING WITH REALTIME 8 control to the background when done. Usually there is a method of check- pointing the current background program, that is, saving it on an exter- nal storage medium, replacing it with an extension of the foreground program capable of performing certain complex operations, and when there is no longer any need for this, restoring the background program and con- tinuing its operation from the point it was checkpointed. However, there is normally elaborate checking involved to insure that the fore- ground and background programs do not interact, as there would be great dissatisfaction on the part of the users if it was necessary, for example, to sort output because the foreground and background punched alternate cards or printed alternate lines. The big advantage of the foreground scheme is that of fast response to events, thus permitting evaluation of each event on its owh merits. The disadvantage lies in the difficul- ty of changing the foreground. In a situation where the foreground is used to monitor and control a process, such as the Operation of a manu- facturing complex (eg. oil refinery) or complex machine (eg. accelerator), where parameters may be varied but where the foreground program is rarely changed, this is no real disadvantage. However, in a situation where multiple foreground operations may be in operation simultaneously. starting and stopping asynchronously with each other, severe problems occur with respect to keeping track of free memory and making efficient use of the memory. 3. In the third scheme each user is performing operations com- pletely independent of all other usage of the machine. This scheme, while being capable of the greatest degree of flexibility, is normally found to be so difficult to implement that restrictions are placed upon all usage. For example, no user is permitted to change the state of the 9 machine himself, and must request all state changes from the resident monitor. 'This monitor must on each request, determine if the request is valid, if the Operation is permitted to the user, and perform other bookkeeping functions before actually going ahead'and performing the operation. A.typical operating'system could easily require 20,000- uo,ooo words of memory at all times Just for the resident programs. In addition, response time may be increased drastically such that, while still adequate for response to people, the response time is orders of magnitude slower than would be possible in a foreground system. This would seriously limit the usefulness of the system in an environment where events could occur thousands of times per second, such as in a nuclear physics laboratory. This thesis describes a new scheme of realtime timesharing, which, while permitting the flexibility of scheme 3 above,_also permits the response time associated with foreground programs, without many of the disadvantages of either scheme. It has the further advantage that the requirements Of a resident monitor are kept to a minimum, since the task associated with each user performs all of his monitor functions, in- cluding all communication with the external world (INPUT/OUTPUT or I/O). This is shown in Figure 2. This is of great advantage in nuclear physics experiments, where an I/O Operation might require a buffer of thousands of words, wasteful to make resident unless used frequently enough to Justify it. (The acquiring of a multichannel or multiparameter spec- trum can be thought of as such an I/O operation, where the storage a1— located to the spectrum is in effect a single buffer.) The operating nystem described is called JANUS, for the Roman god "...Of all going out and coming in,...also the god of entrance into a new division of time“ 2), thus the god of timesharing. ! sau- 10 Figure 2. Memory allocation under JANUS. As in Figure l, the column represents core memory, with JANUS at the bottom. Two tasks are shown, with the independent task address spaces twining through memory. Not all pages of a task need be in core at one time. The darkened pages of core are dedicated to realtime processes specific to the task which has the page. 2. THE USE OF CORE MEMORY In order to provide a perspective for the discussion of JANUS, I will first describe how various other timesharing systems Operate. Con— sider first the problem of sharing the core memory of the computer. How can more than one user make use Of the core memory without the possibility that an error can interfere with another user? (Subsequent figures are keyed to Figure 3.) The simplest scheme is to have only one user in core at a time, and all available core is his to use. This scheme is that used in Project MAC of the Massachusetts Institute Of Technology on an IBM 7090 computer (Figure h). It is also used in the Sigma 7 timesharing system developed by the Hubble Chamber Group at Brookhaven Rational Laboratory 3). The users program is brought into core from an external storage medium (swapped), and started. If the program did not inform the resident exe- cutive program that it wished to exit early, then at the end of a fixed time increment execution is stOpped, the current status is saved, and the program is swapped out to the external storage medium, freeing the core for the next user. This process continues for each user, until eventually the first user is swapped back into core, and his execution is continued. While this scheme has the advantage Of simplicity, the amount of time spent on nonproductive bookkeeping (overhead) is high, as the computer is idle while swapping occurs. To provide a reasonable response time to each user, the interval specified (timeslice or time 12 13 7.0338: s M33088 some s on sashes finances can» 5 mean: .szuos use: on» we can 23 305 $35.03 32803:. O» hem .n «Maura r H m>_5< m>_._.o>m N mmm: w>_._.30mxw mmmaoi O... >m§ 1h Figure 4. Memory allocation--proJect MAC. User execution alternates with swapping (the process where the program is transferred to or from memory). 16 quantum) must be short—~normalhy fractions of a second to each user. An example of the problems involved for such a scheme is demonstrated in the Brookhaven system, where the average time required to replace one block of 8192 words with another is 56 milliseconds. With the 1 second timeslice used, this provides 5.6% overhead, but with 6 active terminals as much as 5 seconds may pass before the computer can respond to the user. Three second response time is normally considered a reasonable upper limit. To provide this response time, a time slice of .5 seconds would have to be used, and overhead would increase to 78 milliseconds. Most terminal usage consists of the computer reading in a typed record, ex- amining it, possibly commenting upon an error. and requesting new input, a process1vhich normally takes much less than 1 second. In this case, the overhead would increase to a large value. Inter-user protection need not be considered, however, since they cannot get at each other. By constraining each user to a separate part of the core sVailable. such that more than one user mqyzfit into the core memory, advantage may be taken of the fact that most computers suitable for timesharing are capable of asynchronous I/O Operations. such that I/O may coexist with program execution. Thus one user may be executing while another is swapping in or out. The swapping I/O overhead is negligible as long as the timeslice is greater than or equal to the swapping time. However, a new problem arises--that of relocation. To make efficient use of the memory, a program should be capable of executing correctly wherever it may be located. Unfortunately, programs tend to reference absolute addresses. The simplist method of treating relocation is to ignore the prob— lem. This approach was taken by Dartmouth College with a GE 265 4) (and 17 more recently a GE #15) computer (Figure 5). Available core is divided into two areas, "high“ and “low" core. Execution is alternated between high and low core..as low core is executing, high core is undergoing a swap. However, a program loaded into high core will not run in low core, and vice versa. A bad Job mix can cause an excess of programs in one area or the other, with the result that either the low density area users get more computer time, or else the computer becomes inefficient, as time must be spent waiting for swap in the high density area. Ad- ditionally, any system library program which is available to all users must be kept in both a high and low version. Protection is provided by a bound register, which specifies the highest and lowest legal core references permitted. In order to treat relocation adequatehy, so that a program may run in different areas of core without revision, special hardware must be used: if the relocation operations were performed by software the overhead would be tremendous. There are three methods of automatic relocation used. Two of these are almost identical, with only a.slight difference in emphasis. The first of these methods uses a location register and relative addressing. Each address is relative to the referencing instruction. The actual reference is made by adding the location register to the ad- dress specified. The block of code will now operate anywhere in core automatically. This scheme has been most successfully applied to the SDS Sigma 2, which is not however used for timesharing. A second scheme uses a base register. Addresses specified are relative to the beginning of the program, rather than to the address of the instruction; otherwise operation is identical to that outlined above. 18 Figure 5. Memory allocation-~Dartmouth project. A new program is swapped into core memory while the current program is executing. However, an imbalance in the number of Jobs assigned to high and low storage causes a delay at the end of the third timeslice, as there is nothing to do but wait between USER 3 and USER l. 19 .m 95.3% AllmEfi. O ———3803 m> Domxm NN NM 20 This scheme is used on the IBM 360 computers (5’ 6), and in the PDP-6 7) (and now in the PUP-10) computers (Figure 6). There are two advantages of this scheme over the Dartmouth scheme. First, successive users are placed where there is room in core, without the problems associated with high and low core areas. Secondly, programs may be of variable length, up to half the available space in extent. Short programs can coexist with longer programs. This scheme further introduces the concept of pages-~a basic unit of core sise. In the PUP-10 each program consists of an integral multiple of 102“ word pages. Protection is again pro- vided by a bound register, the lower limit of which is also the base register. The third scheme of auto-relocation involves a memory map. First developed by Project GENIE at the University of California, Berkeley, using an SDS 940 computer, it is also used by the IBM 360-6? (8' 9), and JANUS in an SDS Sigma 7. Figure 7 shows the use in an SDS 9h0 computer, which uses 2048 word pages. Note that pages which are modified (M) while a program is active are flagged to be written back (W). Since for unmodified pages there is a true copy on the external storage medium, these pages are preferentially chosen to be overwritten thereby cutting down the number of swap operations necessary. The penalty for reducing the number of swap operations is the necessity of searching through a table of content-associated core pages, to determine if a page of a pro- gram ie currently in core. Programs execute in a virtual address space, connected to the real address space of the core memory through the map. Thus contiguous virtual pages need not be in contiguous real pages of core, but may instead by located wherever most desirable. Inter-user protection is afforded by a multilevel page protection system, used to 21 Figure 6. Memory allocations—PDP—é computer. Swapping occurs con- currently with execution, but the efficiency is higher than in Figure 5, as no limitation is imposed by the use of specific areas. Note that a significant part of memory is rarely or never used. 23 Figure 7. Memory allocation--project GENIE. Problems are initially brought into free core. When no more core is free (TASK h), those pages are chosen which are not currently in use and are identical to the cepy on the disk (unmodified). to be overwritten by new pages. The resultant fragmentation of Jobs is offset by the use of a memory map. Not until the sixth timeslice is it necessary toxwrite a page out to the disk (TASK 1, Page 5). This scheme is also used in JANUS. (The P numbers are pages within each user's address space. M signifies that the page is modified, W indicates that it must be written back onto the disk.) 0 3 llmmOo TIME 0 Figure 7. 25 protect and monitor the usage of pages. Under a mapped paging scheme, the usage of each page may be closely monitored-~closely enough, in fact, to permit demand paging. If the exe- cutive system can be informed whenever a page is referenced, and if the user can be locked out of some of his own pages, there is no longer any need of the uhole program being in core. Those pages currently being used can be brought in, and if a valid reference is made to a page which is not present (demanded), the current timeslice can be stopped, and conditions set up such that the demanded page will be available during the next timeslice for the program. Further, if a page is not referenced for some period of time, it may be safe to assume that it will not be referenced again for a while, and eased out of core memory in order to make room for pages in use. JANUS uses a mapped memory usage scheme, but with an important ad- vantage over that specified above. Much of the executive is unique to the task, rather than resident and common to all tasks. As a result, it is entirely up to each task if demand paging is to be used. Furthermore, any task's monitor may dedicate one or more pages, making that area resident until undedicated (Figure 8). These portions may be connected to interrupts, permitting realtime operations asynchronous to timesharing. These pages form resident islands, and timeshared usage maps around them. ‘All the advantages of foreground usage result, without the rigidity inr herent in conventional foreground-background systems. The added ability to solve problems which are actually larger than physical core, without requiring special techniques of the programmer, such as overlays, is a boon. in. 26 Figure 8. Gross memory allocation under JANUS, showing realtime pro- cesses. Using a large time scale. all short-term details of memory usage are omitted. Shown instead are areas dedicated for realtime processes. The blank area is available for swapping. The activation of four tasks is shown, each of which immediately initiates a real- time data input process. These tasks, in order of appearance, might be MOIRAE, JBCM, DATA TAKER, and JFCM. Note the interleaving of lineprinter output of tasks 1 and 2. The variable size scope dis- play is a measure of the amount of realtime buffer area required as a display is expanded to show relationships instead of detail. 60— 50— 40F 27 30- 20 E5 CORE (PAGES) —. :2":sz START or START or START or TASK 3 TASK 4 TASK l PLOT I ET— I“: In N D. Figure 8 . 3. BULK STORAGE Almost all timesharing schemes require, in addition to the core memory, additional bulk storage to keep programs, libraries, and data. In general, this storage is addressable, in that a specific block of storage may be located without searching all the storage medium. With certain exceptions, magnetic tape does not fall into this category. Instead, magnetic tape is a serial or ”stream” storage medium, where records relative to the current record may be referenced. As such, it is useful primarily as an archival storage medium, where data stored thereon is not capable of change without either destroying all succeed- ing records or requiring sleepy operation to move the data from a source tape to a destination tape, making changes as necessary in the new copy. This use is adequate for storing data, and for some functions such as holding lineprinter output. It is inadequate for working bulk storage in a timesharing environment where response time is critical. In this environment, addressable storage is required. Commonly used storage takes many forms, some of which are indicated in Figure 9. Shown also is the typical access time and range of storage capability for that form of storage, as well as cost. Cost and storage are in terms of bytes, a byte containing 8 bits of data. It is readily appar- ent that as access time decreases the cost increases. This factor of cost/byte is what normally sets an upper limit to the practical storage capability for a particular form of storage. 28 .... 29 O_ . Suva owssopu Mann users: mo noaauauoaosssmo $038 m§340> so_ mo_ n9 eo_ no. . _ _ a _ _O woo>onm I l 00.. 88031 I. >m02m2 mmoo 5E mmmooa. m1:0. mzano> 8% 00m - _ r _ _ wagon anew u machddjd I 00.9 .m enemas (SHVTIOCI) qu uses 3o Timesharing aystems require an immense amount of bulk storage, normally approaching infinity as closely as possible. In additon, it is normally desired that access time be as low as possible. To be prac- tical in terms of cost, it becomes necessary to build a bulk storage structure, using a set of storage forms of differing characteristics. Thus, one uses a fast, low volume medium as well as a slow, large vol- ume medium. This storage structure may take three possible forms, of which the linear form is rarely used in comparison with hierarchical and hybrid structures, at least for timesharing usage. The most easihy understood structure, however, is the linear structure, shown in Figure 10. Here the storage is an extension of the core memory, but suffers from the difficulty and inconvenience of exe- cuting programs directly from the storage. Its advantage lies in the fact that there is a unique address associated with every piece of stor- age, both core and bulk. Operation consists of cepying blocks of data into core memory, manipulating them, and then replacing them. The opposite extreme is the hierarchical or pyramid structure (Figr ure 11). In this scheme, unused sets of data are kept at the lowest (large capacity, slow accessibility) level of storage. If referenced, the set of data is brought into core, and, if necessary, later written back. The system executive does automatic accounting of usage-~if a data set is used frequenthy enough, such that time spent accessing a level of storage becomes significant because of frequent references, that data set is copied through core to the next higher level of storage. Depending on the algorithm used, the original block of storage may or may not be freed (depending on whether or not the storage is referenced 31 .oomns unsaved aaeuqoneusfi as non seduce ommaoun mesa .pmwaen an“: successes sad» ensued. .oasoosuau owdAOpe Hmonsoushoam .Ha oasmfih {medium mmmmood. m..__n_ r mmzeo ”.3: she r can (I r 23% >mo_>_ms_ mmoolw A.naommsp o\H sapmpsoeNolsos use .cssposnam summons mass amosaq .OH easwuh E052 MES, h mo._._mo_mn_ kmw>>0n_ mow 02E >._._mo_ma mm>>o.._ OH ..oz_v_._._m0_ma ...mwzwi .mmfiu mozoa a mo .wqflamvemoe huwaoamm .nH unawah 2:...2430 20 _ .Sow xm owmdwmog a ‘ an: $32 owm535 doggone mo mama one .333er mags. mo cc: .3903 H33? .3 mafia o n .. .v v .n n a ~ llwzc. u _ xmg. 131C371 luaouud ‘- mmcz TASK 2 Fwfi DRNE /' SUB TCP 2 STREAM INPUT FILE —. TCP TCP l 2 JANUS 4 KC 4 Figure 18. 63 successive locations are generated, and addresses are incremented. It is therefore necessany to have a location counter (L0). (This is the I basis of all assemblers.) It is conceivable that, under certain cir- cumstances, it is desirable to generate code to be loaded in one place, but capable of being moved to a specified place for execution. This would, for example, be of use in overlay programming. We may thus readily convince ourselves of the utility of both a load location counter (LLC) and an execution location counter (ELC). Many assemblers have only a LG, some have both LLC and ELC. Under JANUS, each task is normalhy in the same address space as all other tasks, implying an overlay structure. This is, however, no problem, since each task is usually the result of a separate load. A problem does exist, however, with respect to the unmapped address space used by interrupt routines. All unmapped storage is in the same address space, independent of the spaces of the controlling tasks. In addition, in a task it is necessary to have intersections between the mapped and unmapped areas. it may be seen that it would be desirable to have mapped and un- mapped location-counters (MLLC, MELC, ULLC, and UELC). Furthermore, it would be desirable in a decentralized system, such as JANUS, for the system loader to be capable of relocating unmapped code completely in- dependently of the mapped storage, Optimizing the usage of real core for dedicable pages. As yet JANUS is not capable of these Operations due to the lack of such a flexible assembler-loader. It is necessary to write tasks using the STMBOL assembler provided by SDS. Since this has only an ELC ($) and LLC ($3), it is necessary to perform certain coding tricks to generate 64 mixed mapped and unmapped code. The most distasteful of these, for aesthetic reasons, is the necessity of allocating unmapped pages for interrupt routines before assembly, rather than at load time, making JANUS much less flexible than it would be, given a good assembler- loader. However, JANUS is still sufficiently useful to be adequate for many operations. In order to include both mapped and unmapped storage, as well as intersections, it becomes necessary to use one counter for a mapped location counter (MLC), the other for unmapped (ULO). Since a task has a unique address space, it is necessarily loaded as one block, without overlays. This suggests that the SDS SYMBOL's LLC be used as MLC; thus ELC becomes ULC. However, one must take care that, in setting ULC so that it will track the unmapped addresses correctly, the relocation of the task as a whole is included. The alternative is to define each unmapped symbol as the mapped location plus a suitable bias. While all tasks are normally independent, there are exceptions. The JANUS concept permits tasks to communicate. This may be through the resident, common to alltasks, or it may be at a higher level of ab- straction. Higher level communication between tasks will generally mean that at least some address space is common to both tasks. Further, any task may start subtasks. In these cases, it will generally be true that the master and subtasks will be generated as one load. This load will then be studded with tasks, which need overlay each other at least in.part (see description of task control page below). In this case, using SYMBOL, LLC must be the LC for the whole task, while the ELC is used for each task. As a result, unmapped storage has to be referenced 65 without modifying ELC or LLC, forcing one to use references of the form of LC+bias. Since in this scheme the tasks may be almost completely inde- pendent, it may be seen that the concept described above, with respect to ELC and LLC, can be extended in an openrended process toinclude a unique ELC and LLC for each address space which might be used by a task. The case of unmapped and mapped counters can then readily be extended to include UNMAPPED, MAPPEDl, MAPPED2,..., MAPPEDN, as well as multiple computers using the same memory, even when they have different word size. As far as this is concerned, JANUS is in effect a two-computer system, where the unmapped computer is independent of the mapped computer, with different usage. It is possible to have not only an openrended set of mapped LC's, but also an openrended set of processor LC's. These would include the 10?. For flexibility, it should be left for the programmer to define the symbol he wishes to use for each LC. 10. JANUS AND BPM: A COMPARISON Perhaps one of the best ways to evaluate a specific computer operating system is to compare it with another operating system. Let us therefore compare JANUS with one of the operating systems provided by SDS, the Batch Processing Monitor (3PM) 13). This must be a quali- fied comparison: whereas JANUS is a realtime oriented system, with background capabilities, BPM is, as its name implies, primarily a back- ground oriented.system1vith some realtime capability. The SDS BPM has been selected because it is the most advanced system yet released by the manufacturer. It is as valid a comparison to make as any other, since there is no other computer system like JANUS. Consider first that there are three basic means of acquiring an Operating system. The easiest and fastest method is to use the manu- facturer-supplied operating system with.no changes not supported by the manufacturer. For most cases,this is the best approach, as the manur facturer will continue to improve the system for the customer. The limitation is that the user must live with the system supplied, and with any inefficiencies in its operation. A second alternative is to modify an operating system supplied, to introduce nonstandard functions, or to counteract some inefficiencies in operation. This is the most attractive approach when nonstandard func~ tions are desired, because one is building upon a working mystem, and the implementation is speeded. This approach turns into a dead-end 66 67 easily, because of,a hidden fault. By introducing a nonstandard func- tion into a system, the system itself becomes nonstandard, and will no longer be supported by the manufacturer. The customer is forced into one of two paths-~either he is confined to an operating system which be— comes more and more obsolete with time, as the manufacturer upgrades and improves the system or even replaces it with more powerful systems, or he must be prepared to repeat his work each time a newer version of the system appears. In either case, the consequence of the initial expediency becomes an unending source of annoyance at best. The.solur tion is thus satisfactory only in a stable environment. The third alternative is to build a completely independent system as in JANUS. In doing so, one cuts oneself off from all support by the manufacturer and sets himself an extended programming effort, but in return ends up with a system optimized for the intended usage. As a manufacturer-supplied system, BPM must of necessity be ex— tremehy general in applicability, so that the first situation described will apply to most customers. As a result, there is a tendency toward a comprehensive inclusion of all possibly desired function. Two con- ditions result: the monitor is large, requiring extensive core and disk storage, and slow, requiring a large partion of time in determining which function is desired, and in doing that function. In addition, SDS manufactures“ a second computer (the Sigma 5) which is identical to the Sigma 7, except that it lacks the map, access protection, and certain instructions (notably the byte immediate and cone vert instructions). As a result, all Sigma 7 software is downward com- patible, able to run in the Sigma 5 also. No advantage is taken of the added power of the Sigma 7. 68 Because of these differences, it is difficult to compare specific features of JANUS and BPM. However, general comparisons in various classes of usage are possible. Perhaps the most striking difference between JANUS and BPM lies in the contents of resident storage. JANUS contains a minimum of resi- dent storage, devoted to the minimum number of primitive routines neces~ sary to resource management. Conversely, BPM contains many high level functions, most of which are a convenience rather than a necessity. Inr deed, many of these functions could be deleted, and instead provided by library routines. For example, both JANUS and BPM keep track of time of day in resident storage. Under JANUS, tasks are informed where to find the information if they ask for it. Under BPM, there is a special resident routine which may be called, and which, after ex- tensive checking as to the form of the request, physically transfers the data to the area specified by the user. Again, BPM provides two files for compressed I/O (M:CI and M:CO, used for Compressed Input and Compressed Output, respectively). Use of these files causes automatic translation between compressed mode (where text is compressed by re~ placing strings of blanks with a blank count, all bytes are compressed to 6 bits, and punched onto cards in binary), and BCD, through resident routines. Anyone desiring to use these functions could as easily call upon a library routine, with no loss in speed, and with an increase in available core if they were not used. Under BPM, all I/O is done through files, each of which has as- sociated with it a Device Control Block (DOB), which is 90 words long. Since there are 17 resident DCB's, 1.5k of resident core is dedicated to this storage, much of which is again superfluous. (The Basic Control 69 Monitor, an earlier SDS monitor, has 6 word DCB's.) Included are such parameters as the file name, tab settings, file keys, etc. Many of these parameters again have no real Justification for inclusion in the resident monitor; If such quantities are used in JANUS, they are unique to a task, carried around with it, and not a system convention. Let us now turn our attention to resource management. In this respect, JANUS and BPM are so divergent that little comparison can be made. While JANUS freely allocates resources to tasks upon request if at all possible, it does not set any restriction on usage. 'By cone trast, BPM is extremely paternalistic, thereby constraining permitted operations. For example, BPM requires that each I/O Operation reference the file associated DCB, which includes an account number (presumably for billing purposes), a password (presumably for file security), ex- piration date, and read and write account numbers (again presumably for security). Under JANUS, any task which references a file knows the name of the file, and tasks which have no need for the file do not bother with it. If the file is write protected (e.g., a library disk file) and is accessable to users, the task provides the necessary se- curity. This is a much simpler (and faster) process. Both JANUS and BPM have functions to allocate and free core memory. However, while JANUS automatically allocates free pages for a task during a timeslice and permits a task to get or free diskpages, the BPM both permits and requires these operations of the slave-mode user. (In JANUS tasks with demand paging, the function of demand allocation is easily provided by the demand paging algorithm, and if desired the func- tion of freeing pages within the address space is easily implemented.) Realtime or foreground processes are exactly what JANUS is 70 oriented and designed for. 3PM also has a foreground facility, and monitor functions such as M:MASTEB, which permits a user to enter master-mode if his is a foreground job. A.foreground user has two op- tions under BPM. He may use the hardware structure of the computer for speed, but act independently of the BPM. In this case, he is not per- mitted to use any of the BPM functions, such as I/O, from his interrupt routines. In order to do I/O from the interrupt routines, all inter~ rupts must pass through 3PM, so they can be monitored. The return from such an interrupt routine requires three RAD operations, and thus 80 milliseconds. This time would be excessive for most experimental applications. One of the most important aspects of a realtime system is security-not in the conventional sense of privacy of data, but instead in terms of the freedom from the possibility of an individual introducing a.program which destroys the system, and the realtime along with it. If this can happen, intentionally or not, no one performing a realtime process will trust another to use the computer in the background, es- pecially if the process involves accumulating data over a long period of time. If this situation can occur, a multi-user system, no matter how elaborate, is useless. Under JANUS, one invokes a specific task from a user library. (While it is possible for tasks to be loaded from card decks using a special task, this is understood to be strictly a debugging feature, and not for general usage.) No task is added to the library until it has been thoroughly debugged to the satisfaction of all concerned. While a system-destroying error could lurk in any task, it is a rare occurrence. No task can be told to destroy the system, nor will any 71 task permit the execution of a user program under its control which can cause the destruction of the system. Such operations are not allowed under the JANUS design philosophy. By contrast, RPM is not at all safe. Programs can be written which will cause the BPM to overwrite itself in any number of ways, and thus destroy itself. A user can declare himself as a realtime process, enter master-mode, and do untold damage. It is even possible to provide a set of control cards which cause all system files to be irrevocably freed, thus destrqying the system. Indeed, this is sometimes the only way that some Jobs may be done, using limited resources. For example, in using RPM with a 1.5 Mbyte RAD, an operation as simple in appearance as assembling the FORTRAN compiler from a magnetic tape requires so much disk storage that the system must be destroyed to accomplish it (as an aside, this "simple" process necessitates the use of approxi- mately #70 distinct cards, each of which must be correct and in the correct sequence). As a final comparison, any time it is considered desirable, the JANUS JBCM/JFCM tasks could be upgraded, by the addition of suitable additional functions, into a JBPM, or JANUS Batch Processing Monitor, without, of course, the realtime or other destructive characteristics of BPM. In that case, JANUS could easily timeshare several JBPM's simultaneously, Just as it now can do for the JBCM/JFCM. ll. MEASUREMENTS Since computer logic signals have two values, it is possible to connect a logic signal to an electrical meter and directly measure the fraction of time the logic signal is in one state or the other. Cali- bration is relatively simple: with the logic signal in the "0" state, the meter movement is adjusted to read ”0” exactly, in spite of the probable existence of small currents. If we now switch the logic signal to the "1” state, it is possible to adjust a variable resistance in series with the meter to cause the meter to read exactly full-scale--if necessary, these operations may be iterated for a higher degree of ac- curacy. Furthermore, if a meter is chosen which has a high sensitivity (such that a low load upon the signal is effected) and a 0-100 scale (such as 0-100 microamperes) it is possible to read the average time that the logic signal spends in the "1" state directly in percent, and short term fluctuations are integrated out by the meter. These measurements are accurate to the accuracy of the calibrated meter, nominally five percent. By a Judicious choice of logic signals, it is possible to measure various operating conditions, and observe the effect of varying various parameters. This was done on the MSU Sigma 7. As timeshared JANUS runs under the map, and realtime JANUS runs unmapped, the fraction of time spent in mapped mode is a measure of the relative weight given each mode (note that the Swapper is an unmapped realtime process). Consequently a meter was attached to the signal 72 73 MAP, a level set while the computer is in mapped mode. Similarly, under JANUS, slave mode is used for all problem solv- ing (production), master mode is used for all control (overhead). As a result, the signal NMASTER was used to monitor actual production opera- tion. JANUS uses the wait'instruction only once—~in the Jobchanger, under the condition that no Job is ready to proceed. The associated signal HALT provides a measure of the completely nonproductive overhead. A fourth signal, PREl, while not actually useful for‘system para- meters, does provide a measure of the efficiency of code. The signal is raised once and only once for a fixed duration, in the course of each in— struction execution. By choosing an instruction with a well-defined time, such as branch (1 microsecond) and providing a timing loop, it is possible to calibrate the meter directly in instructions/second. The most important factor, in a realtime oriented system, is the time required to service an interrupt. For other than clock interrupts, which are of lowest priority and which are frequently inhibited, the time required to service an interrupt is hardware, rather than soft- ware, limited. This time is 6 microseconds + the time required to com— plete the instruction interrupted, if there is no higher priority inter- rupt active: 6 microseconds + the time required to complete servicing all higher priority interrupts if any are active. While there are patholigical situations which do cause interrupt inhibition, these are demonstrably rare. Similarly, 4 microseconds are required to exit from a realtime inr terrupt process. (Compare with the SDS Batch Processing Monitor 13), where an exit from a realtime process may require as much as 80 7h milliseconds.) Actual metered measurements are more difficult to make. because of the rapid fluctuations the system undergoes with time. However, it is possible to provide quantitative numbers in certain relatively stable situations, notably those which are not I/O limited. 1. Single task active, requiring no swapping. An overhead of 2% has been measured, and is entirely due to timeslicing the single task to provide an entry for an asynchronously activated task. 2. Multiple tasks active, requiring no swapping. Times are 8%, or Just four times those measured in case 1, attributed entirely to the fact that the time quantum is four times longer for the single task case. 3. One task active, performing demand paging for pages not in core. Times vary from 5% overhead for well behaved programs to as much as 50% for some cases, notably processors (such as the JBCM/JFCM Loader) which are required to physically move multipage blocks of storage around within the task's address space. 4. Two tasks active, swapping required. Times vary from 5% to 20$ overhead, the difference between case 3 and case 4 being attribur table to the high probability that execution of one task is proceeding concurrently with the swapping for the other. 5. Three or more tasks, all requiring swapping. In general, overhead approaches 100% in this case. This problem and a possible solution will be treated in more detail in Chapter 11. 6. Realtime scope display. These scope displays are unbuffered, and must be refreshed periodically by the computer. They may be imple~ mented by computing the display points from a small data base (requiring 75 little core but much computer time), by having a large data base ins itialized in such a form that it may be written directly out to the scope (requiring more core but less computer time), or a mixture of the two. These displays are normally refreshed 20 times a second to avoid screen flicker disturbing to viewers. Two cases are of interest, one involving a static display (initialized storage), the other a dynamic display (computed display). A. Static display. The data analysis code MOIRAE, displaying 4096 points, plus three dynamic vectors and several characters-~60% of the computer time is used to generate the display. 3. Dynamic display. The game code SPACEWAR, displaying 100 static and 500-1000 dynamically generated points (position computed from orbit equations as a function of real elapsed time)--lO-30% overhead. It is readily seen from these examples that multiple displays would generally tie up the computer entirely, and the need for self- buffered displays is indicated (such as storage scopes). 12. CONCLUSIONS JANUS is finally operational, and is used for significant parts of each day. The principal delay to fulltime Operation has been the lack of systems programmers available to introduce additional capabilities to the JANUS ayetem which have not as yet been implemented (examples of unimplemented capabilities are the lack of teletyps and magnetic tape handlers in the JBCM). The other difficulty is the necessity of re- casting existing programs (especially realtime data acquisition) into a timesharing form. These problems are, however, being met, and JANUS will approach greater permanence as these implementations occur. One of the most striking conclusions that can already be drawn from observed operation of JANUS concerns demand paging. I feel that JANUS has conclusively demonstrated the value of demand paging in a batch processing configuration as a memory expansion device. By the use of a relatively inexpensive map and RAD, one can simulate the existence of a much larger, and more expensive, core memory. Since in any in- stallation the majority of problems will fit into core, the use of demand paging introduces no essential overhead. For the few problems which do not fit, there must be a mechanism provided for execution, either through overlays, Job-chaining, or through some other means. _Demand paging ex- tends memory--no additional knowledge is required of a user in order to demand page a large Job. The efficiency of the Job execution is his problem, and it is relatively easy to explain how to optimize execution. 76 77 Any other method requires the user to introduce a large number of con- trol cards, and to have a thorough understanding of the structure in- volved (requiring that more systems programmers be available to answer user questions). The other side of the problem, system programming, is of comparable difficulty under either method. In general, resident buffers are required under demand paging, but the necessary amount of space in the monitor may be prOvided by being able to delete control card processing relative to overlays, and hr deleting core allocation functions. A loader capable of segmenting overlays is not necessary. and the effort required for its generation and maintenance could be directed elsewhere.) However, the demand paging currently used in JANUS is impractical for use in a timesharing environment where more than two or three tasks are active. The difficulty with the JANUS implementation is the lack of sufficient history to permit adequate Judgements as to usage of demand- able pages. As JANUS permits each task to perform its own demand paging, it is’a relatively easy matter to test different demand paging algorithms by modifying some standard task. This has not been done as yet, be- cause of a lack of available computer time, and the existence of higher priority problems. The problem, and a possible solution, may be simply stated. Under JANUS, all memory or usage exists for only one timeslice. In demanding a page not currently in core, jobchange must be effected. Only those pages referenced the last time may be brought into core the next time. If, as is frequently the case, three successive instructions reference three different pages, in a hard-swapping environment only one instruction will be executed each timeslice. By the time the third 78 instruction is executed, the first is forgotten. Instead, what is necessary is to keep a record of each page of a task, with a memory of how recently the page was referenced. The demand paging routine, in ad— dition to setting the "used this time" bit in the task control page, would also have to set the corresponding entry of this table to "refer- enced this time". At slice start, the task must reset each entry back by one. At task end, all entries must be compared, and the N most re- cently r'ferencmd pages (where N is to be empirically determined, but probably about 10) must be flagged in the TOP as "used this time". The significance of this now changes from "used this time" to "used recently enough to Justify its presence". An alternative, and more suitable, method would be to flag up to N pages as above, but ignore all references which occurred more than M timeslices ago, where M is also to be em- pirically determined. Similarly, the usage of core memory pages under JANUS does include a two-bit (four level) memory as to how recently the page was used. This is an inadequate memory, but unfortunately is so deeply imbedded in JANUS that it would be extremely difficult to change. The point would be well to remember, however, in future implementations. (Crude measurements made since the bulk of this thesis was written indicate that this approach has definite merit. With the case of four identical tasks operating concurrently, total running time was within 10-20% of the time required to run the same tasks serially, using this method. Using the previous approach, times differed by loo-200%.) The JANUS capability of timeshared monitors, each capable of dedi- cating realtime processes as necessary, has been successful. Many system functions may be greatly streamlined, to produce an efficient system 7.9 task. While suffering from the necessity of using two independent ad- dress spaces, one of which (unmapped) is unique, it is possible to over— come the problem by the construction of a relocatable task loader, pro- vided that the multiple address spaces can be referenced in the process generating the relocatable tadk. This will doubtless be a limitation in the future, but is not yet a problem. The use of a memory map is a great advance in computer design, making possible demand paging and therefore, more efficient use of core memory. In all probability, more and more computers will have a map available. As the demand paged memory provides one of the most flex- ible file systems available, I foresee that available address spaces will increase to a large value, on the ordpr of 100,000,000 words and more, even though it would be impractical to have actual core memories of this size. This will be true especially of small, nonrtimeshared computers, such as are used for batch processing, research, and process control. Finally, JANUS works as defined. There is room for improvement, but more study of specific inefficiencies is required to optimize the computer usage. It should be possible to make JANUS as efficient for many active tasks as it is now when there are only two or three active. B IBLIO GRAPHY 1. 2. 3. 10. 11. 12. 13. 14. 15. BIBLIOGRAPHY On-line Computers for Research, Nucleonics, January-March 1967. Dictionary of Classical Antiquities, Oskar Seyffert, Meridian Books, 1957. Users Manual: Brookhaven Scheduler for Data Terminal Network, B.J. Shepard, April 10, 1968. Timesharing Systems Manual, General Electric Corp., May 1966. An Advanced Computer—Based Nuclear Physics Data Acquisition System, H.L. Gelernter et. al., Nuclear Instrument; ggg Methods 5“ (1967) 77-90- Initial Operating Experience with the Yale-IBM.Nuc1ear Data Acquisition System, M.W. Sachs et. al., Internal Report 32.,2g, Wright Nuclear Structure Laboratory, Yale University. Time-sharing: A Computer for Everyone, Jeffrey N. Bairstow, Electronics Desigp, April 25, 1968. System/360 Model 67 Timesharing Systems Preliminary Technical Survey, IBM form 020-1647-0. IBM System/360 Model 67 Timesharing System Technical Summary, IBM, August 18, 1965. IBM System/360 Operating System PL/l Language Specifications, IBM form 028-6571~h. A Scheduling Philosophy for Multiprocessing Systems, Butler W. Lampson, Communications g; gh2,A§M 11 (May, 1968), 347~360. SDS Sigma 7 Computer Reference Manual, November 1967. SDS Sigma 5/? Batch Processing Monitor Operations Manual, January, 1968. SDS Sigma 5/7 Basic Control Monitor Reference Manual, May 1968. Basic Language Reference Manual, General Electric Corporation, May, 1967. 80 81 General References A new remote-accessed man-machine system, General Electric Corporation, (from Proceedings, Fall Joint Computer Conference, 1965). SDS Sigma 5/? Batch Processing Monitor Reference Manual, July, 1968. APPENDICES APPENDIX A. Glossary of Terms Absolute--any datum (including instructions) the value of which is independent of its location in a storage medium. Active--the word is used in two different senses, depending on context. A task is active if it is not on.wait status, when discussing scheduling. Also, a task is active (current) if the current time- slice is assigned to it. Address space--the full range of addresses which may be accessed. Algorithm-~the specific procedure used to implement a given process. Associative addressing~~a method of referencing a datum by content rather than by position. The datum consists of a key (the con— tent referenced), and the associated information. Background--a timesharing technique in which programs can be run con- currenthy with realtime processes in those periods when no realtime activity is required of the computer. Byte--a unit of data, consisting of 8 bits. A.byte is identical to one character. Channel-~a means of initiating a single I/O data transfer which then automatically runs to completion without needing further program intervention. Clock interrupt-~the Sigma 7 has two standard realtime clocks, one "ticking" at 500 Hz, the other at ZKHz. These can be used to time realtime processes. Datav-a set of information, other than instructions, used in performing a process. Dedicate-~changing the usage of a resource from general availability to a specific usage. For example, under JANUS, a page of a task may be dedicated into a page of physical core memory, such that the physical page is used only for that task, rather than being available for all tasks. 82 83 Double precisionr-the use of two words of computer memory to maintain a single datum. The larger size permits a greater information content to be provided than under single precision (one word). Foreground—~a timesharing technique in which realtime processes can be run concurrently with other processes, interrupting the back~ ground as necessary. Honest task--one which is careful to manipulate only those resources which belong to it, and which does not indiscriminantly affect those resources which belong to other tasks. H/t disk--(head per track). A.diskfile where a read-write head is positioned over each track, thereby requiring no head movement on an I/O operation. Inactive task--a task which can temporarily perform no operation be- cause it is waiting to be synchronized with a realtime event, such as the completion of an I/O operation. Index register--a hardware feature permitting automatic arithmetic operations during a reference to an address, such as the addition of a displacement to a base address. Interrupt—~a hardware feature which permits the computer to change states in a rapid fashion-~interrupting the execution of one pro— cess in order to execute a second process. Intersection-~an area of storage common to two or more address spaces, capable of being references by different names from each address space. I/O—~the abbreviation for Input/Output; the process of transferring data to and from the computer. Location counter-~a datum within an assembler to keep track of the address of each datum generated (including instructions) relative to some specific point such as the beginning of the assembly. Used to generate relocatable binary code for the loader, and to define addresses. Map-~a feature permitting the automatic translation of an effective address to the real address used to reference a storage medium. See also relocation. Mask-~a specific bit pattern used in performing logical operations under computer control. Master-~the mode of computer operation wherein all operations are per- mitted. Master mode is used normally for control operations. Memory mapping-~the process of using a map to translate addresses in the computer core memory. 84 Monitor--a program designed to supervise the usage of the computer in executing a problem, and which provides the control functions necessary and sufficient to that problem, or to a set of problems. Overlay--a method of generating a program for execution in such a manner that independent subsets of the program may alternately be executed within the same address space, and be capable of referencing common areas. Page--a natural unit of memory which is machine dependent. In the Sigma 7, one page contains 512 words. PL/l-a relatively recently developed highelevel programming language, containing many of the functions provided by FORTRAN. ALGOL, COBOL, and other special purpose languages in a fashion that per- mits the statement of a problem in a manner much more powerful and flexible than in any single special purpose language. Pointer-~a datum indicating the location of a set of data, referenced instead of the data set itself. Realtime--a realtime process is one which is initiated asynchronously with respect to the normal flow of machine operation. A realtime process is normally associated with an interrupt. Begister—-a.piece of hardware, normally consisting of an ordered set of bi-stable elements, capable of operations in addition to a storage function, such as arithmetic or logical operations. The time required to access a register is much less than that required to reference core memory. Relocation-~the capability of a datum to have, in addition to a value, information as to some other quantity to*which the value is related. Resident~~that portion of a monitor or supervisory system which is kept permanently in core memory. Slave--that mode of computer operation capable of being completely controlled as to permitted Operations. Computational functions are permitted, but control functions are not. A mechanism is provided for a slave-mode process to request of the monitor that a specific control process be performed. Task--a set of processes capable of being timeshared as a unit, in- dependent of any other usage of the computer, and containing those monitor functions necessary and sufficient to its Operation. Task control page (TGP)—~a block of storage under JANUS which is always located in specific addresses in the address space of a task. This contains the status of the task, including trap and memory page usage. Also referred to as the state vector for the task, and is unique to the task. 85 Tum-address computer-a computer where each instruction specifies both a source and a destination, as opposed to a single effective ad- dress, in addition to a process to be performed. iflflg—_ APPENDIX B. JANUS Reference Manual Some features of JANUS are of interest primarily to programmers who intend to build tasks to operate under JANUS. As has been noted previously, there are no aids to building a task currently available. While many of the computational functions desired of a task may be writ- ten in ahigher language, such as FORTRAN, it is still necessary that all monitor and control functions be coded in assembly language. This re- quires an understanding of specific functions available in JANUS, and how they are used. The following sections describe the properties of JANUS on a cod- ing level, and the ryetem functions available. They are ordered in terms of memory, disk, and address space usage, and then proceed into task com- munications and realtime Operations. The rather curious names which are sometimes used result from the necessity of compromising between the need for helpful mnemonic names and the SYMBOL defined constraint limiting a symbolic name to 8 charac- ters or less. B. 1 Resident Tables and Lists JANUS concerns itself primarily with certain tables and lists kept for the purpose of bookkeeping. I now inteend to provide a list of these, 86 87 along with their use. Names may be mentioned which are as yet undefined in this thesis; however, because of the interrelated nature of JANUS, it is necessary to start somewhere. Table elements are almost always exact- ly one addressable base in size, such as word or byte. This is because, when an element may be referenced from more than one place, including an interrupt routine, it is necessary to reference it in a way that is not interruptable, either by setting a flag that it is not to be touched, by perfdrming the operation in an instruction which can not be interrupted, or by inhibiting the interrupt. JANUS is written to take advantage of realtime, thus interrupts are inhibited as little as possible. As much as possible is done with single noneinterruptable instructions. However, there are certain abnormal conditions which may require ab- normal action, including inhibiting all interrupts. These include actual hardware errors (e.g. memory parity), software errors (e.g. traps from unmapped code), and one additional special case. The latter results from having a number of lists partially resident, with the rest of the list existing on the disk within a task. Under normal circumstances. the non-resident task (the Housekeeper) is brought in to tidy up. How~ ever, in freak cases, it may be discovered that a list is full or empty, with no recovery procedure available for the requester. In this case, a resident routine is invoked--the Troubleshooter. This routine sus- pends all functions while bringing into core enough of the Housekeeper to straighten out the difficulty. For the duration of this process, all interrupts are inhibited. However, this is definitely a last ditch ef- fort on the part of JANUS to stay viable, and thus happens extremely in- frequently, provided all tasks and interrupt routines are correct and honest. Any practice which is not completely honest, expecting certain 88 timing relationships, etc, may work 99% of the time..the lOOth time an error will occur, frequently resulting in the destruction Of the opera- tion system. The method of getting around this problem is discussed below. This chapter will consider those tables used in timesharing tasks. Let us consider first the one non-resident table, the Task Control Page (TOP). This page is always the first unique page of the task, and is of fixed format. It contains all information as to the current status of the task which is of interest to JANUS. This includes pointers to rour tines associated with traps, program status, Signals, and the task USAGE table. The task USAGE table consists of a word (MAXSIZE) specifiying the size of the task under the map in pages, and the list (USEPAGE) of pages and their attributes. Each of the latter is in mapped sequence; that is, the Neth entry corresponds to the Neth page of the address space. An entry is null if diskpage O is specified, as this page is inaccessable to all tasks. The entries are designed to take advantage of the INTerpret instruction, such that the first four hits are usage information, the next twelve are general information, and the last sixteen are the disk- page address. The attribute bits have the following significance: 0. Absolute code (ABS) page. This page may be dedicated at any time, and bits 8-15 of the entry will specify the unmapped page to load this page into, if bit 0 is set. ABS pages will be loaded into core each time the task is active. 1. Virtually dedicated page. This page must be in core for the duration of any timeslice the task is active. 2. NEEDbNEXT. Used primarily in a demand paging task which cannot proceed until that page becomes available. 89 3. USED-LAST. Again used in demand paging, this bit is set during a timeslice if the page is used. If not set, and no other bits are set, no effort will be made to bring in the page. Bite 2 and 3 are cleared at the start of each timeslice. b. WRITEBACK. Indicates that this page is modified regularly, and must be unconditionally written back on the disk. 5. Not used. 6-?. The.Access Protection Lower Limit (ACL, =O-3) which may be used for this page without error. 8-15. Used if bit 0 is set, as described above. Otherwise ig- nored, except at task generation and destruction. At generation, the page will be copied onto a new diskpage and the copy used if this byte is non-zero. At destruction, only if this byte is non-zero, will the page be freed. This allows multiple use of an absolute task, since all nonemodifiable pages used will be the original copy of the task, and are shared by all task copies. Only the volatile storage will be different for each task, and efficiency may be greatly improved. The convention used is that, if the task allocates a page it did not start with, bit 14 is set, while if a copy of the page is used, bit 15 is set. The table described above is the only one of which it is necessary to have knowledge in order to write a task. However, other associated tables are described in order to allow one to become more familiar with the operation. Two of the resident tables are required only because the hardware registers are not readable. These are the access protect image (ACIMAGE) and the map image (MAPIMAGE). These are respectively 2—bit and 8-bit entry tables, each with 256 entries, and are in map sequence. 90 Another table is the image of unmapped core (TRUECORE). This is again set up to take advantage of INTerpret, as was the usage table. 0. This bit is used by the troubleshooter as a flag for pages it is using. 1. This page is in use by the currently active task. 2. This page is being subjected to swapping. 3. This page is part of the next task. 4. This page must be written back onto the disk before being used for anything else. 5-6. Unused. 7. This page is dedicated to swapping, and may not be used for ABS pages. 8. This page contains a TCP. 9. This page may become dedicated, and should be used only tem- porarily. lO-13. Dedication level for this page. 14-15. Reuse priority for page. 16-31. Diskpage currently residing in memory page. The last table actively associated with swapping is the stack of Task Control Pages (TASKPAGE). Again a table of one word entries, this is the only reference to a task which is kept resident. Bits used are: 0. This task must proceed immediately, regardless of the time- sharing ring (RUSH bit). 1. This task must be started next in normal sequence; i.e., if a task is being brought into core or is ready to go, JANUS will proceed with it, but will cause this one to be the next task readied (HURRY bit). 2. This task is loaded and is ready to proceed. 91 3-14. Unused. 15. This task is on wait status. This bit is set at the request of the task, and is removed only on the receipt of a Signal or if bits 0 or 1 of this word get set. Bits 0, l, 2, and 15 are cleared each time a task is started. 16-31. The diskpage address of the TOP of this task. Associated with this table are an entry (TSXCNT) specifying the number of tasks which exist, and an entry (NEXTTCP) specifying which task the Swapper is currently manipulating as the next task. NEXTTCP has these attributes, set by the Jobchanger: O. This is a new task to load. Flag cleared by Swapper. 1. This task is on rush priority. 2. All tasks are on wait status. In order to understand the timesharing process, it is necessary to know that the lowest priority interrupt in the machine must be a clock, (the Jobchanging interrupt). Tinesharing proceeds as follows (Figure 19): 1. At some point in time during the execution of a task, the Job- changing interrupt fires, either because the time is up, or because the task has, for its own reasons, triggered the interrupt. As soon as there are no higher level interrupts active, and there is no inhibit on the clock, an Exchange Program Status Doubleword (XPSD) instruction is executed, which references the TOP of the task. {As a result, the current status of the task is saved, and control is transferred to a part of the task (Slice-end routine) which performs all unique and necessary slice- end functions, before transferring control to the resident Jobchanger routine. g u - ' . . s . ' 'v I ‘ I . ' ‘h i . _ ~ . . . . n . ' . i s u I f . . . t l . v RE TURN SIGNALS AND REMOVE TASK FROM WAIT NO MORE NO PAGE NONE Figure 19. 92 CLEAR 'ESK READY' FLAG FND TCP,SET MAP SET ALL AC=3 L 0%“92'55 FOUND ONE or NEXT TASK NO MORE FND NEXT TASK KICK SWAPPER SET JOB CLOCK SET FLAG JANUS JOBCHANGER ALGORITHM FLOW CHART The Job Changer - flow chart. 93 2. The Jobchanger performs common slice-end cleanup, examining each entry in table TRUECOBE. The reuse priority (P) is a measure of how recently that page was in use, and to what degree it was used. The lower the priority, the less it is necessary for that page to remain in core. A.non-zero priority is reduced by one if the page was not part of the current task. If the page was part of that task, the correspond- ing entry in USEPAGE is found. If not flagged as ABS, virtualLy dedi- cated, or USED-LAST, the priority is set to l--otherwise it is set to 3 if it must be written back, 2 if not. The flag for being a part of the current task is also cleared. 3. If NEXTTCP does not contain its rush flag, TASKPAGE is scanned for the presence of a RUSH flag. If found, the rush flag in NEXTTCP is set, and the Swapper (RAD interrupt routine) is kicked. If only one task is active, the Swapper is also kicked. In kicking the Swapper, the RAD status is checked. If not operational, a comment is produced on the con— sole teletype, and JANUS hangs the machine in an alarm loop until the RAD becomes operational. 4. All tasks on wait status are checked for the presence of RUSH or HURRY conditions, and for the presence of one or more Signals. 'If any of these conditions hold, the task is removed from wait status. 5. If any Signals exist, all TCP’s which are in core are located in turn. The map is set to reflect the location of each one, and a search is made of Signals, to locate and transmit all Signals for that task, de- leting each Signal found in the process. 6. The task specified by NEXTTCP is tested. If that task is not ready to proceed, a WAIT instruction is executed, and after the next interrupt, execution transfers back to step 3. 94 7. If the task is ready to proceed, the map is set for the TCP. and the access protects for all pages are set to 3. TBUEQORE is scan- ned for entries flagged as part of the next task. For each such entry, that flag is cleared, and the associated page name is picked up. Each reference to that page i. found in table USEPAGE and the entry. is INTer- preted. If it is flagged as ABS or virtually dedicated, the access protect specified in USEPAGE is set. The map is set, according to the locations of the references in both USEPAGE AND TRUECORE. If the USEPAGE entry is flagged as having to be written back, the corresponding flag is set in TBUECORE. All "NEED-NEXT” and "USED-LAST" flags are deleted from USEPAGE. 8. The NEXT and HURRY bits of the TASKPAGE entry are cleared. Routine FINDNEXT is called to locate the next task to process, and this information is saved in NEXTTCP. If more than one task is active, the Swapper is kicked, the timeslice duration is computed, and the Slice- start routine of the new task is entered via an LPSD, resetting the Job- changing interrupt. A.typical example of the sort of timing problems which must be always considered is seen here, in that, while the Jobchanger is the lowest priority interrupt, the interrupt which ticks the clock is one of the highest. Setting the clock and transferring to the task requires two instructions. As the Jobchanging interrupt will fire only as the clock runs through zero, and not at all if the interrupt is active, it is conceivable that, as a result of heavy interrupt usage, the clock may run out between setting and transferring control. The result would be that a task would start with a timeslice, not of a nominal 100 milliseconds. but instead, of two months, the time required for the clock 95 ts tick 2 billion tines. As a result, the Jebchanger may not set the clock itself, but instead tells the task how much time to ask for. Be- cause of this, the Slice-start routine must always operate with the Job- changer inhibited. Also, the task can play tricks. such as setting the oledk to a fixed fraction of the time, and at the end of this partial timeslice, start a different segment of itself for the remainder of the time. 4A task may thus timeshare itself within a timesharing environment. Let us now turn our attention to the Swapper, the resident RAD interrupt routine (Figure 20). This routine may be entered in two ways: normally through an I/O operation, or abnormally by being "kicked", that is, by the execution of a specific and easily recognizable invalid I/O operation, instigated from outside the interrupt routine, and which can heccur only if the RAD is not busy. 1. Test if entered via kick. If not, check the last operation per- formed. If an error was detected, go to POINT S. Otherwise determine diskpage used, the entry of TRUECOBE referenced, and the operation per- formed. If write, clear all flags from the TBUECOBE entry except 2 and 7-13. If read, set the diskpage into the TRUECORE entry, set bit 3, and clear all bits but 3, 7, and 9-13. Finally, delete that operation from the queue. 2. Test NEXTTCP. If flagged as a new task, clear that flag, clear FLAGS, clear bits 2 and 3 from all TBUECOBE entries unconditionally, and clear out the queue. Exit if no tasks should proceed, or if the next task is ready. 3. Copy the diskpage specified in the TASKPAGE entry specified by NEXTTCP. Determine if it is in core. If not, proceed to POINT A. Otherwise set the flag in TRUECORE accordingly, and compute the 96 ALLOCATE BEST CORE PAGE REINITIALIZE No sum vo FOR TOP YES msx “”5 ”a RETURN 5cm FOUND 0'" FOR ABS me: can ABS ass PAGE mo E IN NO “ORE mom PLACE A ALL yes no YES sass. wars u so u '5 Otis "0 p YES USABLE'T so no no room ONE F as my “0 mos: mos ves POINT To YES omen SCANTYPE g: TASK ' new usxs saunas NEXT no "° coum- 5 0 RETURN 5“" FOUND ONE roe 5cm- we Is ..0 ”° o MORE IN cos: YES COUNT -I-COUNT NO YES '—fis f.— SCANTYPE = .____.__ USED LA ST Figure 20. The Swapper - flow chart. 97 unnnpped address of USEPAGE for future reference. 4. Test FLAGS. If not set to indicate all ABS pages have been found, scan USEPAGE for ABS entries. For each one found, determine if in the correct place in core. If so, set bit 3 of the TRUECORE entry and continue. If not, determine if the required page is free, and if not, find a new task and continue to 2. if possible. If the page is free, scan THUECORE for the desired diskpage. If found, copy into the cor- rect page, writing the original contents out to the RAD if necessary. Define the new contents, and free the page it was in. If the page was not found, go to POINT F. When all ABS pages have been located, set FLAGS to reflect the fact, so that 4. can be skipped in the future. 5. Check FLAGS to determine if all virtually dedicated pages have been found. If not, scan through USEPAGE to locate all such en- tries, ignoring all ABS entries. For each one, scan TRUECORE for the diskpage specified. If not found, proceed to POINT A. Otherwise set bit 3 in the TRUECORE entry and continue. When all virtually dedicated pages have been located, set FLAGS to reflect the fact, so that 5. can be skipped in the future. 6. Scan USEPAGE for all entries flagged "NEED-NEXT", ignoring all ABS and virtually dedicated pages. Scan TBUECORE for that page. If not found, go to A. Otherwise set bit 3 and continue, counting that entry. 7. If less than 5 pages were found in step 6, repeat the search, looking for ”USED-LAST“ pages. As soon as a total of 5 pages have been found in either of these latter categories, set the task ready to pro- ceed (in TASKPAGE) and exit. POINT A (Allocate). Two assignments are presented to this routine-- the weights to give the swap dedication (W3) and dedication (VD) 98 attributes in TBUEOORE. Each entry of TBUECORE is INTerpreted to deter— mine if dedicated, or in use for the current task or the next task. If not, a value is computed on the basis of: V = 2*(WBITEBACK)+WS*(swap dedication)+WD*(dedication) +2*(reuse priority), where quantities in parentheses are TRUECORE entry attributes. The page with the lowest value V is passed to POINT F. POINT F (Fetch). Set bit 2 (page undergoing swapping) in TBUECOBE entry specified. If that page must be written back, generate an output entry and put into the queue. Always generate an input entry for the queue. POINT 3 (Start I/O). Set up and initiate the I/O operations for the first entry in the queue, and then exit. As a result of the Swapper algorithm used, JANUS is a primitive learning program, in that it tends to keep in core those diskpages used most frequently. Given a set of tasks which may all fit into the machine core memory simultaneously, and a demand paging scheme, only a few time slices are required for JANUS to discover the pages required and bring them into core, where they will remain until freed or replaced. As a~ result, in the case where everything fits into core, the overhead due to Swapping, Jobchanging, and demand paging drops to an extremely low value compared with other timesharing systems. B. 2 Resident Routines Since it is required of most tasks that they be able to manipulate the resident tables, and since it should be unnecessary for a task to have to know all the details of the tables, it is desirable to have a 99 number of resident routines, callable from tasks, which will perform the manipulative functions required. The calling sequence is common to all routines. It is: BAL,Rll ROUTINE with.parameters transmitted in.R6-Rll as necessary. Any information is normally transmitted back in the same fashion, and if necessary, OCH is set to‘l if the request was satisfied successfully. Consider in this section those routines which deal with the time~ sharing tables already described. These will be subdivided for the pur— pose of description by the table they reference. Each descriptor will be of the form: | NAME“) R Parameters transmitted Parameters returned Comments Where (s) is a flag in the descriptor to specify that a success code is returned. Each parameter is described by contents and register thus: B6 Value uOOFFXX where 8 hexidscimal digits are displayed, and the characters mean: * Unpredictable garbage, to be ignored 0 Zero F All bits set to 1. Any hexidecimal digit may be used. X Field of interest. B. 2 (l) Routines Which Deal with the Map A s GETMAP ‘ . 4 v R6 Net used ' ******** Unmapped address OOOOOOXX R7 Mapped address OOOOOOXX Unchanged OOOOOOXX This routine permits referencing MAPIMAGE, in order to locate the lOO actual page a specified page maps into. The addresses are page addresses. B. SETMAP R6 Unmapped sddress OOOOOOXX R7 Mapped address 00000011 This routine returns if the map is set as specified. Otherwise, MAPIMAGE is updated as requested, and the map is reloaded before return. B. 2 (2) Routines which deal with the Access Protection. A. GETAC R6 Not used "*’***‘ Current access OOOOOOOX R? Mapped Address OOOOOOXX Net used ***‘**** This routines permits referencing ACIMAGE, to located the currently used access for a page. Page addresses are used. B. SETAC R6 Access Protect OOOOOOOX R7 Mapped address OOOOOOXX This routine compares the access specified with.that in ACIMAGE, returning if they are identical. Otherwise it updates the image, and reloads the access protect registers. B. 2 (3) Routines Which Deal with Table TASKPAGE. These routines are all of the same form, since in each case: R6 TCP NAME ""XXXX All routines are called by name. A. WAIT The specified task is located, and placed on wait status. B. RUSH .The specified task is located and its RUSH flag is set. This routine is reentrant and may be called from an interrupt level. 101 C. HURRY The specified task is located and its HURRY flag is set. This routine is reentrant and may be called from an interrupt level. D. KILL The specified task is located, and removed from the ring of ac- tive tasks to a stack of dead tasks, to be serviced by the system MORTICIAN task. Since this routine has to rearrange a table which is referenced from multiple interrupt levels, it is necessary to inhibit both I/O and external interrupts for a brief period (31.0 microseconds). However, this routine is called but once for each task--thus the con- dition will not occur often. Furthermore, this is the only place in all of JANUS where it is necessary to inhibit these interrupts as a normal condition. E. START Unnecessary bits are masked off the task name, and an attempt is made to add it to the ring of tasks. If successful, a "wake up" Signal is sent to the task. B. 2 (4) Routines Associated with Table TRUECORE. All references are associative, in that the diskpage contained in a page of memory is specified. In all but specific cases, the operation will not succeed unless the specified page is in core, and flagged as being part of the current task. A. CURRENT‘ R6 Disk address *‘*!XXXX Unmapped page address OOOOOOXX If the page is in core, it is flagged as being part of the current talk. 102 B. RITEBACK* R6 Disk address ***‘XXXX Unmapped page address OOOOOOXX The flag is set that the page specified must be written back onto the RAD, because true copy no longer exists there. C. REDEFINE* R6 Old disk address *'*VXXXX Unmapped page address OOOOOOXX R? New disk address ****XXXX Unused ‘******* If the page specified by R6 is in core, change the name to that specified by R7. This routine is used in disk copying operations, since a task may bring a page into core, change its name (which is equivalent to making a copy), then modify the copy independent of the original. D. DROPFILE’ R6 Disk address. *‘*¥XXXX This routine is used to get rid of pages not currently in use, but which must be preserved. 'If the page is in core, and not dedicated, the page is removed from the range of the task. If, in addition, the page need not be written bask, the page of memory is freed. E. DEDICATE¢ R6 Disk address ****XXXX If in core, the dedication level of the page is increased by 1, looking it in place as a resident page. F. UNDEDICT* R6 Disk address **‘*XXXX If in core, the dedication level of the page is decreased by 1. If the resultant dedication level is zero, the page is free to engage in swapping again. G. ALLOCATE! R6 Disk address *’**XXXX Unmapped page address l"OOOOOXX 103 This routine evaluated the worth of each page of TRUECORE, ignoring all pages in use, dedicated, or which must be written back, and assigns a value according to: V = 4*(reuse priority) + 2*(dedicab1e page) - (Swap dedicated page), where the quantities in parentheses are attributes of each TRUECORE entry. ' If one or more pages are not ignored, the one of these with the lowest value is assigned the new diskpage specified, and flagged as part of the current task. This routine is used in attempts to acquire tem~ porary storage without proceeding through a Jobchanging cycle. H. FREE* R6 Disk address ***TXXXX If the page in in core, and not dedicated, it is unconditionally freed. That is, it is undefined, and will never be written back onto the RAD. B. 2 (5) Routines Associated with Disk Pages. These routines deal with a stack of resources, which is only par- tially resident. If at any time the stack is endangered, the Jobchanging interrupt is triggered. Hence any task should permit Jobchange to occur between each request to these routines. A diskpage address is a 16 bit, non-zero, unsigned quantity specifying the location on the disk where it may be found. A. ALOCDISK"I R6 Unused ******** Allocated disk page OOOOXXXX If a disk page is available, it is allocated to the requesting task. No effort is made to know to which task a specific diskpage is 104 assigned. B. FREEDISK R6 Diskpage ****XXXX The diskpage specified is returned to the pool of free disk pages. Since JANUS does no elaborate checking, it is the responsibility of the tasks to use these routines and resources properly. Typical ex- amples follow, which illustrate the difficulty which may arise from thoughtless use of the functions. 1. Over-dedicating a page. A page may be dedicated up to 15 times without difficulty. This is sufficient if it is dedicated once for each interrupt routine which may reference it. However, if it is dedicated a sixteenth time, an arithmetic carry occurs, such that the page is no longer dedicated. In as much as such a page is normally flagged as dedicable, that bit is also cleared, and the carry may extend to defining the page as a TCP, or even dedicated for swapping. When undedicated, the page enters the swap swirl. The first time an unnapped mastermode transfer is made into the middle of data or mapped code, all hell breaks loose. 2. Over-undedicating a page. The same arguments apply as in 1, except that a borrow occurs, leaving the page totally dedicated. 3. Overdefining a page. Under certain circumstances, it is pos- sible for a free diskpage to be in core. (For example, the last task which freed the page may have been interrupted by the Swapper after freeing the page, but before removing the reference from the TCP, such that the Swapper did cause the page to be brought into core again, where it might remain for a long time under low usage.) Also, a freshly freed diskpage is most likely to be allocated next. As a result, one should 105 never allocate a page directly, but should instead first check if the page is in core. If not, it may be allocated. If allocation is un— successful, then there is no recourse but to effect Jobchange, causing the page to be actually loaded off the disk. Similarly, in freeing a page, a task is being polite to all users of the machine if it performs a sequence of: A. Freeing the diskpage, B. Deleting the TCP entry, C. Checking if the diskpage was in core, and if so, freeing that page of memory, all without permitting Jobchange to occur. 4. Difficulty can also ensue from freeing a disk page twice, since the name will now appear in two places, and may be referenced by multiple tasks in the future. 5. Making requests with invalid diskpage addresses. Any reference to diskpage zero is ignored by the Swapper and Jobchanger, since disk- page zero specifies an unused (null) entry in various tables. However, if a task tries to look up page zero, and a null page exists in core, then that page will be found. Similarly, defining a page to have a disk page address outside the range of the'RAD, or requesting that such a jpage be brought into core, will cause the Swapper to hang unconditionally. The only valid diskpage names are those a task starts with, or has allocated. B. 3 Demand Paging Under JANUS, it is possible for a task to operate without being emxtirely in real memory at all times. This scheme is called demand paging, in that a given page of the task is brought into the working 106 memony upon demand, whenever referenced. The routine involved is over half a page in length, and there is a point of diminishing returns, be- yond which it is no longer economical to use a half page of virtually dedicated code for demand paging. Since demand paging applies only to slavemode code and references, this limit is reaChed when there are about five pages demandable. If there are more than five, demand paging be- comes profitable. The demand paging algorithm is described here both for its use, and to illustrate the use of previously described JANUS routines. This routine is full~blown, in that it takes care of all eventualities and idiosyncrasies of the Sigma 7 in addition to demand definition (the automatic extension and definition of the task address space). Certain features may be eliminated with previous knowledge of the task usage—— if it is known unconditionally that the trapping instruction will al- ways do word addressing, and will always be present with the correct map and access, esoteric tests may be dropped. The demand paging routine is connected to the X'QO' trap (non- allowed operations), which includes violations of memory protection. There are two parts, shown in Figure 21--one of which deals with JANUS, and is called by the second, which interpretively decodes the trapping instruction. We consider first the JANUS oriented routine. Function SCANPAGE(EWA)--S(A). EWA is the Effective Word Address. The routine always expects a word address as an argument. The routine determines the status of the page referenced, and returns Condition Codes (CC) as follows: 1. CC - O, EWA in registers. 2. 001 - 1, EWA is not in core. 3. 002 8 l, situation improved-~EWA is available, but usage was 107 my w¢00 z. #02 o<...u ...wa aux—30mm hum .m. .4- N4 .pasno so: .. 93m!" unseen .HN 93mg E 02 9 =3 olmmwmoo< omo? <0 w>=.<._.zwmwmamm Awoooaov 2 hum wooo do Ickwu. :5 ma»... OP 02.010004 20:03”.ka— wxh MND