Assignment 2, due Jan. 27

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

On every assignment, write your name legibly as it appears on your University ID and on the class list! Assignments are due at the start of class on the day indicated (usually Friday). Exceptions will be by advance arrangement unless there is what insurance companies call "an act of God" (something outside your control). Homework must be turned in on paper, either in class or in the instructor's mailbox. Never push late work under someone's door!

  1. Background: Consider this perhaps less than trivial C program:
    #include <stdio.h>
    #include <stdlib.h>
    int main( int argc, char *argv[] ) {
       if (argc <= 0) exit( EXIT_SUCCESS );
       argc = argc - 1;
       puts( argv[argc] );
       main( argc, argv );
    }
    

    You may find the man command to be very important in understanding this program. The Unix shell command man 3 exit will output the manual page on the exit() routine in the standard library. Section 3 of the manual is the standard library. You can look up puts the same way. Kernighan and Richie has a discussion of the main program, and Google (or Bing, or Yahoo) can find writeups on all of this. (0.4 points each)

    a) What order does the program output its command line arguments in?

    b) The main() function is recursive. Does it ever return?

    c) What is argv[0]?

  2. Background: In 1974, Ritchie and Thompson's article on the Unix Time-Sharing system was published in Communications of the ACM. See
    -- http://dl.acm.org/citation.cfm?id=361061

    A Question: What did Ritchie and Thompson claim was original in their invention of Unix? (0.9 points)

  3. Background: Going back in time, in 1966, Lampson and Lichtenberger published an article on A user machine in a time-sharing system in the Proceedings of the IEEE. See
    -- http://research.microsoft.com/en-us/um/people/blampson/02-UserMachine/WebPage.html

    A Question: Programmers on this machine thought that they were writing code on a physical machine, but the system provided services that let them reconfigure the machine. How? (0.9 points)

    Warning: Don't write long essays. The purpose of the final two questions is to get you to browse some of the classics of the operating system literature. Skim the papers looking for short meaningful answers, don't spend hours on them, unless you get intrigued.

    An aside: Note that Ritchie and Thompson cite Lampson and Lichtenberger. The influence of Lampson's work on Unix is apparent to this day: The vi text editor is a direct descendant of QED, the editor Lampson wrote for the system described in his paper. developed.