Skip to content
Official PYQ · 1997

GATE CS 1997 Q74 — I/O Scheduling

Explain with AI

A program PP reads and processes 10001000 consecutive records from a sequential file FF stored on device DD without using any file system facilities. Given the following

  • Size of each record =3200= 3200 bytes
  • Access time of D=10D = 10 msecs
  • Data transfer rate of D=800×103D = 800 \times 10^3 bytes/second
  • CPU time to process each record =3= 3 msecs

What is the elapsed time of PP if

  1. FF contains unblocked records and PP does not use buffering?

  2. FF contains unblocked records and PP uses one buffer (i.e., it always reads ahead into the buffer)?

  3. records of FF are organized using a blocking factor of 22 (i.e., each block on DD contains two records of FF) and PP uses one buffer?

View worked solution

Answer: 9.006

First, let us calculate the basic parameters for a single record:

  • Record size: 32003200 bytes
  • Transfer rate: 800×103800 \times 10^3 bytes/sec = 800,000800,000 bytes/sec
  • Transfer time for 1 record: 3200800,000=0.004 seconds=4 ms\frac{3200}{800,000} = 0.004\text{ seconds} = 4\text{ ms}
  • Access time: 10 ms10\text{ ms}
  • Total I/O time for 1 record: 10 ms+4 ms=14 ms10\text{ ms} + 4\text{ ms} = 14\text{ ms}
  • CPU processing time for 1 record: 3 ms3\text{ ms}

Now, we evaluate each case:

Case A: Unblocked records, no buffering
Since there is no buffering, I/O and CPU processing happen sequentially for each of the 10001000 records:
Total time=1000×(14 ms+3 ms)=17,000 ms=17 seconds\text{Total time} = 1000 \times (14\text{ ms} + 3\text{ ms}) = 17,000\text{ ms} = 17\text{ seconds}

Case B: Unblocked records, one buffer (read-ahead)
With one buffer, the CPU processes the current record while the next record is being read in parallel:
Total time=Read 1st record+999×max⁡(Read time,CPU time)+Process last record\text{Total time} = \text{Read 1st record} + 999 \times \max(\text{Read time}, \text{CPU time}) + \text{Process last record}
Total time=14 ms+999×max⁡(14,3) ms+3 ms=14+999×14+3=14,003 ms=14.003 seconds\text{Total time} = 14\text{ ms} + 999 \times \max(14, 3)\text{ ms} + 3\text{ ms} = 14 + 999 \times 14 + 3 = 14,003\text{ ms} = 14.003\text{ seconds}

Case C: Blocking factor of 2, one buffer
Each block contains 22 records.

  • Number of blocks: 10002=500\frac{1000}{2} = 500 blocks
  • Block size: 2×3200=64002 \times 3200 = 6400 bytes
  • Transfer time for 1 block: 6400800,000=8 ms\frac{6400}{800,000} = 8\text{ ms}
  • Total I/O time for 1 block: 10 ms+8 ms=18 ms10\text{ ms} + 8\text{ ms} = 18\text{ ms}
  • CPU processing time for 1 block (2 records): 2×3 ms=6 ms2 \times 3\text{ ms} = 6\text{ ms}
Using one buffer, the I/O of block ii overlaps with the CPU processing of block i−1i-1:
Total time=Read 1st block+499×max⁡(Block I/O,Block CPU)+Process last block\text{Total time} = \text{Read 1st block} + 499 \times \max(\text{Block I/O}, \text{Block CPU}) + \text{Process last block}
Total time=18 ms+499×max⁡(18,6) ms+6 ms=18+499×18+6=9006 ms=9.006 seconds\text{Total time} = 18\text{ ms} + 499 \times \max(18, 6)\text{ ms} + 6\text{ ms} = 18 + 499 \times 18 + 6 = 9006\text{ ms} = 9.006\text{ seconds}

Free practice · Your answers on this page are not saved.

Published
Report a correction
Keep exploringMore I/O Scheduling questions