Assignment 1, Solutions

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

  1. Background: Consider the concept of transparency, as discussed in the notes for lecture 1.

    Microsoft's first product was a BASIC interpreter for the Altair computer, based on the 8-bit Intel 8080 microprocessor. This BASIC was interpreted. That is, BASIC programs were executed by a program that read and interpreted the source code directly, without first translating to machine code. Altair BASIC had a pair of commands, PEEK and POKE. These allowed a program to peek at the value in a RAM address or poke a new value into an address.

    A Question: Explain the role of PEEK and POKE in the transparency or opacity of the virtual machine interface provided by Altair BASIC. (0.5 points)

    PEEK and POKE converted an opaque interpreter to a transparent interpreter, allowing a program running under the interpreter to carry out arbitrary operations (albeit inconveniently) on the underlying machine.

  2. Background: Take a look at the Unix History Web Site http://www.bell-labs.com/history/unix/ to answer the following quick questions (0.2 points each):

    a) What organizations did Bell Labs partner with to develop the Multics operating system?

    General Electric and the Massachusetts Institute of Technology.

    b) What was the application program from which the first version of Unix grew?

    The game of Space Travel played a significant part in the original efforts on the PDP-7 computer. The Unix word-processing suite (the ed text editor and the troff text formatter were the first "paying applications" that justified the effort to port the system to the PDP-11. (The Space Travel answer is the better of the two offered here.)


    c) What was the first high-level language used to implement parts of Unix?

    B. Performance problems with B and the addressing architecture of the PDP-11 later led to the evolution from B to C.


    d) How did the University of California at Berkely get involved?

    Ken Thompson took a sabbatical at Berkeley in 1976-77.


    e) Who owns Unix today?

    The story is tangled. The Open Group owns the name, and SCO owns rights to the AT&T source code. The exact division of ownership between these organizations appears to be subject to ongoing litigation.

  3. Background: Note the following manual of style for C programmers: http://homepage.cs.uiowa.edu/~dwjones/syssoft/style.html and note that the following C program does not conform to this style:
    #include <stdio.h>
    int fib(int i){if(i
    <= 1){return i;}else
    return fib(i-1)+fib(i
    -2);}int main(){int i;
    for( i=0 ;i<= 10;i ++){
    printf("fib(%d)=%d\n",i,
    fib(i));}}
    

    a) Fix it to conform with the recommended style. Running the result is a good way to make sure you didn't break it, but grading will depend on style as well as correctness. (1.0 points)

    #include <stdio.h>
    int fib( int i )
    {
            if (i <= 1) {
                    return i;
            } else {
                    return fib( i - 1 ) + fib( i - 2 );
            }
    }
    
    int main()
    {
            int i;
            for (i = 0 ; i <= 10; i ++) {
                    printf( "fib(%d)=%d\n", i, fib(i) );
            }
    }
    

    c) Would rewriting this program to take advantage of the object-oriented features Java or C# make it any clearer? (0.5 points)

    No. Adding objects to this program would only add irrelevant complexity.