Writing Data To Disk

If the disk is in "write" mode and the disk has not yet finished writing data from memory to disk, then copy the value from the next memory cell to disk index. More formally,

if the following are true:
  • value of cell 49 at time t = 1
  • value of cell 48 at time t = 1
  • disk bytes read at time t < value of cell 46 at time t

then disk byte at index: ((value of cell 47 at time t) + (disk bytes read at time t)) time: (t + 1) = value of cell (30 + (disk bytes read at time t)) at time t

For example, suppose that the following are true:

  • value of cell 30 at time 105 = 98
  • value of cell 46 at time 105 = 3
  • value of cell 47 at time 105 = 3
  • value of cell 48 at time 105 = 1
  • value of cell 49 at time 105 = 1
  • disk bytes read at time 105 = 0

Cell 46 says that we want to copy 3 bytes, cell 47 tells us to copy to disk index 3, and cell 48 says we are writing to disk. We can see that bytes read so far (0) is less than total data size (3). Thus we can conclude that:

disk byte at index: ((value of cell 47 at time 105) + (disk bytes read at time 105)) time: (105 + 1) = value of cell (30 + (disk bytes read at time 105)) at time 105

After some substitutions and simplification, this becomes:

disk byte at index: 3 time: 106 = 98

click here for the full proof.

Try running the simulator below to see the disk copy cell #30 to disk index 3.

Time: 0
LW Computer IO Simulator

Comments

Please log in to add comments