Using the Disk Head Simulator

This document was last modified on March 2, 2004 to reflect changes made to version 0.54. This is the first version with a user's guide.


Table of Contents

Overview
System and User Requirements
Starting the Simulator
Basic Operation
Configuration
Runs and Experiments
Simulator Time
Distributions
Head Algorithms
Movement Algorithms
Layout Algorithms
Specifying Blocks
Specifying Bad Blocks
Running the Simulator
Logging
Demo Mode
Additional Features


Overview

The Disk Head Simulator is a Java application that can be used for exploring aspects of disk head scheduling. It supports the standard scheduling algorithms such as FCFS, SSTF, SCAN, LOOK, C-SCAN and C-LOOK as well as double buffered versions of these. Blocks to seek can be set up either as a list in a file or generated on the fly using distributions. These blocks can wither be static (all arriving before the simulation starts) or can arrive at a later time.

The time to do a seek can be set to be any linear function of the number of cylinders to move. The simulator supports both a uniform layout of blocks (a fixed number of blocks per cylinder) or a zoned layout in which the physical disk is divided into sections with different uniform layouts.

The simulator assumes that the operating system is doing the scheduling. It can either assume that the operating system has complete knowledge of the physical layout of the disk or the operating system can use a different layout. For example, the operating systems can use LBA (logical block addressing) in which it essentially assumes that each block is on a separate cylinder while the physical layout is zoned. The consequences of this mismatch can be explored using the simulator.

The simulator can generate graphs and tables of statistics which can be used to compare different disk layouts or seek algorithms. All data and graphs generated by the simulator can be placed in a log file in HTML format for display or printing.

The simulator is available for download and is freely available.


System and User Requirements

System requirements:

User requirements:

If you are only interested in this simulator, you can download a zip file disk.zip that contains all of the files that you need.

Running in a non-Windows environment:
If you installed the simulator by copying the files from a CD, the scripts may not have the correct permissions to run. The convert and rundisk files should be executable.
The ASCII files distributed with this distribution are in the Windows format in which lines end in a carriage return followed by a line feed. It may be more convenient to have the carriage returns removed. If you are running under UNIX, Linux, or Mac OSX, it may be more convenient to have the carriage returns removed. You can remove all of the carriage returns from these files by executing the convert script.


Starting the Simulator

If you are running from an image of the simulator CD, start in the disk subdirectory of the run directory. If you unzipped the DiskHead.zip file in a single directory, start in that directory. In either case, you can start the simulator from a command window by executing typing rundisk. In a Windows environment you can also just click on the file rundisk.bat.

If you do a custom installation, you can put the jar files anywhere you want. Modify the rundisk.bat (Windows) or rundisk (Unix, Linux, Mac OSX) file so that the JARDIR1 or JARDIR2 variables points to the location of the jar files.

If the simulator does not start, make sure you have the Java runtime executables in your path. In a command window, execute:
java -version
and make sure this displays a version later than 1.0.


Basic Operation

From a command or terminal window, execute rundisk. After a few seconds, you should see a small window appear similar to the one below.

Figure 1: The main simulator window.

The main simulator window has four parts.

  1. The first three lines in the window give version information.
  2. The Quit button in the upper right corner exits the simulator.
  3. The thin bar under the version information is a progress bar that shows the progress of the simulator. When the experiment is run, the upper progress bar (in red) gives the progress of the experiment and the lower bar (in blue) gives the progress of the current run.
  4. The bottom of the main window is taken up with buttons that control the simulator.
When you push the large green Run Experiment button it splits into two buttons: Pause Experiment and Abort Experiment until the experiment is complete. When the experiment has completed, the button changes back to its original form.

After running the experiment, the results can be displayed using the Show Table Data at the top of the middle column. This displays information about the result of the runs. Figure 2 shows the table for three runs.

Figure 2: The statistics generated by the simulator.

The Show Run Data Graph displays a graphical representation of one of the runs. If more than one run has been made, you will be presented with a list of runs to choose from. After choosing one of these, a graph of the selected run will appear. Figure 3 below shows a graph for the SSTF algorithm applied to the following track numbers:

Figure 3: A graphical representation of the SSTF algorithm.

The data and graphics generated by the simulator can be saved in an HTML file that can be displayed and printed by a standard browser. See the section on logging.


Configuration

