Question 3:A given processor requires 2000 cycles to perform a context switch and start an interrupt handler (and the same number of cycles to switch back to the program that was running when the interrupt occurred), or 400 cycles to poll an I/O device. An I/O device attached to that processor makes 250 requests per second, each of which takes 10,000 cycles to resolve once the handler has been started. By default, the processor polls every 0.5 ms if it is not using interrupts. a. How many cycles per second does the processor spend handling I/O from the device if interrupts are used? b. How many cycles per second are spent on I/O if polling is used (include all polling attempts)? Assume the processor only polls during time slices when user programs are not running, so do not include any context-switch time in your calculation. c. How often would the processor have to poll for polling to take as many cycles per second as interrupt

 Answer:

Given Data:

  • Context switch for interrupt: 2000 cycles to switch to the interrupt handler and 2000 cycles to switch back.
  • Total cycles for context switching for one interrupt: 2000 + 2000 = 4000 cycles.
  • Cycles to resolve each I/O request: 10,000 cycles.
  • I/O device requests per second: 250 requests.
  • Cycles to poll an I/O device: 400 cycles.
  • Polling interval: 0.5 ms (milliseconds).

Part (a): Cycles Spent Handling I/O if Interrupts are Used

  1. Interrupt Handling Per Request:

    • Cycles for context switching (to and from): 4000 cycles.
    • Cycles to resolve each I/O request: 10,000 cycles.
    • Total cycles per I/O request when using interrupts = 4000 cycles + 10,000 cycles = 14,000 cycles.
  2. Total Requests Per Second:

    • I/O device makes 250 requests per second.
  3. Total Cycles Spent Per Second:

    • Total cycles per second = 250 requests/second * 14,000 cycles/request
    • Total cycles per second = 3,500,000 cycles/second.

So, the processor spends 3,500,000 cycles per second handling I/O from the device if interrupts are used.

Part (b): Cycles Spent on I/O if Polling is Used

  1. Polling Interval:

    • Polling every 0.5 ms means the processor polls 1000 times per second (since 1 second = 1000 ms, and 1000 ms / 0.5 ms = 2000 polls/second).
  2. Cycles Per Polling Attempt:

    • Each polling attempt takes 400 cycles.
  3. Total Cycles for Polling Per Second:

    • Total cycles per second for polling = 2000 polls/second * 400 cycles/poll
    • Total cycles per second for polling = 800,000 cycles/second.
  4. Handling I/O Requests:

    • Each request takes 10,000 cycles to resolve, and there are 250 requests per second.
    • Total cycles for handling I/O requests = 250 requests/second * 10,000 cycles/request
    • Total cycles for handling I/O requests = 2,500,000 cycles/second.
  5. Total Cycles Spent Per Second:

    • Total cycles spent on I/O per second = Cycles for polling + Cycles for handling requests
    • Total cycles per second = 800,000 cycles/second + 2,500,000 cycles/second
    • Total cycles per second = 3,300,000 cycles/second.

So, the processor spends 3,300,000 cycles per second on I/O if polling is used.

Part (c): Polling Frequency to Match Interrupt Cycle Usage

To find the polling frequency that would result in the same number of cycles spent per second as when using interrupts:

  1. Target Cycle Usage:

    • From part (a), the cycles per second with interrupts are 3,500,000 cycles/second.
  2. Current Polling Cost:

    • Each polling attempt takes 400 cycles.
    • Let 𝑓 be the polling frequency (polls per second).
  3. Cycle Calculation:

    • Total cycles for polling per second = 400×𝑓.
    • Total cycles for handling requests per second = 2,500,000 cycles/second.
  4. Equation to Match Interrupt Cycle Usage:

    400𝑓+2,500,000=3,500,000
  5. Solve for 𝑓:

    400𝑓=3,500,0002,500,000
    400𝑓=1,000,000
    𝑓=1,000,000400
    𝑓=2500 polls/second

So, the processor would have to poll 2500 times per second for polling to take as many cycles per second as interrupts.

Comments

Popular posts from this blog

7.Write a program to read a list containing item name, item code and cost interactively and produce a three-column output as shown below. NAME CODE COST Turbo C++ 1001 250.95 C Primer 905 95.70 ------------- ------- ---------- ------------- ------- ---------- Note that the name and code are left-justified and the cost is right-justified with a precision of two digits. Trailing zeros are shown.

Questions 2 : Assume there are three small caches, each consisting of four one-word blocks. On cache is direct-mapped, a second is two-way set-associative, and the third is fully associative. Find the number of hits for each cache organization given the following sequence of block addresses: 0, 8, 6, 5, 10, 15 and 8 are accessed twice in the same sequence. Make a tabular column as given below to show the cache content on each of columns as required. Show all the pass independently pass. Draw as many numbers Assume the writing policy is LRU. Memory location Hit/Mis Add as many columns as required

Quetion 6 : Consider the "in-order-issue/in-order-completion" execution sequence shown in f In Figure Decode OWE Execute 12 12 12 14 16 13 16 13 15 15 16 Write 024/06/02 11 3 4 11 12 13 13 N 15 16 a. Identify the most likely reason why I could not enter the execute fourth cycle. stage until the [2] b. Will "in-order issue/out-of-order completion" or "out-of-order issue/out-of-order completion" fix this? If so, which? Explain