Midterm II Solutions

Part of materials for 22C:50, Summer 2003
by Douglas W. Jones
THE UNIVERSITY OF IOWA Department of Computer Science

 

Name: ________________________________________________

ID Number: ___________________

Please write your answers in the space provided! Make sure your name is in the same form as it appears on your University ID card! Illegible and excessively long answers will be penalized! This exam is open-book, open-notes, closed neighbor! This exam is worth 1/10 of the final grade (10 points; allocate 4-5 minutes per point).

Grade Distributions

For both Exams plus Assignments 1-7 and Machine Problems 1-3

Mean   = 37.67
Median = 39.0
                               X
         X             X       X     X       X
    _____X_________X___X_X___X_X_X___X_X_X_X_X_____X_______
    10. 14. 18. 22. 26. 30. 34. 38. 42. 46. 50. 54. 58. 62
Scale      F D       D C       C B       B A       A

For Exam II

Mean   = 5.48                 X
Median = 5.9                  X
                              X
                        X   X X
                    X   X   X X
   _______X___X_____X___X___X_X_X___X_X_X_______
     0 . 1 . 2 . 3 . 4 . 5 . 6 . 7 . 8 . 9 . 10

Total Exam Scores versus Homework and Machine Problem Scores

   18 |                                      1   18 |                        1
   16 |              1     1           1         16 |        1       1       1
 e 14 |                    1        1     1      14 |            1       1   1
 x 12 |  2                          1  1     1   12 |  2             1   1 1
 a 10 |                    1     1  1  1         10 |  1           1 1       1
 m  8 |              1                            8 |                1
 s  6 |                          1                6 |          1
    4 |                                           4 |
    2 |_______________________1_________________  2 |________________1_________
	2  4  6  8 10 12 14 16 18 20 22 24 26 28      0 1 2 3 4 5 6 7 8 9 . 11
                      homework                            machine problems

Solutions and Commentary

  1. A problem: Hand assemble, link, relocate and load the following bits of EAL code, showing only the values that are eventually loaded into memory. Assume that the initial relocation base for linking and loading is 10016. Give all addresses and values in hexadecimal. (2 points)
    				Location     Value
    	; File A
    	      INT ASYM
    	      EXT BSYM
    	; commentary
    	ASYM: W  #FFFF            0100        FFFF
    	      W   ASYM		  0102       (0100)
    	      W   BSYM            0104       (0108)
    
    	; File B
    	      INT BSYM
    	      EXT ASYM
    	BSYM  =   .+2
    	      W   BSYM            0106       (0108)
    	      W   ASYM+#0002	  0108       (0102)
    

    5 did perfectly here, while half the class had real difficulty with the value of BSYM.

    For a bit more credit, circle the values that were relocated as they were loaded into memory.

    Parentheses are used above for this. 7 did well, 9 got about half credit, and a few got nothing.

  2. Background: An 8-megabit flash EEPROM chip has the following characteristics:

    a) Why 1056 bytes instead of 1024 bytes? What is the most important system data you might want stored in the extra 32 bytes? (0.5 points)

    A checksum

    6 gave answers including this. Partial credit was offered for those who suggested useful things that were not totally inappropriate, for example, information about which sector holds the file system root, or an up-link to the i-node referencing this sector, etc, but no credit was given for information related specifically to disks (track number, cylinder number) or to disk request queues (buffer address, done flag). About 1/3 of the class got no credit.

    b) What delays can be thought of, by the author of the I/O driver for this flash EEPROM, as being comparable to the various latency times for a disk? (0.5 points)

    The time for an erase-write cycle or a read cycle.

    Only a few gave this, but 7 gave the first half, which is clearly the significant part! A few gave really odd answers or left this blank.

    c) Assuming main memory uses 50 ns RAM, and that the DMA controller gathers groups of 4 bytes into 32-bit words for access to main memory, what fraction of the memory cycles are consumed by DMA operations while a transfer is being made to or from one of the flash EEPROM's internal buffers? (0.5 points)

    1/16

    Only 2 gave this answer, and 4 gave 1/4 (forgetting that the controller batches 4 bytes before it moves a word) for partial credit. This question was supposed to be a give-away, so the poor performance here is disturbing. It was particularly troublesome to see that some students gave answers higher than one, since it is impossible to use more than 100% of the memory cycles.

    d) Is there any reason to use (or not to use) anything analogous to a disk scheduler with this flash EPROM device? Explain! (0.5 points)

    There is no need for a request scheduler because the latency time does not depend on the sequence of requests.

    4 got full credit for this answer, and 2 more got partial credit for saying no, with wrong reasons. The most interesting wrong reasons had to do with using the request queue as a cache, but this isn't (technically) scheduling!

    A request scheduler would reduce the average wait for I/O completion if it gave read requests priority over write requests.

    2 got full credit for this answer. They are right! The scheduler giving priority to read requests will not change the throughput at all, but it can improve the average wait! On a disk, in contrast, the scheduler can improve both!

  3. Background: Consider two identical computer systems running identically the same operating system, differing only in the applications that are running. Performance measurements indicate that the disk is busy almost all the time on both, yet system B completes well over twice as many disk operations per second as system A. Explain the likely cause of this! Focus on disk characteristics I/O driver features that might explain it. (1 point)

    The application on System A is single-threaded and uses I/O operations that each wait for operation complete, so the request queue never contains multiple requests that can be scheduled. On system B, the disk scheduler is effective!

    There was 1 perfect answer, and 6 that were almost as good. 6 more got half credit for identifying the right issue without understanding the role of the scheduler. In many cases, the error had to do with overlooking the word "identical" that is used twice to emphasize that only the application code differs!

    Only 2 answers received no credit.

  4. Background: A typical device driver consists of an interrupt handler for that device, a set of interface routines allowing higher level code to access the device, and a queue (sometimes queues) between the interrupt handler and the interface routines.

    a) Usually, when the interrupt service routine returns, the interrupt enable bit in the device is left on, but sometimes, when it is turned off when the interrupt service routine returns. Why? (1 point)

    The device's interrupt enable bit is left off when the system has or no pending input or output for that device or is unable to service interrupts from that device.

    7 gave good answers here, with 2 more almost as good, usually illustrated with examples like a full input queue or an empty output or request queue. 5 got close to half credit, and 3 more gave answers that were not fully irrelevant.

    b) Most systems have a global interrupt-enable bit as well as interrupt-enable bits for each device. Part a asked about the latter. Explain the need for the former! (1 point)

    Interrupts are disabled globally during critical sections and on entry to interrupt service routines.

    Nobody mentioned the second issue above! 7 got almost full credit for mentioning critical sections. 2 got half credit for suggesting that interrupts would be disabled at some points during the startup and shutdown procedures, and 5 simply defined the global interrupt disable operation with no explanation of why it is needed, for a little credit.

    c) When the queue in a device driver is a request queue, each entry holds several administrative items such as a disk address or a pointer to the done flag for the device. What items are central to each queue entry that were not mentioned here?

    A pointer to the buffer!

    7 gave this answer, and 5 more got partial credit for listing secondary items that might be found in the request queue entry, such as the request priority.

  5. Background: Under the example shell for MP4, I wanted to run a test of the setenv command I had just added. The first half of the test was easy, using setenv to set a variable. The second half was a mess, because the example shell didn't have any tools for printing variables from the environment. Here is my really awful solution:
    setenv TESTVAR value_of_TESTVAR
    tcsh -c $argv eval echo $TESTVAR
    
    The -c option on the tcsh shell causes it to interpret its next argument as a command. The $ prefix causes the shell to hunt for the argument in its pool of named local variables and in the environment passed to it. The named local variable argv contains the entire argument string to the shell (excepting shell options and their arguments). The eval command is a built-in in tcsh that evaluates its argument list as if it was a shell command; this is useful when you want to do macro substitution on a shell command and then execute the result.

    a) Given the above, what is the value of $argv on entry to tcsh on the second line of the above script? (0.5 points)

    eval echo $TESTVAR

    By way of explanation, note that argv[] on entry to tcsh holds more, but that by the time this is packed into the variable $argv the command line option -c and its parameter $argv have been stripped out of the argument string. This question assumed some experience trying to solve MP4, and students who had not worked on MP4 were at a clear disadvantage.

    8 did well here, 2 included the -c option, and one prematurely evaluated $TESTVAR. 5 gave answers that verged on incoherence.

    b) Given the above, what is the argument list that eval executes as a command line? (0.5 points)

    echo value_of_testvar

    By way of explanation, because eval treats its argument as a command line, it substitutes for shell variables like $TESTVAR before it executes the command.

    3 had this answer, while 7 (for a small penalty) did not replace the variable with its value.

    c) Given the above, what is the argument list that echo sees as its input? (0.5 points)

    value_of_TESTVAR

    8 gave this answer, 6 failed to evaluate the variable. People who stumbled on part b could recover here because they knew, from the problem statement, that the entire purpose of this was to print the value of a variable in order to test the setenv command.