The default configuration file is diskheadconfig but the simulator will use another file if it is specified on the command line when the simulator is started. A configuration file contains lines of keyword-value pairs. Lines beginning with a % are treated as comments and are ignored. The following table lists the valid keywords and the corresponding values.
KeywordValuesMeaning
useranythingThe name of the current user. This appears in the log file.
quietnone Turns off all sounds generated by the simulator.
runa filenameThis is the name of a file with extension .run. The extension is not listed. Each run file used by the simulator must have a corresponding run line in the configuration file.
expa filename This is the name of a file with extension .exp. The extension is not listed. Each exp file used by the simulator must have a corresponding run line in the configuration file.
inputa filename The name of an input file. Each input file specified in a run or exp file must appear here.
fontsizean integerThe default fontsize. This parameter is optional.
fontnamea font nameThis must be the name of a font that is recognized by the Java system. It is optional.
fontstylea font style This is either plain, bold or italics. It is optional.
logdira directory pathIf given, this is the directory for storing the log file. If not given, the log file is stored in the current directory.
logfilea filename The name of the log file. The extension .html will be appended to this. The default log file is logfile.html.
imagenamea filenameThis is the base filename used for images created for the log file. The default is gifimage.
datadira directory path If given, this is where input, run and exp file are located. By default, they are stored in the current directory.
portan integer If this value is greater than zero, remote logging will be used with this port. The default is 0.
standardcolors4 integersIf given, these numbers affect the intensity of the colors used by the simulator.


Runs and Experiments

A run (or more precisely and experimental run) consists of a running the simulator with a specific set of algorithms and input data. Three algorithms are needed to specify a run. Experimental runs are described in a file with extension .run. This file consists of lines, each containing a keyword followed by a value or values. The first line of the file should contain the keyword name followed by the name of the file without the .run extension. The second line should contain the keyword comment followed by a comment describing the run. This line is not used by the simulator.

The following lines of the run file contain the following information:
KeywordValues
keyText describing the run. This is used in many of the tables to distinguish this run from others.
doublebufferEither true or false. If true, new requests are put in a separator pending buffer until previous requests have been handled. When the current buffer is empty, the pending buffer becomes the current one. The default value is false.
inputA file name. The file contains a list of blocks to seek along with arrival time. Each line of the file contains an integer block number and a floating point arrival time. Multiple input lines can be used and the associated files are merged. Input files can also be combined with seek blocks generated by distributions as described below.
seedAn integer used to seed the random number generator used for the simulations. If specified it allows repeated simulations to generate identical results.
seedtimeEither true or false. If true, the seed is generated from the current time (with millisecond precision) and any seed specified with the seed keyword is ignored. The default is false.
startAn integer representing a block number. This is the starting block number of the disk head. The default is 0.
layoutThe value has one of two forms:
����� uniform n, where n is an integer
����� zoned n1 m1 n2 m2 ...
The first form is for a uniform layout with n blocks per cylinder. The second form is for a zoned layout in which ni is the number of blocks per sector and mi is the number of sectors in the ith zone. This represents the physical layout of the disk, used to determining how long it takes to perform a seek. Each run file must have exactly one layout entry.
oslayoutThe value parameter is the same as for the layout keyword. If specified, this is the layout assumed by the operating system. It is used to determine which block to seek next and where the operating system thinks the disk head is currently positioned. It defaults to the physical layout.
movementThis specifies how long it takes the disk head to move from one cylinder to another. The only currently supported movement algorithm is linear and specified by
����� linear n m
where n and m are integers. The time for a seek of x cylinders for x greater than 0 is nx + m. A seek of zero always takes 0 time. Each run file must have exactly one movement entry.
badfractionThe value is a floating point number between 0 and 1. It represents the fraction of references that are to bad blocks. A reference to a bad block is mapped to a location given by the baddestination keyword. It value defaults to 0.
baddestinationThe value parameter is a distribution. See the section on Probability Distributions for the format. This entry is necessary when badfraction is not 0. When a bad block is referenced, this distribution is used to generate the actual destination.
headThe value is one of the following specifications that determine when block to seek next.
����� FCFS
����� SSTF
����� LOOK
����� LOOK-
����� CLOOK
����� SCAN n
����� SCAN- n
����� CSCAN n
����� V x y
����� V- x y
These are described in more detail under Head Algorithms.
clearThis keyword does not use a value. The clear keyword is used in run modifications (described below) to remove any block requests specified in a run file
numblocksThe value is an integer specifying the number of block requests to generate from a distribution. The four keywords numblocks, firstarrival, interarrival and nextblock form a set and must all be present to specify a set of blocks to generate. The blockabsolute and blockrelative are optional keywords that modify the set of blocks. Multiple sets many be specified.
firstarrivalThe value is a floating point number representing the arrival time of the first block generated in this set.
interarrivalThe value is a distribution specification giving the interarrival time of the requested blocks.
nextblockThe value is a distribution specification that is used for generating the next block request.
blockabsoluteThis does not take any parameters. This is the default which indicates that the distribution given by the nextblock keyword generates absolute block numbers.
blockrelativeThis does not take any parameters. If given, it specifies that the block numbers generated by the nextblock distribution are relative to the previous block generated. This feature is not implemented in the current version of the simulator.

An experiment performs several runs and compares the results. An experiment is described by a file with extension .exp. Like the run file, it consists of lines containing keywords and values. The first two lines of an experiment file contain a name and comment field similar to those of a run file. The name line contains the name of the file without the .exp extension. The rest of the lines in an experiment file contain the keyword run followed by the name of a run file.

The name of the run file may be followed by any number of keyword-value pairs that modify the run. The keywords and values are the same as those listed in the table. The run modifications allow the same run file to be used several times in the same experiment.

For example, suppose that the file myrun.run uses the FCFS head movement algorithm. The following file called myexp.exp will make three runs, all with the same parameters but using three different head movement algorithms:

name myexp
comment Three head algorithms compared
run myrun key "FCFS" 
run myrun key "SSTF" head SSTF
run myrun key "C-LOOK" head CLOOK
The first run line has one modification, key while the others modify both the key and the head. Any modifications in the run line of an experiment file override the corresponding value in the named run file.


Simulator Time

The simulator is event driven. This means that the simulator program takes action when an event occurs. An event can either be an arrival of a new block request or the completion of a seek. Each event occurs at a specific time. Time is prepresented as a floating point number greater than or equal to zero.


Probability Distributions

Three probability distributions are supported at this time. When a probability distribution is specified in a file, it is represented by a single line of ASCII characters. The line starts with a word indicating the type of distribution and is followed by either a single floating point number representing the mean of the distribution, or in the case of the uniform distribution two floating point numbers representing the left and right endpoints of the interval.

The following distributions are supported:


Head Algorithms

The term head algorithm refers to the method the simulator uses to decide which block to seek next. At any given time there are a number of pending block requests is a buffer or list. Each algorithm is specified by a short keyword. Some of these require one or more arguments. The following head algorithms are supported by the simulator:
AlgorithmArgument typesDescription
SCANinteger The SCAN algorithm starts moving the head toward higher cylinder numbers until it reaches the last cylinder (given by the argument) stopping at pending blocks along the way. It then reverses direction and stops at pending blocks on the way back, moving al the way to cylinder 0.
SCAN-integer This is similar to the SCAN algorithm, but it starts moving toward lower cylinder numbers.
CSCANinteger This is similar to SCAN but does not stop at pending blocks on the way bak to cylinder 0.
LOOKnone LOOK is like SCAN, but it changes direction when there are no more pending blocks in the current direction.
LOOK-noneThis is like LOOK but it starts moving towards lower block numbers.
CLOOKnoneThis is like CSCAN but it changes directions when there are no more pending references.
FCFSnoneThis seeks blocks in the order in which they are requested.
SSTFnoneThe next block to seek is on the cylinder closest to the current one.
Vfloat integerThis is the Vr algorithm that takes two parameters, x and y. x is a floating point value between 0 and 1. and y is an integer representing the largest block number. This algorithm is a mixture of SSTF and SCAN with the x parameter indicating the mix. When x = 0 the algorithm is SSTF and when x = 1 the algorithm is SCAN.
V-float integerThis is like V but starts in the direction toward lower block numbers.

In addition, double buffering may be specified for each algorithm.


Movement Algorithms

The movement algorithm determines how long it takes to move the head from one track to another. The only supported movement algorithm is linear in which the time to move n tracks is a + bn. This formula is used whenever n > 0. The seek time for a seek of length 0 is always 0.


Layout Algorithms

The layout algorithm describes how sectors are laid out on the disk. There are two supported layouts: uniform and zoned. A uniform layout has a fixed number of tracks per cylinder. Since the simulator does not take into account rotational latency, the number of surfaces is not relevant. A uniform layout is specified as:
layout uniform n
where n is an integer greater than zero representing the number of sectors (blocks) per cylinder.

In a zoned layout, the disk is divided into zones, each one having a uniform layout. A zoned layout is specified by giving the number of zones, n followed by n pairs of integers, each giving the number of cylinders in that zone and the number of blocks per cylinder for that zone. For example,
layout zoned 3 10 8 10 16 10 24
would represent a disk with 3 zones, of 10 cylinders each. The first 10 cylinders have 8 blocks per cylinder, the next 10 have 16 blocks per cylinder and the last 10 have 24 blocks per cylinder.

