University of Wisconsin Computer Sciences Header Map (repeated with 
textual links if page includes departmental footer) Useful Resources Research at UW-Madison CS Dept UW-Madison CS Undergraduate Program UW-Madison CS Graduate Program UW-Madison CS People Useful Information Current Seminars in the CS Department Search Our Site UW-Madison CS Computer Systems Laboratory UW-Madison Computer Sciences Department Home Page UW-Madison Home Page

Homework 5

CS/ECE 354, Fall 2003


Send e-mail questions to Nitin Agrawal, nitina@cs.wisc.edu
Due Monday, November 24th, before 5 pm.


Homework (48 points total)

  1. (12 points) When a program is executed, it enters the kernel with the following values in the coprocessor 0 registers. As for Program 5, assume Cause register bit 10 refers to the clock, bit 11 the keyboard, and bit 12 the display.
        $12 (Status) : 0x00001c3c  
        $13 (Cause)  : 0x00000400  
        $14 (EPC)    : 0x0040000c
    
    The memory for the text segment looks like this, with words listed in big-endian order:
            [0x00400000]	0x40806000 0x3c081001 0x8d090000 0x11200005
            [0x00400010]	0x3402000b 0x01202020 0x0000000c 0x21080001
            [0x00400020]	0x0401fff9 0x3404000a 0x3402000b 0x0000000c
            [0x00400030]	0x3402000a 0x0000000c 0x00000000 0x00000000
    

    (a) Was the exception a trap or an interrupt?

    
    

    (b) What was the reason for entering the kernel?

    
    

    (c) What was the address of the instruction that executing immediately before the kernel was entered?

    
    

    (d) Give a reasonable TAL description of the instruction executing immediately before the kernel was entered.

    
    
  2. (6 points) Write a short sequence of code that a kernel could use to enable display interrupts (and not change anything else).

  3. (6 points) Consider a kernel that implements puts in the kernel by spin-waiting until all characters of a string are printed on a device that prints 1000 characters per second. Assume that it take the computer 100 ns to execute the code to print the next character, adjust queue pointers, etc. What fraction of time would the kernel spend doing useless spin-waiting when printing a long string (so you can ignore start up and finishing)?

  4. (6 points) What must a re-entrant kernel do before it can re-enable interrupts? Explain why.

  5. (6 points) Consider the least six significant bits of the MIPS Status register. Recall that least-significant bit gives whether interrupts are currently enabled (1 means "yes"), while the next bit gives whether the current mode is user (1) or kernel (0). The next two bits give the previous status of these values, while the next two give the old (previous to previous) values. Thus:
        Bit 5     Bit 4     Bit 3     Bit 2     Bit 1    Bit 0
    
        Old KU | Old IE | Prev KU | Prev IE | Curr KU | Curr IE
    
    What would be the value of these bits if the following were true: Originally a user level program was running but it was interrupted. This interrupt caused a reentrant interrupt-driven kernel to run, but it too was interrupted while executing the keyboard interrupt handler. The second interrupt cause the kernel to be re-entered and the processor is currently storing the value of the EPC register.
    
    
  6. (12 points) The futuristic disk drive has 1 platter with two surfaces. There is one head for each surface. Only one head can be read at a time. There are a total of 118,196 cylinders. When formatted, it contains 2,293,995,840 512-byte sectors. It rotates at 8,000 RPM. The time to move a head from one track to an adjacent one is 0.3 milliseconds.

    (a) What is the total capacity of the drive (in bytes)?

    (b) What is the average number of sectors per track?

    (c) What is the minimum time it takes to read all the sectors on one track?

    (d) What is the minimum time it takes to read all the sectors on one cylinder?

    (e) What is the minimum time it takes to read all the sectors on one surface?

    (f) What is the minimum time it takes to read all the sectors on the disk?


Handing In the Homework

Turn in your file containing answers by running the script:


  handinHW5 hw5file

where hw5file is an example name of a file containing the homework answers. The handinHW script submits your homework for you. No printout will be turned in.