The Flex Computer System was developed by Michael Foster and Ian Currie of Royal Signals and Radar Establishment (RSRE) in Malvern, England, during the late 1970s and 1980s. It used a tagged storage scheme to implement a capability architecture, and was designed for the safe and efficient implementation of strongly typed procedures in high-level programming languages such as ALGOL 68 and Ada.
Description The original Flex hardware was custom and microprogrammable, with an operating system, (modular) compiler, editor and filing system all written in ALGOL 68RS. The microcode enforced a tagged architecture to distinguish between different types of data and was described as providing "a protection structure equivalent to that of capability machines". The microcode was entirely responsible for storage allocation, deallocation and garbage collection. By tagging pointers, the microcode could make them "unforgeable" by program operations, and this immediately precluded a whole class of errors arising from the misuse (deliberate or accidental) of pointers, or from compiler bugs.
Memory and garbage collection Memory was allocated in blocks of different types that supported only certain kinds of operation. Block types were divided into two principal groups: those concerned with procedures and those concerned with data. Procedures were described by closure blocks that referenced the code, non-locals and constants, and could only be invoked. Invocation would cause a workspace block to be allocated containing local variables and the evaluation stack for a procedure. Data would reside in blocks distinct from blocks holding program code. However, unlike certain other capability systems, Flex allowed both pointers and data values to be stored at the same time within the same block, relying on the tagging of pointers to prevent conflation with data. In contrast, the Plessey System 250 employed dedicated capability and data segments, along with dedicated capability and data registers. Pointers were only able to reference whole blocks without supplementary information. Individual data values would be accessed using a reference involving a pointer and an offset or displacement within a block. Elements in a vector would be accessed using a pointer and a displacement constrained by an upper bound, and array access would involve pointer, displacement, bounds and stride information. Blocks would contain metadata in the form of overhead words which, although appearing at the start of blocks in physical memory, would be invisible to code accessing these blocks whose offsets would be adjusted transparently to skip such overhead regions. The whole scheme allowed abstract data types and for interfaces to privileged code to be safely implemented, as data items and the procedures permitted to access them could be bound together and the resulting capability passed freely around. The capability would grant access to the procedures, but could not be used in any way to obtain access to the code or data. Indeed, just as the operating system could employ such mechanisms to uphold its privilege and be protected from callers, procedures in user programs could similarly employ these mechanisms to act like an operating system to their own callers. Since such mechanisms were provided at the hardware level, as opposed to depending on code generated for any particular programming language, information hiding restrictions stipulated by languages such as Modula and Ada could not be circumvented by using code written in low-level or permissive languages, these purposefully not supporting such restrictions, to interface to high-level language code. Memory blocks in Flex were garbage collected, with the collector implemented in microcode using a mark and sweep approach. This would scan the known live (or active) blocks for pointers, made easier by the presence of the tag bits distinguishing pointers from data words. Referenced blocks would then be marked as live and compaction would occur, situating the remaining live blocks at the start of the system's memory and updating the system's own records of block locations. A notable feature of Flex was the notion of firm and shaky pointers: the former causing blocks to be marked as live during collection, and the latter acting as a form of weak reference. Where all pointers to a given block were marked as shaky, such a block could be freed at the next garbage collection. Each of the shaky pointers involved would then be overwritten with a nil value Shaky pointers were also used, for example, for cached disc blocks or to provide a list or chain of spare procedure workspaces. Garbage collection would suspend execution of code for approximately half a second in the second "laboratory model" implementation of the system with one megabyte of memory. It was a process whose duration was directly proportional to the size of the memory, increasing linearly with store size. On a two megabyte PERQ system, the measured time for garbage collection was, on average, between 1.1 and 1.5 seconds. An example scenario of "two long Algol68 compilations in parallel with normal text editing" would cause collection every 45 seconds or so, this recovering 1.2 megabytes of free memory on each occasion.
… excerpt ends here. Continue reading the full article.