The simulator allows for two different layouts, one the physical layout of the disk and the other being the logical view of the disk by the operating system. By default these are the same, but the layout as seen by the operating system may be set independently with the oslayout keyword. For example
layout zoned 3 10 8 10 16 10 24
oslayout uniform 16
indicates that the physical disk is zoned as above, but the operating system thinks that it is uniform.

The operating systems layout is used to determine the next block to seek while the physical layout is used (along with the movement algorithm) to determine how long it takes to perform the seek.


Specifying Blocks to Seek

The head algorithm is used to decide which block to seek next from a list of pending block requests. The simulator uses two methods for generating these block requests. For a short list of requests, the simplest methods is to just specify each requested block number along with the time at which the request is made. Use the input keyword with the name of a file as its one value to specify a file containing such a list. The format of this file is a sequence of lines, each containing a time (floating point value) followed by a block number (an integer). The lines of this file do not have to be in any particular order. More than one input file may be specified and you can specify both input files along with distributions described below.

An alternative to presenting a list of block numbers is to have the simulator generate block numbers using distributions. A collection of block numbers is specified with distributions by specifying four keyword-value pairs:

KeywordValue
numblocksAn integer specifying how many block requests will be generated.
firstarrivalA floating point value indicating the time at which the first of these blocks arrives.
interarrivalA distribution giving the interarrival times of the generated blocks.
nextblockA distribution used to generate the block request.

The four keyword-value pairs may occur in any order. Multiple distributions of block requests can be used by repeating these four keyword-value pairs.

If used in a run modification, the input file or distribution specifications add additional block requests to those specified in the run file. To clear all block request specifications, use the keyword clear.


Specifying Bad Blocks

Some disk drives automatically map bad sectors into sectors reserved for that purpose. When this happens, the operating system thinks it is accessing a block in a location different than the actual location on the disk. This has two consequences. The seek may take a different amount of time than expected by the operating system and the choice of the next block to seek will be based on incorrect information. The simulator can simulate this with two parameters, the badfraction and the baddistribution. The badfraction is the faction of block references that are to bad or mapped blocks. The baddistribution tells where these bad block are mapped.


Running the Simulator

The main simulator window of Figure 1 is shown again below. The three columns of buttons control the running of the simulator. The first column of buttons is described in the section on logging. The other buttons are described here.

Figure 1 (repeated): The main simulator window.

The large yellow button in the third column shows the name of the current experiment. If more than one experiment was specified in the configuration file, pushing this button changes to another experiment. Pushing the large green Run Experiment runs the current experiment. Pushing this button splits it into two buttons: Pause Experiment and Abort Experiment until the experiment is complete. When the experiment has completed, the button changes back to its original form. If the Pause Experiment button is pushed while the experiment is running, the experiment is temporarily stopped and this button changes into a Continue Experiment button. Pushing this button resumes the experiment. Pushing the Abort Experiment button ends the experiment and no data from the experiment is saved.

The remaining 6 buttons display information about completed runs.

The Show Table Data Button show a table of statistics for all of the runs similar to the one in the figure below.

Figure 2 (repeated): The statistics generated by the simulator.

Each run is labeled by its key. The top part of the table shows the three algorithms used by this run, the layout algorithm, the seek movement (or head) algorithm and the seek time (or seek movement) algorithm. Also shown are the number of seeks (Count column), the total and time seeking, the total idle time (when no head movement is occurring) and the maximum queue length.

The bottom part of the table gives detailed numeric data about the seek movement (number of tracks moved per seek), the seek time, and the seek request turnaround time. This latter time is the time between when the seek request is make and when the seek is completed. For each of these four statistics, the main, minimum, maximum and sample standard deviation are given.

The Done button at the bottom of the window is used to close the window.

The Show Run Data Graph allows you to select a run. When selected, a graphic showing the head movement is displayed. The figure below shows the Shortest Seek Time First (SSTF) graphic corresponding to the run in above table.

Figure 3 (repeated): A graphical representation of the SSTF algorithm.

The horizontal direction corresponds to head position. Each time the head changes direction, the trace moves down. A tic mark appears each time a seek position is reached that does not cause a change in direction. The buttons on the bottom of the provide some additional features. The Hide button temporarily hides the window. It can be brought back again using the Show Run Data Graph button. The Dispose button permanently destroys the window and all its resources. If the Show Run Data Graph button is used again for this run, a new window is created. If logging is active, the Log button will put a copy of this image (without the buttons) in the log file. The Scale button will attempt to rescale the graphics so that it entirely fits in the window. The Show Data button pops up the same table available through the Show Run Data Table of the main simulator window. It will be described later. The Demo button enters Demo Mode for this window. This mode is described in the section on Demo Mode. Lastly, the Controls window allows you to set the scale and colors of various features of this window.

