Assignment 2, due Feb. 12

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

Always, on every assignment, please write your name legibly as it appears on your University ID and on the class list! All assignments will be due at the start of class on the day indicated (usually a Friday). The only exceptions to this rule 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 and in class! Late work may be turned in to the teaching assistant's mailbox, but see the late work policy. Never push late work under someone's door!

  1. Background: Consider a large software product called (creatively) product. The distribution for this contains the following source files.

    a) When compiling and building product a number of files will be created that are not listed as bullet points above. Enumerate these files, with brief comments about their role. Some of them are mentioned in the comments above, some are not. (0.5 points)

    b) Write a makefile (the standard name for this is MAKEFILE) that ought to be included in the standard distribution of product in order to automate the build process. Typing the make command in a directory that includes the above files and the makefile will automatically build product and if you edit any of the source files, it will do the minimum number of steps needed rebuild product to account for your changes. (0.5 points)

  2. Background: The example shell program distributed on the web has many shortcomings, One of these is that it doesn't support quoted parameters, so if one line of input to this shell is:

    echo "hello world"

    There are two parameters, ("hello) and (world"), with the quotation marks simply treated as letters.

    A question: All the changes required to support quotation marks would be confined to one subroutine in the code that was distributed. Identify that subroutine. (0.5 points)

  3. Background: The example shell program distributed on the web is written in idiomatic C: The result of this is that argv and line are allocated as local variables in one_command().

    A question: If you were writing this code in Java, C# or some similar modern language, how would you do things differently. Where would the array argv be allocated and where would you put the text of each parameter? (0.5 points)

  4. Background: On a modern computer, it is common to find a hierarchy of busses, so to' output to the serial port, you have to work through a USB, but to output to the USB, you have to work through the PCI bus. Imagine a fictional bus sort of like a USB bus with the following interface registers:

    Assume data can be transferred from top-level interface registers with io_read(register) which returns the value, and to them with io_write(register,value).

    Assume that one of the devices attached to your fictional bus is a serial port with two bus addresses of serial_status and serial_data. The latter is a read-write register used to send data to or receive data from the device. The former has two defined bits that may be set or reset, SERIAL_IN_READY and SERIAL_OUT_READY. Bits can be tested by anding the named constant for that bit with the contents of the indicated register.

    A Problem: Write the code for a serial port read operation. This code should access the serial port over the bus to which it is connected, and then inactivate the bus when done. (The above spec includes the bare minimum to allow this. A better bus spec would include support for interrupts and some way to avoid inactivating the bus except when there is no pending I/O.) (1.0 points)