PHY 406 - Microprocessor Interfacing Techniques

Module 2

Disk Reading and Writing

Objective

In this module we will look at the theory and reality of writing data to disk. We will see that the actual rate of writing to disk is much lower than the theoretical rate.

There are two parts to this module: Disk Writing and Advanced. The Advanced section is optional and carries no marks.

In the real world questions sometimes don't have simple answers - because the world is not that simple! In this course you may (will!) find that some of the most simple questions have not-so-simple answers. Take heart, I am not trying to trick you - just getting you to think about the problem a bit more. I am always more interested in whether you have thought about the problem than whether you have the precise answer "in the back of the book". If you have any doubts about whether you are on the right track or not - it is your duty to corner me or the demonstrator and ask.

Preparation

You will need the following VIs

You should have read and understood the lecture notes on disks and how they are structured.



File Types

LabVIEW is capable of writing four types of file:

We will be concerned with spreadsheet files.

Local Variables

Another new feature of LabVIEW that the example VI uses is a "local variable". These are additional references to controls/indicators in the diagram and permit you to do two useful things: Change the value of a control on the front panel and alter the value of a control/indicator from several points in the VI (whether this makes sense is a matter for the programmer - ie you!).

You will find one of the local variables and the indicator on the first and third panels of the sequence in e:\l_view\examples\ex_write - on the first panel the "run/wait" indicator is set to "running" and on the last panel the local variable of the same name is used to set the indicator to "waiting". (You might like to think how you would do this without local variables).

You can generate a local variable by the sequence right click>>create>>local variable on a indicator or control on the siring diagram. You may have as many local variables for a single control or indicator as you wish.

A word of caution - since LabVIEW uses the label of the indicator/control to name the local variable, it is a good idea to have the indicator/control labeled with something meaningful before you create the local variable even if you don't display that label on the front panel.

Equipment

No external equipment is required for this module

If you have access to LabVIEW and another system, you can use that system, but you will have to think a bit about how your answer might differ from that obtained with a laboratory system.

Disk Reading and Writing

  1. The VI ex_write (which you will find under e:\l_view\examples\ex_write) shows you simply how to write a set of arrays of numbers to a spreadsheet file and time the result.
  2. Modify the VI to generate an array of size size of array (a control) and write this to an output file. The VI should then append similar arrays to the output file until it has written number of arrays (another control) arrays to the file. Thus at the end the file contains (size of array)*(number of arrays) numbers.
  3. Run the VI for various conditions and find out how long it takes to write a file for various size of array and number of arrays using an output file in the C:\temp directory. By running the VI with suitable numbers for the controls fill in the 2-dimensional table (shown below) of the "time to write one number" as a function of these parameters for powers of ten. You need not fill out any part of the table if you feel that the running time will exceed five minutes - but please justify your choices
  4. Can you see a pattern in your results? Eg does it take longer (per number) to write large arrays or short arrays? Does the total size of the file matter? Can you offer some explanations?
  5. By looking at the files, the size of the files or some other manner, find out how many bytes (characters) the system is using to write a real number. Is this a constant?
  6. Does the representation of the numbers in the file represent the precision with which the number is internally represented in binary? If not, how many characters would you need for that? (You may assume that the single precision numbers are stored in IEEE format) Hint: you should use scientific notation. How does that compare to the amount of internal storage used? You can look at a file by naming it with a ".txt" extension and then following the "My Computer" tree on the main windows display to the directory where the file is (Windows 95 will not show you the extension but the icon will look vaguely like a notepad) Double-clicking will enable you to look at the file although the system may have some trouble with the larger files.
  7. Write a similar VI or modify the one you have to read the arrays you have written and find out how long it takes to read arrays. Compare the time to read a number with the time to write it for various sizes of array. (You can just read the arrays into an array indicator to satisfy the LabVIEW syntax)
  8. If your disk has 823 cylinders, 4 heads, and 504, 512-byte sectors per track, rotates at 4500rpm and takes 2mS to step from track-to-track what is the theoretical maximum transfer speed in bytes/sec and how does that compare with your results above?
  9. For small files try using the F:\ drive instead of the C:\ drive and see how network speeds (theoretical maximum of 1.25Mbytes/sec on the Ethernet) compares with local disk speeds
  10. Delete all the temporary files you have created when you have finished.


Advanced

This section is for the intelligent/bored or otherwise fascinated. There are no marks for this section - only the satisfaction of solving a problem or two.





The Table

Number of Arrays

Size of Array

1 10^1 10^2 10^3 10^4 10^5 10^6 10^7
1
10^1
10^2
10^3
10^4
10^5
10^6
10^7