Class Disk

java.lang.Object
   |
   +----Disk

public class Disk
extends Object
implements Runnable
A software simulation of a Disk.

You may not change this class.

This disk is slow and ornery. It contains a number of blocks, all BLOCK_SIZE bytes long. All operations occur on individual blocks. You can't modify any more or any less data at a time.

To read or write from the disk, call beginRead() or beginWrite(). Both of these functions will start the action and return immediately. When the action has been completed, a call to Kernel.interrupt() will occur to let you know the Disk is ready for more.

It may take a while for the disk to seek from one block to another. Seek time is proportional to the difference in block number.

Warning: Don't call beginRead() or beginWrite() while the disk is busy! If you don't treat the Disk gently, the system will crash! (Just like a real machine!)

Author:
Douglas Thain (thain@cs.wisc.edu)
See Also:
Kernel

Variable Index

 o BLOCK_SIZE

Constructor Index

 o Disk(int)
Create a new Disk.

Method Index

 o beginRead(int, byte[])
Start a new read operation.
 o beginWrite(int, byte[])
Start a new write operation.
 o getSize()
Get the size of the disk
 o run()
Do not call this function.

Variables

 o BLOCK_SIZE
 public static final int BLOCK_SIZE

Constructors

 o Disk
 public Disk(int b)
Create a new Disk.

Parameters:
b - The number of blocks on the disk.

Methods

 o getSize
 public int getSize()
Get the size of the disk

Returns:
The number of blocks in this disk.
 o beginRead
 public synchronized void beginRead(int b,
                                    byte d[])
Start a new read operation.

Parameters:
b - The block number to read from.
d - The data area to write to.
 o beginWrite
 public synchronized void beginWrite(int b,
                                     byte d[])
Start a new write operation.

Parameters:
b - The block to write to.
d - The data area to read from.
 o run
 public void run()
Do not call this function.