CAL Lisp: Preliminary Description
Total Page:16
File Type:pdf, Size:1020Kb
., CAL Lisp: Preliminary Description (Bill Bridge) Gene McDaniel Paul McJones A project for CS 220 and CS 199. / -1---' c> j . ,j.) '~;'4)':j ( ~.' . /1 , I . ! . ".--(-- ,,\--1.::> INTRODUCTION Lisp has been in the forefront of symbol manipulation programming languages for more than a decade and interactive implem~entations on timeshared computer systems have kept it up-to-date. In particular BBN Lisp for the SDS 940 and, more recently, the PDP-10 provide a very large address space and powerful primitive'; ) .. / operations allowing interactive debugging and editting ext~sions, among others, -t to be written in Lisp itself. (1,2). CAL Lisp is an attempt to coninue this line t of development and hopefully harness a fast computer, the CDC 6400, and a not-so r fast operating system, the CA~Timesharing system • ..; BBN has diverged from Lisp 1.S (3) in several ways which increase efficiency without, it is felt, detracting from the language. First, a linear pushdown stack replaces the association list scheme for variable bindings and allows compiled functions to reference their arguments directly. (These compiled functions still place the variable names with the values to facilitate debugging and maintain compatibility with interpreted functions.) Second, the property list of an atom is no longer used by Lisp to hold function definitions and constant values. Each atom has three settable attributes: a definition cell, referenced when the atom is used as a function name; a "zero-level value" cell, used when the atom occurs as a free variable bound nowhere in the stack; and a property list cell, purely for use by the user (including the Lisp-coded extensions) as a hatrack. Third, the treatment of special forms, functions taking unevaluated and/or a variable number of arguments, is nicely handled, with any of the four combinations allowed. A number of generalizations and extensions in many other areas exist and in PDP-10 Lisp provision is made for an openended set of datatypes, after the spirit of SNOBOL4. We wish to mimic the BBN Lisp faithfully enough to be able to utilize much of its library of software (editor, breakpoint routine, etc.) and yet still clean up a few of the inconsistencies which naturally occur as large systems evolve over the years. Our machine has a relatively large physical memory (23,000 words available to a user process) with an awkward 60 bit wordlength.... Secondary storage capacity is limited. with 8 million words of disk and 300 thousand words of extended core f ,: storage (~c~). Thus much of our effort has been applied to dense packing of data structures. And since no paging or segmentation hardware exists, we have had to carefully plan their inclusion in the software. The timesharing system does provide a disk file structure buffered by the ECS, and a software map to swap the central memory to/from files (residing on disk or in ECS.) The work is being done in BCPL, a high level language ostensibly suited for systems programming. This should greatly reduce the time spent on coding,but the resultant object program may be too large and slow to be feasible. We envision rewriting sections in assembly language as necessary. Th8 "\.-,orlo of' CJ\T, Lisp can be characterized by a complex of eleven con centric rings. F.ach ring represents a virtual machine, from the hardware (inner most ring) to the user program (outerm09t ring). The hardware consists of 32 K (K=102h) of eM (60 bit words), 1 CPU, 10 PPUs, 300K ECS and eight million words of disk storage. The ECS and disk act as secondary and tertiary storage devices. The lack of really large scale bulk storage imposes severe restraints on upon the upper layers of virtual machine. Next the ECS-INTERRUPT SYSTEM layer implements a number of orthogonal actions which aid in the implementation of a timesharing system. Of particular interest to Lisp is the ECS-CM interaction, ie., process swapping from and to CM and ECS. Associated with each user process is a software map which describes which blocks of CM are to be written where into ECS (and vice versa). The CAL Lisp system uses that software map to implement the virtual memory layer (described later). In the CAL Timesharing system files can exist either on the disk or in ECS. The low level disk system was designed to allow unused portions of a file to reside on the disk while the currently used portions of a file may reside in ECS. The directory system implements complicated searching procedures to allow the user to employ symbolic names while describing or asking for his files. The command interpreter-executor follows the two fold task of determining the "semantics" of user or subsystem requests and then attempting to service those requests. The virtual processor viewed from this point is the CAL Timesharing System. The lowest level processor directly implemented by CAL Lisp is the virtual memory mechanism. There is a 256kYirtual memory divided into lK of 256 word pages. The Lisp system references a virtual address through special macros: fetchvirtual(VA) and storevirtual(VA). They take a virtual address as input and return the current CM address 'of the word named by that virtual address. A page table is maintained which contains a one word entry for every 256 word page (See figure~). The page table, which is also paged, contains one word for every block in use, but need not contain entries for pages which aren't being used. A virtual address only need be right shifted a sufficient number of bits to produce the correct index in the page table. The virtual memory mechanism returns the CMaddress of the word being referenced if it is around; otherwise a call is made to the disk system to change the subprocess map. ! LISP PROCESSOR li AUX ,I eM AODR IC ::.1 ,U ~'s r(l'~ '''' c.a'(~ RF::.1 rU ~,s ~~~ ((ftre"ced ~,\\C~ lo.~t-liMe ~ pQ)'f! ~wllt, Io~ ~6: 1 if ~is i1 fA rud·OVl~J ..(il,r,'Y past LB:: tbfAtV ~ k ~~r 1'1'~ =- type '(14, b,-h ~:. du.y.illi",y ~rt ;,,~~J;on I i~J~J pse,",o·P'l)~ -if.sl AU~-::. b~h ~ 10 ~"41( 1k ,,~(ib~ dG.lt.~'pel j u.~ /U, . .f1... t c~" ~ \vSI etc. eM AUDIl ~ ~ck oJdrtn "{ I(~ 1 The disk system brings the missing file page into ECS from the disk and places it in the current subprocess map--thereby effecting the paged memory. This action may be preceded by the swapout-to-the-disk for some page chosen by the virtual memory mechanism. This occurs when CM is fully ma{ed with file blocks of the virtual address space (See figure 3 ). There is also a block buffer table which maps 256 word blocks of CM onto the virtual page currently residin~ there. Storing into a virtual address is more complicated: the paging mechanism must check of the virtual address being stored into belongs to a read only page. If so, a copy of this page is made, the r/o page is returned to the disk, ' the page table entry is changed to r/w and the appropriate CM address is returned to the caller. Important attributes of the virtual memory mechanism may be summarized in the following ways: 1) A large virtual address space is mapped into a small physical address space through use of software paging. 2) Software paging is accomplished by use of the subprocess map maintained by the operating system (which uses it to remove the user process to ECS when his time slice is up, or vice versa). 3) A Least Recently Used swapping strategy is implemented to decide which virtual page must be swapped out of CM to make room for a different virtual page. 4) When the system is smoothly running s1.apping experiments can be performed to determine good swapping strategies: the swapping mechanism may decide to keep more pages in ECS than there is room for in CM. This would mean that when a page fault occured it would not be necessary to retrieve the page from the disk. Virtual Segments The BBN Lisp partition~ the virtual address space into various types. An atom could only occur on a page within certain bounds in the virtual address space. While this allows for quick type checking by doing address arithmetiC, it also sets a static limit on the number of words which can be devoted to anyone type of object. CAL Lisp places no such address restrictions on objects. When a page is created, it is assigned to a specified type (eg., atom, string, etc). There is no limit to how many virtual pages can be devoted to a specified type beyond the intrinsic limit of the 256 K virtual memory_ Vir~l Mr~s This introduces the following problem: There is no .my of predicting in what order the pages of various types will be created. One page might be of type atom while the next two virtual pages might be strings or numbers. (See fiQ.1re 4 ). It is apparent that consecutive virtual addresses may lead to objects of completely different type. 1~ile all primitive functions should't have to worry about virtual address type, it is clear that chaos will result if virtual addresses aren't neatly "bundled." The virtual segment layer of the CAL Lisp system stands between the virtual memory and the data structures for the reasons described above. The virtual segment mechanism follows algorithms fitted specifically for the type of the data structure it may be handling at a given time.