Midterm II

22C:50 Section 2, Fall 2000

Douglas W. Jones

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/5 of the final grade (10 points; allocate 4 minutes per point).

  1. Hand assemble the following EAL code, and show what goes in the symbol table. For those lines of code that cause data to be stored in memory, show the memory address that is changed and the value stored in memory. Each memory address and each value may be either absolute (A) or relocatable (R). Indicate this in the blank labeled reloc following the corresponding address or value. Do not fill in anything unused symbol table entries or next to lines that assemble nothing into memory. (2 points)
    line     hexadecimal          source
         loc  reloc  val reloc    text
    
     1  ______ ___ ______ ___         B    22        symbol table
                                                  symbol value reloc
     2  ______ ___ ______ ___    X:   B    #22
                                                  ______ ______ ___
     3  ______ ___ ______ ___         B    X
                                                  ______ ______ ___
     4  ______ ___ ______ ___    ; Commentary
                                                  ______ ______ ___
     5  ______ ___ ______ ___         B    Y
                                                  ______ ______ ___
     6  ______ ___ ______ ___         B    Z
    
     7  ______ ___ ______ ___    Y    =    10
    
     8  ______ ___ ______ ___    Z:
    
    For a bit more credit, circle the line numbers of the lines that would cause problems for relocation bases over 256 (approximately). (0.5 points)

  2. When you open a file under the classic UNIX file system, the i-node for that file is read into main memory, but no other disk accesses are performed. Once the file is open, how many disk accesses are required to read a file, assuming one access is required to read each sector. (1.5 points)

    a) 10 sectors long? __________

    b) 100 sectors long? __________

    c) 1000 sectors long? __________








  3. Consider a classic UNIX system, with the following text file in its directory structure:
    /space/jones/.public-html/syssoft/hw/mid2.html
    
    As above, assume that opening a file reads that file's i-node into main memory, but does not read any sectors of that file; also assume that the i-node for the root directory of the file system is read into RAM when the system is started. Assume that each directory requires under 5120 bytes, that the average directory requires 1024 bytes, and by chance, each i-node is in a different disk sector. (1.8 points)

    a) How many low-level files would the directory manager need to read in order to open this file? ____________

    b) How many i-nodes would be read by the directory manager as it opens this file? ____________

    c) How many disk read operations would you expect to be required in order to open this file? ____________

  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. Sectors are numbered counterclockwise around the disk, because it spins clockwise. Cylinders are numbered from the outside in. The head accelerates at a uniform rate in moving from track to track, so the distance moved grows quadratically with the time taken. (2 points)

    a) How long will it take to read the following sequence of disk addresses, from the start of data transfer for the first read to the end of data transfer for the last. Measure all times in units of 1/64 second, assuming that the read of sector 0 cylinder 0 begins at time 0.

      transfer number    cyl sect   begin time   end time
    
             1            0   0         0           1  
    
             2            1   3       _____       _____
    
             3            5   4       _____       _____
    
             4            4   5       _____       _____
    
             5            0   1       _____       _____
    
    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? Rough estimates are acceptable!
       distance moved  time       distance moved  time
    
             0          0               4       ________
    
             1       ________           5       ________
    
             2       ________           6       ________
    
             3       ________           7       ________
    













  5. Consider a serial mouse. Every time the user clicks a mouse button, and every time the user moves the mouse, it sends a packet of data to the host computer over a serial communications line indicating the direction of the move and the state of the buttons. The current mouse coordinates are variables maintained in software.

    Suppose we wanted to use the mouse to imitate a touch screen, with the mouse buttons used to indicate touch pressure using some sensible scheme. Assume you already have a working touch screen input driver that expects to use the following interface registers.

    8-bit interface registers
          ___________
    PDX  |_____X_____| Top 8 bits of the X coordinate
    PDXY |__X__|__Y__| Bottom 4 bits of X, top 4 bits of Y
    PDY  |_____Y_____| Bottom 8 bits of the Y coordinate
    PDP  |/////|__P__| 4 bits giving finger pressure
    
    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 connected to the mouse to make a mouse driver that would behave (to user software) as if it was a touch screen driver. Write concisely. (2.2 points)
     ______________________________________________________________________
    
     ______________________________________________________________________
    
     ______________________________________________________________________
    
     ______________________________________________________________________
    
     ______________________________________________________________________