CSE306 Homework 4

CSE306 Processing Systems and Structures Lockwood, Spring 2003

Homework Assignment 4

Due: Monday April 16, 2003, 5pm (extended)

75 Points

The answers to this homework assignment are to be submitted via the World Wide Web (WWW). You may use any Mosaic browsers (such as Netscape or Internet Explorer) to submit this assignment. No special software is needed. 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, Inc., has just recently upgraded the hardware on their artificial heart. 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!

    • Assume that the time to switch between interrupts is negligable.
    • 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.
    • Enter 999 to indicate a task that will eventually have worst-case delay of infinity.
    • Recall that a similar example problem was discussed in class during Lecture 15.

    Specify all numbers in decimal

    Task Pri. Run
    Time
    Dead-
    line
    Event
    Freq.
    Event
    Period
    CPU
    Load
    BP 1 2 ms 11 ms 20 ms
    OX 2 13 ms100 Hz 10%
    PH 2 6 ms 37 ms10 Hz
    VAG 3 1 ms 45 ms 20%
    TEMP 4 3 ms 40 ms 30 ms
    LoBAT5 9 ms 49 ms 60 ms

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

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

  3. Task OX: Run Time (ms)
    (2 pts)

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

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

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

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

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

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

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

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


    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.

    256 Hz

  11. (2 pts)
  12. (2 pts)

    1024 Hz

  13. (2 pts)
  14. (2 pts)

    1792 Hz

  15. (2 pts)
  16. (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

    Dark Green dot at top row, right-most column of screen

  17. DI = (2 pts)
  18. AL = (1 pt)

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

  19. DI = (2 pts)
  20. AL = (1 pt)

    Yellow dot at the bottom-right of the screen

  21. DI = (2 pts)
  22. 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.

    OutArray db '000000000000000000000000' InArray db 'CSE306 IS THE GREATEST CLASS ON THE FACE OF THE EARTH' ... mov ax, cseg ; Initialize DS register mov ds, ax mov es, ax ; Note ES=DS for these examples ... mov ah, 'C' ; In the real world, you'll mov dh, 'X' ; be forced to deal with programmers mov al, 'E' ; that don't comment their code... ; Instead, they just add silly ; comments or leave comments blank. mov di, offset OutArray mov si, 36 + offset InArray mov cx, 4 cld stosw stosb inc di movsw movsw rep stosb mov si,18 + offset InArray mov cx,2 rep movsw mov cx,14 mov al,'I' mov di,offset InArray repne scasb add OutArray[16],CL ...

  23. OutArray[0..3] = (3 pts)

  24. OutArray[4..7] = (3 pts)

  25. OutArray[8..11] = (3 pts)

  26. OutArray[12..15] = (3 pts)

  27. OutArray[16..19] = (3 pts)

    Compressed Image Data

    Run-length encoding can greatly reduce the number of bytes required to represent data with redundancy. PCX uses run-length encoding to encode image data. Analyze the following 8x8 image and determine how it would be compressed

    Given the following assumptions and hints below, determine the contents of the file

    • Recall from lecture that PCX files have a header
    • Assume that Xmin=1 and Ymin=1.
    • Recall that PCX compression never spans multiple lines.
    • Assume that the image uses the default VGA palette discussed in lecture.
      • See the on-line assignment to view the image in color
      • Except for black, assume that all colors in the image are bright.
    • Enter all values in hex
      (1 pts/each)

  28. Image[0] =
  29. Image[8] =
    ..
  30. Image[128] =
  31. Image[129] =
  32. Image[130] =
  33. Image[131] =
  34. Image[132] =
  35. Image[133] =
  36. Image[134] =
  37. Image[135] =
  38. Image[136] =
  39. Image[137] =
  40. Image[138] =
  41. Image[139] =
  42. Image[140] =
    ..
  43. Image[148] =
  44. Image[149] =
  45. Image[150] =
  46. Image[151] =

Once you have completed this homework assignment, press: