Midterm II Solutions

22C:50 Section 2, Fall 2000

Douglas W. Jones

Grade Distribution

    Median = 5.0           X
                   X       X
                   X   X 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
Grades?  D          C          B          A

  1. The EAL code you had to assemble was identical to the code you had to assemble for the first midterm. The only difference was the request to identify all values as either absolute or relocatable! Here's the solution to the same problem on the first midterm, with absolute values in boldface:
         1 0000: 16    |    B   22
         2 0001: 22    |X:  B   #22
        (3)0002: 01    |    B   X
         4             |; commentary
         5 0003: 0A    |    B   Y
        (6)0004: 05    |    B   Z
         7             |Y   =   10
         8             |Z:
    ; symbol table:
    X       =       #0001
    Y       =       #000A
    Z       =       #0005
    Half of the credit for this problem was relocation, the other half was for redoing the problem from the first exam. 8 had perfect scores, 5 didn't do anything about relocation. Sadly, there were a significant number who could not correctly do the basic part of this problem from the first midterm.

    At least 14 students received no credit on the additional part of this problem, to identify the lines that would cause problems for relocation bases above about 256 (these line numbers are parenthesized above), while at least 6 did well on this.

  2. Once a file under classic UNIX is open and the i-node is in main memory, how many disk accesses are required to read a file, assuming one access is required to read each sector.

    a) 10 sectors long requires 10 disk accesses; 17 students knew this.

    b) 100 sectors long requires 101 disk accesses; 16 students knew this.

    c) 1000 sectors long requires 1009 disk accesses; 6 did well here, 5 more had "off by one" errors.

  3. Consider /space/jones/.public-html/syssoft/hw/mid2.html under a classic UNIX file system, where the i-node for the root of the file system is in memory when the system starts. Each directory requires under 5120 bytes, the average directory requires 1024 bytes, and each i-node is in a different disk sector.

    a) The directory manager needs to read 6 low-level files to open this file. Each of these low level files holds a directory. The names for these low level files are

    1. /
    2. /space
    3. /space/jones
    4. /space/jones/.public-html
    5. /space/jones/.public-html/syssoft
    6. /space/jones/.public-html/syssoft/hw
    8 got this right, and 5 were off-by-one.

    b) The directory manager reads 6 i-nodes as it opens this file. The i-node for the root is already in the memory; the 5 i-nodes for the remaining low level files must be read, and the inode for the file itself must be read. 6 got this right, 6 were off by one.

    c) Opening this file requires 18 disk reads. 1 for each i-node and 2 for each low-level file, since the low-level files are 2 sectors long. 5 got this right.

  4. Consider a disk with 8 sectors per track, 8 cylinders, and 1 surface. The disk spins at 8 revolutions per second, and the disk heads can move from cylinder 1 to cylinder 2 in 1/8 of a second. The head accelerates so the distance moved grows quadratically with the time taken.

    a) How long will it take to read the following sequence of disk addresses? All times are stated in 64ths of a second.

      transfer number    cyl sect   begin time   end time
             1            0   0         0           1  
             2            1   3        11          12
             3            5   4        28          29
             4            4   5        37          38
             5            0   1        57          58  
    17 did well here (full credit was given to anyone who got the end time right; intermediate times were checked only for those who had errors on their start times). 10 had answers for which no credit could be assigned.

    b) How many sectors will move past the head in the time it takes the head to seek n cylinders, for n = 1 to 7?

       distance moved  time       distance moved  time
             0          0               4          16   
             1          8               5         ~18    
             2        ~12               6         ~20   
             3        ~14               7         ~22   
    12 did well here. Off-by-one errors were accepted.

  5. Consider the problem of substituting a serial mouse for a touch screen. Every time the user moves the mouse, it sends a packet to the computer indicating the move direction and button state. Current mouse coordinates must be maintained by software. Assume you already have a working touch screen input driver that expects to use interface registers giving the X and Y coordinates touched and the pressure of that touch.

    What minimal changes would you make to the code for the touch screen input driver and what code would you write for the asynchronous input interrupt service routine?

    1. All references to the touch-screen interface registers in the original touch screen driver must be changed to references to variables in main memory.
    2. The interrupt routine for the serial port must accumulate information about mouse moves and record these by incrementing or decrementing the X and Y coordinate variables and by setting the pressure variable according to how the mouse button is pressed.
    3. The clock interrupt routine (or whatever it was that told the touch screen driver when to check the interface registers) would operate as before.

    1 student gave a great answer to this question. 5 gave essentially no answer, 3 rambled on at great length giving no useful answer. 5 gave vague answers of variable quality that were not wrong and were penalized primarily by their degree of vagueness. 23 gave answers that focused in great detail on one or sometimes two issues, frequently peripheral to the central issues of the question while ignoring the big picture. 8 were penalized (mildly) for excessively long answers.