CS306 Homework 4

CS306 Processing Systems and Structures Lockwood, Spring 2002

Homework Assignment 4

Due: Saturday, April 13, 2002, 5pm

75 Points

The answers to this homework assignment are to be submitted via the World Wide Web (WWW). You may use any Mosaic browser (such as Netscape or Internet Explorer) to submit this assignment. No special software is needed. Your answers will be graded automatically. You may resubmit this homework to improve your score. Your best score is posted immediately to the on-line gradebook.

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 CS306 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 (rounded to the nearest integer if necessary).

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

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

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

  3. Task OX: Event Period (ms)
    (3 pts)

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

  5. Total CPU Utilization (%)
    (3 pts)

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

  6. Task BP Worst case delay (ms)
    (3 pts)

  7. Task OX: Worst case delay (ms)
    (3 pts)

  8. Task PH: Worst case delay (ms)
    (3 pts)

  9. Task VAG: Worst case delay (ms)
    (3 pts)

  10. Task TEMP: Worst case delay (ms)
    (3 pts)

  11. Task LoBAT: Worst case delay (ms)
    (3 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

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

  12. DI = (1 pt)
  13. AL = (1 pt)

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

  14. DI = (1 pt)
  15. AL = (1 pt)

    Blue dot at Row=20, Column=10

  16. DI = (1 pt)
  17. 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, '2' mov ah, '8' mov si, InArray + 6 mov di, OutArray + 0 stosb movsb stosb movsb mov cx,2 rep stosw mov cx,2 rep movsw mov di,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,OutArray + 14 mov si,Inarray + 10 mov cx,4 rep movsb cld mov si,InArray mov di,InArray + 15 mov cx,10 mov bx,10 repe cmpsb sub bx,cx add [OutArray+23],bl

  18. [OutArray + 0..3] = (2 pts)

  19. [OutArray + 4..7] = (2 pts)

  20. [OutArray + 8..11] = (2 pts)

  21. [OutArray + 12..15] = (2 pts)

  22. [OutArray + 16..19] = (2 pts)

  23. [OutArray + 20..23] = (2 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 pt/each)

  24. [Image + 0] =
  25. [Image + 8] =
    ..
  26. [Image + 128] =
  27. [Image + 129] =
  28. [Image + 130] =
  29. [Image + 131] =
  30. [Image + 132] =
  31. [Image + 133] =
  32. [Image + 134] =
  33. [Image + 135] =
  34. [Image + 136] =
  35. [Image + 137] =
  36. [Image + 138] =
  37. [Image + 139] =
  38. [Image + 140] =
  39. [Image + 141] =
  40. [Image + 142] =
  41. [Image + 143] =
  42. [Image + 144] =
  43. [Image + 145] =
  44. [Image + 146] =
  45. [Image + 147] =
  46. [Image + 148] =
  47. [Image + 149] =
  48. [Image + 150] =
    ..


    Once you have completed this homework assignment, press: