GATE / CS ARCHIVE

GATE CSE 1997 / QUESTION 74(c)

Single-buffer timing

Operating Systems · I/O & Disk Scheduling · Full GATE CSE 1997 paper

GATE 1997, Q74(c) 2 marks · Descriptive
Report issue

I/O & Disk Scheduling

Question 74(c), GATE 1997: A program processes 1000 consecutive records of a sequential file on a device, without file-system facilities. Each record is 3200 bytes. Device access time is 10 ms per read; transfer rate is 800×10^3 bytes/s; CPU processing time is 3 ms per record. Copying a record from a buffer to a local variable takes negligible CPU time. Ignore additional overhead, and include startup and final processing time. The file uses blocking factor 2: each device block contains two records. The program uses one buffer. Find elapsed time, explicitly stating when the next read may begin and whether the program can retain a whole block outside the buffer.
Question 74(c), GATE 1997: A program processes 1000 consecutive records of a sequential file on a device, without file-system facilities. Each record is 3200 bytes. Device access time is 10 ms per read; transfer rate is 800×10^3 bytes/s; CPU processing time is 3 ms per record. Copying a record from a buffer to a local variable takes negligible CPU time. Ignore additional overhead, and include startup and final processing time. The file uses blocking factor 2: each device block contains two records. The program uses one buffer. Find elapsed time, explicitly stating when the next read may begin and whether the program can retain a whole block outside the buffer.
Question 74(c), GATE 1997: A program processes 1000 consecutive records of a sequential file on a device, without file-system facilities. Each record is 3200 bytes. Device access time is 10 ms per read; transfer rate is 800×10^3 bytes/s; CPU processing time is 3 ms per record. Copying a record from a buffer to a local variable takes negligible CPU time. Ignore additional overhead, and include startup and final processing time. The file uses blocking factor 2: each device block contains two records. The program uses one buffer. Find elapsed time, explicitly stating when the next read may begin and whether the program can retain a whole block outside the buffer.
Tap to enlarge
Answer & solution

Answer: 10.503 s with one-record local storage and reads starting only after the whole buffer is free; 9.006 s with whole-block staging or early overlap (no official key was published)

There are 1000/2=500 blocks. Each block holds 6400 bytes, so its transfer takes 6400/(800×103)=0.008 s=8 ms. Including the 10 ms access, one block read takes I=18 ms. Processing its two records takes 6 ms total. The words one buffer do not alone determine how the unread second record is protected while another read is started.

Model 1: one block buffer, one-record local variable, and a new block-read operation starts only after the buffer is entirely free. The first block arrives at t=18 ms. Copy record 1 locally and process it during 18–21. Record 2 must remain in the buffer during that computation. At 21, copy record 2 locally; the buffer is now free, so start the second block read during 21–39 while processing record 2 during 21–24. Thus each block arrival is 21 ms after the preceding one, not 18 ms: three CPU milliseconds are needed before the unread second record can leave the buffer.

The kth block arrives at 18+(k−1)×21 ms. For block 500 this is 10,497 ms. After it arrives, both final records still require 6 ms, giving 18+499×21+6=10,503 ms=10.503 s. Only the last record of each nonfinal block overlaps the following read. This schedule never overwrites a record that has not been copied out.

Model 2: copy the whole two-record block into separate local staging at negligible cost, releasing the input buffer immediately. Then all 6 ms of computation can overlap the following 18 ms read. The pipeline time is 18+499×max(18,6)+6=9006 ms=9.006 s. This model needs enough staging for two records, not just the single local record explicitly used in Model 1.

A second way to attain 9.006 s is to allow the next device access phase to begin before the buffer is free, while delaying actual writes until it is safe. Start the next 10 ms access immediately when the prior block arrives. The buffer's remaining record is copied out after 3 ms, well before the subsequent 8 ms transfer begins. Block arrivals can then remain 18 ms apart even with one-record local storage. That requires an I/O interface/scheduler that supports this early access, which the question does not explicitly describe.

Accordingly 9.006 s is the conventional whole-block-pipeline result, and 10.503 s is the stricter one-record/cannot-start-until-free result. Neither should be presented as unconditionally forced by the supplied wording. The distinction is about storage and I/O scheduling, not the arithmetic of the 18 ms block read.

Original paper, page 11