edited by
7,536 views
33 votes
33 votes

A program $P$ reads and processes $1000$ consecutive records from a sequential file $F$ stored on device $D$ without using any file system facilities. Given the following

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

What is the elapsed time of $P$ if

  1. $F$ contains unblocked records and $P$ does not use buffering?

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

  3. records of $F$ are organized using a blocking factor of $2$ (i.e., each block on $D$ contains two records of $F$) and $P$ uses one buffer?

edited by

2 Answers

Best answer
46 votes
46 votes
  • $1000$ consecutive records
  • Size of $1$ record $= 3200$ Bytes
  • Access Time of device $D = 10$ms
  • Data Transfer Rate of device $D = 800\ast 10^3$ Bytes per second.
  • CPU time to process Each record $= 3$ms.
  • Time to transfer $1$ record $(3200 \;\text{Bytes})=\frac{3200\;\text{Bytes}}{800\ast 10^3} = 4$ms

(A) Unblocked records with No buffer. Hence, each time only when a record is fetched in its full entirety it will be processed.

Time to fetch $=$ Access Time for $D($Every time you'll access the device. This is also known as device latency$) +($Data transfer time)

$=10\text{ms} + 4\text{ms} = 14\text{ms}$

Total time taken by CPU for each record $=$ fetch $+$ execute $=14\text{ms} + 3\text{ms} = 17\text{ms}$

Total time for program $p=1000\ast 17\text{ms} = 17\text{sec}$ 

(B) Unblocked records and $1$ buffer. Records will be accessed one by one and for each record fetched into the buffer, the device delay has to be taken into account.

Time to bring one record into buffer $=10 + 4 = 14$ms.

Now let us see how the program goes.

  • At $t=0$ms, the program starts and the buffer is empty.
  • At $t=14$ms, $R_1$ fetched into the buffer and CPU starts processing it.
  • At $t=17$ms, cpu has processed $R_1$ and waiting for more records.
  • At $t=28$ms, buffer gets filled with $R_2$ and CPU starts processing it.

To get the Total time of the program we think in terms of the last record because when it is processed, all others would already have been processed too!.

Last record $R_{1000}$ would be fetched at $t=0+14\ast 1000=14000$ms and $3$ms will be taken by CPU to process this.

So, total elapsed time of program $P=14000+3=14003\text{ms} = 14.003\text{sec}$

(C) Each disk block contains $2$ records and Assuming buffer can hold $1$ disk block at a time.

So, $1$ Block Size $=2\ast 3200=6400$Bytes

Time to read a block $=\frac{6400}{800\ast 10^3} = 8$ms.

Each block read you have to incur the device access cost.

So, the total time to fetch one block and bring it into buffer $= 10 + 8 = 18$ms.

We have $1000$ files and so we need to read in $500$ blocks.

Each block has two records and therefore CPU time per block $= 6$ms.

Again to count the program time $P,$ we think in terms of the last Block.

Last block would be fetched at $t=0+(18\ast 500)=9000$ms.

After this $6$ ms more to process $2$ records present in the $500^{\text{th}}$ block.

So, program time $P=9000+6=9006\text{ms} = 9.006\text{sec}$.

edited by
25 votes
25 votes

here Access time $= 10ms$
     Process each Record $= 3ms$
     Transfer time $= 3200/800 \times 10^3 = 4ms$

  1. Elapsed time $=$ ( Access time $+$ Transfer time $+$ processing time) $\times$ number of records
                      $(10+4+3)\times 1000 =17000 \ ms = 17 \ sec$
  2. In this case $P$ uses one ' Read ahead' buffer the processing and transferring of records can be overlapped
       "Processing time is less than transfer time."
                    Elapsed time $=$ ( Access time $+$ Transfer time) $\times$ number of records
                                 $= (10+4)\times 1000 = 14 \ sec$
  3. In this case each block contain two records so we can access $500$ time to transfer $1000$ records.
                    Elapsed time $=$ ( Access time $+$ Transfer time) $\times$ number of records
                                 $= (10+4+4) \times 500 = 9 \ sec$
edited by
Answer:

Related questions

51 votes
51 votes
14 answers
3
25 votes
25 votes
6 answers
4
Kathleen asked Sep 29, 2014
17,442 views
An operating system contains $3$ user processes each requiring $2$ units of resource $R$. The minimum number of units of $R$ such that no deadlocks will ever arise is$3$$...