Assignment 4, Solutions
a) How does OS6 differ in its use of the concept of virtual machine from the Lampson and Lichtenberger's 1966 work you read for Homework 2? (0.6 points)
In OS6, Stoy and Strachey wrote an interpreter, so that all "virtual machine instructions" in user code were executed interpretively by code running on the physical machine.
In contrast, in Lampson and Lichtenberger's system, most user machine instructions were directly executed in hardware, and the hardware forced traps to the operating system for illegal instructions and for instructions that were implemented by the operating system (POP codes).
As a result, given hardware with equal performance, I would expect OS6 to be slower because of the interpretive overhead, but Lampson and Lichtenberger's approach can only be done if the hardware of the base machine can be made to trap the appropriate instructions.
b) What makes the OS6 loader noticably more complex than the loaders we discussed in class? (0.6 points)
The loader has to preserve any globals that are overwritten by loading, so that the globals can be restored when the indicated variables are "unloaded". There is absolutely nothing even vaguely similar to this in Unix.
Some of the ideas for stream I/O in OS6 look very similar to ideas in Unix or the C standard I/O library. For example, the OS6 calls x:=Next[s] and Out[s,x] look very similar to the C calls x=getc(s) and putc(x,s), if one ignores syntactic details.
a) Identify a feature of OS6 streams that is distinctly different from anything in Unix. (0.6 points)
PutBacl() to, in effect, push a character onto an input stream, has no analog in the Unix/C stream model.
b) The OS6 paper does not use the terminology of object-oriented programming, as that terminology was being invented while this paper was being written. In one or two sentences, is OS6 I/O object-oriented? (0.6 points)
It is fairly clear that OS6 streams are properly a class, where stream objects support the methods Next(), Out(), Close(), etc. The implementation using indirection through the stream vector is one of the common ways of implementing polymorphic classes.
A Problem: Why is the select-case construct a bad approach? What does it make difficult. (0.6 points)
All the implementations of the polymorphic class must be known at the time the code is written, and they are all forced to be mixed together. For example, all of the put method bodies are combined into the case-select construct in the put routine, and all of the get method bodies are combined into the case-select construct in the get routine. As a result, adding a new subclass at a later date is messy.