The Show Run Data Table button shows a detailed table of data about all of the seeks made in the given run. The figure below shows the table for the SSTF run corresponding to the above graphic.

Figure 4: The table generated by the Show Run Data Table button.

For each seek it shows the starting and ending block, the time the request was made, the time the seek started, the time the seek ended, the time to do the seek (the difference of the previous two entries), the turnaround time (between request and completion) and the size of the pending queue when the request was made. At the bottom of the table, the total number of seeks for this run is shown. Two button at the bottom of the table allow you to hide or dispose of the window.

The Show Run Description button gives a description of the runs from the current experiments. This is essentially the contents of the run file modified by the modifications in the exp file. The table for the experiment shown in Figure x is given in the table below.

Figure 5: The table generated by the Show Run Description button.

The Show Exp Description button shows the contents of the exp file for the current experiment. The figure below shows an example.

Figure 6: The table generated by the Show Exp Description button.

The Show Info button displays a window giving a log of the runs made. It logs events (with wall clock time) such as the start and completion of each run. The window generated for the above run is shown below. The Scale button attempts to fit all of the data in the window if there are more lines than are currently displayed. Otherwise there will be a scroll bar on the right side of the window.

Figure 7: The table generated by the Show Info button.

The tables of data shown in Figures x, y, z, ... have a common format. They can all be resized. If the data to be displayed does not fit in the current format, scroll bars appear on the bottom or right side of the window. At the top of each window are two small buttons on either side. The &lt: and &gtl buttons will respectively decrease or increase the size of the font. If the Clr button is active it will clear the contents of the window. If logging is active, the Log will put a copy of the table in the log file.


Logging

The simulator can keep a log file in HTML format that can be displayed and printed from a standard browser. The log file is controlled by the column of 5 buttons on the left side of the simulator main window.

The name and location of the log file is controlled by logfile and logdir configuration parameters. The simulator will store images in the logging directory with a name based on the imagename configuration parameter.

You can change the name of the log and image files after the simulator starts by using the Change Log Filename button. This will allow you to change the logging directory, the filename and the image filename.

Normally, when you open a new log file it will replace an existing log file of the same name. Pushing the Replace Old Log button changes it to Append To Old Log and causes future opens to append to and existing log file of the same name. It also modifies the image file name so that images created do not interfere with those created previously.

Open the log file by pushing the Open Log button. This changes the Open Log button to Close Log so that the log can be closed. It also changes the the buttons to Log Comment and Stop Log. The Log Table Data is activated.

The Log Comment button allows you to insert a comment into the log file. The Stop Log button changes to Start Log when pushed and allows you to temporarily stop and restart automatic logging without closing the log file.

The Log Table Data button inserts a table of data into the log file. The information in this table is similar to the information displayed with the Show Table Data button.


Demo Mode

The run data graph display for each run contains a Demo Mode button. When this button is pushed, demo mode for this display is entered. Any number of graphs for the same experiment can be simultaneously in demo mode. When this mode is active, a demo control window appears, similar to the one below.

Figure 8: The control panel for demo mode.

This control panel allows you to control the simulator time. It contains a Start Button, a Time Slider, a Speed Slider, an Update Rate slider, and Pause/Resume button and a Hide button. Each of the sliders controls a particular quantity and consists of three rows of widgets of the same color. The first widget shows the value of the quantity being controlled. The second row contains three buttons. The first button rounds the value. The Double and Half buttons control the upper limit of the slider value. The third row contains the slider.

You can either set it manually by moving the time slider or to automatically run the time at a fixed rate by pushing the Start Demo button. The speed at which time progresses is controlled the Speed Slider. How often the graphs update is controlled by the last slider, labeled Frames per second. Next there is the Pause button. When it is pushed, the simulation time stops and the button changes to a Resume button. Lastly, the Hide button hides the demo control window. You can bring this window back by turning off and on the demo in any of the run data graph displays.

Figure 9: Demo mode.

Figure 9 shows graph displays of three algorithms in demo mode along with the demo control panel. The time is paused at 44.695. Each of the graphs shows the state of the simulation at that time. At the top of each graph are tick marks in blank, green and red. The black marks are pending requests. The request of the current seek is shown in green. The current head position is shown in red.


Additional Features

Remote Logging If the remote port is set to a positive integer, and the simulator is started from a browser, the simulator will attempt send to log file to the server using the remote port. This used when the simulator is run from a browser pointing to the simulator web site.