Class FastDisk

Object
  extended byDisk
      extended byFastDisk
All Implemented Interfaces:
Runnable

public class FastDisk
extends Disk

A new and improved Disk. You may not change this class.

This disk is so much faster than the previous model that read and write operations appear to finish in no time. Because disk is so fast, beginRead and beginWrite wait for the operation to finish rather than causing a CPU interrupt when they complete.

See Also:
Disk, Kernel

Nested Class Summary
 
Nested classes inherited from class Disk
Disk.DiskException
 
Field Summary
 
Fields inherited from class Disk
BLOCK_SIZE, busy, currentBlock, data, DISK_SIZE, readCount, targetBlock, writeCount
 
Constructor Summary
FastDisk(int size)
          Creates a new FastDisk.
 
Method Summary
 void beginRead(int blockNumber, byte[] buffer)
          Deprecated. Do not use this method. Use read instead.
 void beginWrite(int blockNumber, byte[] buffer)
          Deprecated. Do not use this method. Use read instead.
 void read(int blockNumber, byte[] buffer)
          Performs a read operation.
 void write(int blockNumber, byte[] buffer)
          Performs a write operation.
 
Methods inherited from class Disk
delay, finishOperation, flush, run, waitForRequest
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FastDisk

public FastDisk(int size)
Creates a new FastDisk.

Parameters:
size - the total size of this disk, in blocks.
Method Detail

read

public void read(int blockNumber,
                 byte[] buffer)
Performs a read operation. When this method returns, the operation is complete.

Parameters:
blockNumber - The block number to read from.
buffer - a data area to hold the data read.
See Also:
Disk.beginRead(int, byte[])

write

public void write(int blockNumber,
                  byte[] buffer)
Performs a write operation. When this method returns, the operation is complete.

Parameters:
blockNumber - The block number to write to.
buffer - a data area to hold the data to be written.
See Also:
Disk.beginWrite(int, byte[])

beginRead

public void beginRead(int blockNumber,
                      byte[] buffer)
Deprecated. Do not use this method. Use read instead.

Starts a new read operation.

Overrides:
beginRead in class Disk
Parameters:
blockNumber - The block number to read from.
buffer - A data area to hold the data read. This array must be allocated by the caller and have length of at least BLOCK_SIZE. If it is larger, only the first BLOCK_SIZE bytes of the array will be modified.

beginWrite

public void beginWrite(int blockNumber,
                       byte[] buffer)
Deprecated. Do not use this method. Use read instead.

Starts a new write operation.

Overrides:
beginWrite in class Disk
Parameters:
blockNumber - The block number to write to.
buffer - A data area containing the data to be written. This array must be allocated by the caller and have length of at least BLOCK_SIZE. If it is larger, only the first BLOCK_SIZE bytes of the array will be sent to the disk.