CSE306 Homework 4

CSE306 Processing Systems and Structures Lockwood, Spring 2004

Homework Assignment 4

Due: Wednesday, April 14, 2004, 3:30pm

75 Points

The answers to this homework assignment are to be submitted via the World Wide Web (WWW). You may use any web browser to submit this assignment. Your answers will be graded automatically. Your score will be immediately posted to the on-line gradebook. You will have the opportunity to resubmit the homework and improve your score.

ID Important: Use the same ID as selected in HW0
Name (First Last)


    Interrupt Service Routine Scheduling

    Jarvic 2000 has just recently upgraded the microprocessor on their artificial heart to a Intel Pentium 4. They have added two new sensors to their electro-mechanical heart: temperature and low-battery. Each sensor generates periodic interrupts and requires a fixed amount of processing time by the CPU.

    They have hired you, a world-renowned CSE306 graduate, to analyze the worst-case interrupt task completion times. Using the interrupt specifications below, complete the timing chart and determine the worst-case delay (completion time) for each of the tasks. It is your responsibility to ensure the safety of hundreds of future patients!

    1. Assume that the time to switch between interrupts is negligable.
    2. Assume that requests are buffered. If multiple tasks occur while the CPU is busy, they will be sequentially processed when the task is scheduled until either: (1) the CPU is interrupted with a higher priority interrupt or (2) until there are no more tasks to process.
    3. Enter 999 to indicate a task that will eventually have worst-case delay of infinity.
    4. Recall that a similar example problem was discussed in class during Lecture 15.
    5. It is helpful to work out the solutions using a timing worksheet

    Specify all numbers in decimal

    Task Pri. Run
    Time
    Dead-
    line
    Event
    Freq.
    Event
    Period
    CPU
    Load
    BP 1 1 ms 3 ms 10 ms
    OX 2 20 ms50 Hz 20%
    PH 3 2 ms 20 ms40 Hz
    VAG 4 1 ms 25 ms 20%
    TEMP 5 2 ms 30 ms 50 ms
    LoBAT6 50 ms 25 ms 12%

  1. Task BP: CPU Utilization (%)
    (2 pts)

  2. Task BP: Event Frequency (Hz)
    (2 pts)

  3. Task PH: Event Period (ms)
    (2 pts)

  4. Task VAG: Frequency (Hz)
    (2 pts)

  5. Total amount of time the CPU is run by any process during first 20 ms (ms)
    (2 pts)

  6. Total CPU Utilization (%)
    (2 pts)

    Assume that all tasks are preemptive except TEMP, which is non-preemptive.
    Calculate the worst-cast task completion delays

  7. Task BP Worst case delay (ms)
    (2 pts)

  8. Task OX: Worst case delay (ms)
    (2 pts)

  9. Task PH: Worst case delay (ms)
    (2 pts)

  10. Task VAG: Worst case delay (ms)
    (2 pts)

  11. Task TEMP: Worst case delay (ms)
    (2 pts)

  12. Task LoBAT: Worst case delay (ms)
    (2 pts)


    Hardware and Software Interrupts

    The BIOS (Basic I/O System), vBIOS (Video BIOS), and DOS provide a number of useful functions available through interrupt vectors. To use these commands, the opcode INT n is used to trigger the software interrupt. Using your lab manual, textbook, or lecture notes; determine what values are necessary to perform the following actions. Specify all numbers in hex.

    Hardware Interrupt vector number called when a character is received from the serial port on IRQ3

  13. INT (hex) (2 pts)

    Hardware Interrupt vector number called when a SCSI controller on IRQ13 interrupts the system.

  14. INT (hex) (2 pts)

    BIOS call to check to see if keyboard input is available. Sets ZeroFlag=1 if nothing is available.

  15. AH = (hex) ( 2 pts )
  16. INT (hex) (2 pt)

    DOS call to read system date (day of week, year, month, day of the month)

  17. AH = (hex) ( 2 pts )
  18. INT (hex) (2 pts)

    DOS call to open a file (preferred method)

  19. AH = (hex) ( 2 pt )
  20. INT (hex) (1 pt)


    Timer/Speaker Interrupt

    The speaker on the PC is controlled by the 8253 timer. To play a frequency, you must determine the value of a count then write that number to port 42h on the I/O bus using 2 8-bit moves. For each of the following frequencies, determine the first and second byte that you need to write to the timer.
    Specify all numbers in hex.

    512 Hz

  21. (1 pt)
  22. (1 pt)

    2304 Hz

  23. (1 pt)
  24. (1 pt)

    1792 Hz

  25. (1 pt)
  26. (1 pt)


    Analog Position Sensor

    IBM designers used resistive/capacitive time constants to implement a low-cost joystick interface on the PC. The position of the joystick is determined by polling the status register at port 201h of the I/O bus. Due to manufacturing variations of joystick hardware and differing clock speeds of PC systems, calibration is necessary to determine how time is related to position.

    Suppose that, during calibration, it is found that a loop performs 41 IN operations before the Y-Bit changes and 63 IN operations before the X-Bit changes when the joystick is in the lower-left position. Likewise, 381 and 427 IN operations (repectively) are performed before the Y-bits and X-bits change when the stick is in the upper-right position.

    For each of the following normalized positions, determine how many IN cycles would have been performed before the bit changed.

    Specify all numbers in decimal.

    Upper-Left Position:

  27. Xcount = (2 pts)
  28. Ycount = (2 pts)

    Center Position:

  29. Xcount = (2 pts)
  30. Ycount = (2 pts)

    Lower-Left quarter position (25%, 25%):

  31. Xcount = (2 pts)
  32. Ycount = (2 pts)


    Plotting points in graphics mode

    Suppose you wish to plot points in 320x200 graphics mode using the default palette (i.e, the first 32 pre-defined colors). Assuming that ES=VidGRSEG=A000h and that you are in graphics mode, determine DI and AL such that you will plot the following dots by executing

    STOSB

    Specify all numbers in decimal

    Blue dot at top row, right-most column of screen

  33. DI = (2 pts)
  34. AL = (1 pt)

    Bright-Red dot at the bottom-left corner of the screen

  35. DI = (1 pts)
  36. AL = (1 pt)

    Cyan dot at Row=20, Column=10

  37. DI = (1 pts)
  38. AL = (1 pt)


    Repeating String Commands

    Consider the following code with repeating string commands. Determine the values of OutArray upon completion of this program. Specify the answers in units of four bytes (i.e., The answer to the first question is the value of the first four bytes of OutArray). Every answer should have exactly four ASCII characters.

    InArray db '1234ABCDEFFEDCBA01234567' OutArray db '000000000000000000000000' .. mov ax,ds mov es,ax cld mov al, '8' mov ah, '2' mov si, offset InArray + 10 mov di, offset OutArray + 0 stosb movsb stosb movsb mov cx,2 rep stosw mov cx,2 rep movsw mov di,offset Inarray mov al,'4' mov cx,24 repne scasb add OutArray[12],cl mov al,'6' repne scasb add OutArray[15],cl std mov di,offset OutArray + 19 mov si,offset Inarray + 11 mov cx,4 rep movsb cld mov si,offset InArray mov di,offset InArray + 17 mov cx,10 mov bx,10 repe cmpsb sub bx,cx add OutArray[23],bl

  39. OutArray[0..3] = (2 pts)

  40. OutArray[4..7] = (2 pts)

  41. OutArray[8..11] = (2 pts)

  42. OutArray[12..15] = (2 pts)

  43. OutArray[16..19] = (2 pts)

  44. OutArray[20..23] = (2 pts)

    Once you have completed this homework assignment, press: