Homework 11

22C:50 Section 2, Fall 2000

Not Due Wednesday Nov. 15, 2000

Douglas W. Jones

To help you study for the Midterm on Nov 15

  1. Consider the following code in our example assembly language:
    ; file1.eal
    X:  B   A
        B   B
    C   =   . - X
    D   =   3
        EXT A
        EXT B
        INT C
        INT D
    
    Consider the following additional piece of code in the same language:
    ; file2.eal
        INT A
        INT B
        EXT C
        EXT D
    X:  B   C
    Y:  B   D
    A   =   0
    B   =   Y - X
    
    If we assemble file1.eal to make file1.obj, and we assemble file2.eal to make file2.obj, and then we link file1.obj and file2.obj and load the result into memory starting at location zero, what is loaded in memory?

    What is the value of each identifier in the symbol table resulting from the assembly of each source file?

  2. Consider the interface to a touch screen, a device that fits over the front of a display screen and senses where your finger touches the screen. This device senses the following informationr: Our goal is to get a stream of "touch" messages, with no more than 100 touch messages per second, with messages only when the user is actually touching the screen, and no duplicate messages -- if I just rest my finger on the screen, without moving it or changing my pressure, I get just one message. Our harware also includes a real-time clock that gives us 100 clock interrupts per second.

    a) Suggest a set of 8-bit interface registers for the touch screen device device.

    b) Propose a format for touch messages, assuming that touch messages are delivered to the user as a stream of characters using the interface defined in Figure 9.3.

    c) Suggest code for the real-time-clock interrupt handler that would work with your answers to parts a and b to satisfy this specification.

  3. When you walk up to a computer system running the Panix operating system, you find that, if you type input before the running application is ready to read that input, the characters appear on the bottom line of the screen, and later, when your program is ready to read that input, the characters disappear from the bottom line on the screen and appear after the prompt, as if you'd just typed them. With reference to the material in Chapter 10, particularly that in Figure 10.7 and 10.13, explain how this must be implemented.

  4. Consider a disk with 8 sectors per track, 8 cylinders, and 8 surfaces. 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, and surfaces are numbered from the top down. The head accelerates at a uniform rate in moving from track to track, so the distance moved grows quadratically with the time taken. (moving for twice the time moves 4 times the distance).

    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.

        transfer number    cyl surf sect
    
               1            0    0    0
               2            0    1    0
               3            1    2    3
               4            5    3    4
               5            4    5    5
               6            0    6    3
               7            0    7    5
    
    b) How long will it take to read the same sectors in the optimal order, using a disk scheduler.

  5. Consider a classic UNIX file system where each file is made of 512 byte sectors, and files are described by i-nodes. Each i-node is 64 bytes, and i-nodes are stored in an array in a series of contiguous disk sectors, the i-table. The location of the i-table is given by the superblock, in sector 1 track 1 cylinder 1 (not 0,0,0, because this is the boot sector). One bit in each i-node tells whether the file is a directory or a normal file.

    Each i-node holds the file size, in bytes, plus pointers to the first 10 sectors of the file. Directory entries give the file name and i-number of the i-node describing the file. The root directory of the file system is described by i-node 0 in the i-table. The root directory occupies only one data sector (it only holds 12 items). One item in the root directory is a directory called etc. This directory contains 200 items, with each directory entry occupying 16 bytes. One file in /etc is called passwd. The file /etc/passwd contains 100 lines averaging 50 characters each.

    Enumerate all of the disk accesses it takes to read the file /etc/passwd, assuming that this disk has never been accessed since the system was started. Assume that the system never needs to read a sector twice -- that is, that it has sufficient buffer capacity to hold copies of all recently read sectors in RAM.

    How many data sectors get read? How many index sectors get read? How many i-nodes get read? Break this list down by the file or directory being referenced. Are there any other disk accesses not accounted for by the questions in this paragraph?