Assignment 4, Solutions

Part of the homework for 22C:112, Spring 2012
by Douglas W. Jones
THE UNIVERSITY OF IOWA Department of Computer Science

  1. Background: Read 0S6—An experimental operating system for a small computer. Part 1: General principles and structure.

    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.

  2. Background: Read 0S6—An experimental operating system for a small computer. Part 2: Input/output and filing system.

    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.

  3. Background: The notes for Feb. 8 give several ways to implement a "polymorphic" file model, for example, using a select-case construct to pick the code appropriate to the particular file type, or using pointers to subroutines for each operation.

    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.