|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnachos.machine.RK05Disk
public class RK05Disk
This version of the Disk class simulates a physical disk device with the geometry (203 cylinders, 2 heads, 12 sectors per track, 512 bytes per sector) of the old RK05 disk packs used on PDP-11 minicomputers in the mid-1970s. I wanted to make this an extension of the existing Disk class, but that would have required eliminating static members of that class, which would in turn have forced rewriting of portions of the file system. Maybe next semester!
Field Summary | |
---|---|
static int |
NumCylinders
Number of cylinders per disk. |
static int |
NumHeads
Number of surfaces per cylinder (i.e. |
static int |
NumSectors
Total number of sectors per disk. |
static int |
NumTracks
Number of tracks per disk. |
static int |
SectorSize
Number of bytes per disk sector. |
static int |
SectorsPerTrack
Number of sector per disk track. |
Constructor Summary | |
---|---|
RK05Disk(java.lang.String name,
InterruptHandler callWhenDone)
Create a simulated disk. |
Method Summary | |
---|---|
static short |
bytesToShort(byte[] buffer,
int pos)
Utility method to deserialize a sequence of two bytes into a short. |
static void |
printSector(boolean writing,
int sector,
byte[] data)
Dump the data in a disk read/write request, for debugging. |
void |
readRequest(int sectorNumber,
byte[] data,
int index)
Called to submit a request to read a single disk sector. |
static void |
shortToBytes(short val,
byte[] buffer,
int pos)
Utility method to serialize a short into a sequence of two bytes. |
void |
writeRequest(int sectorNumber,
byte[] data,
int index)
Called to submit a request to write a single disk sector. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int SectorSize
public static final int SectorsPerTrack
public static final int NumCylinders
public static final int NumHeads
public static final int NumTracks
public static final int NumSectors
Constructor Detail |
---|
public RK05Disk(java.lang.String name, InterruptHandler callWhenDone)
name
- Text name of the file simulating the Nachos disk.callWhenDone
- Interrupt handler to be notified each time disk
read/write request completes.Method Detail |
---|
public void readRequest(int sectorNumber, byte[] data, int index)
sectorNumber
- The disk sector to read.data
- The buffer to hold the incoming bytes.public void writeRequest(int sectorNumber, byte[] data, int index)
sectorNumber
- The disk sector to write.data
- The bytes to be written.public static void printSector(boolean writing, int sector, byte[] data)
writing
- True if the request is a write request.sector
- The sector number in the request.data
- The buffer for data read/written in the request.public static void shortToBytes(short val, byte[] buffer, int pos)
val
- The short value to be serialized.buffer
- The buffer into which the value is to be serialized.pos
- Starting offset from the beginning of the buffer at which
the serialized bytes representing the value are to be placed.public static short bytesToShort(byte[] buffer, int pos)
buffer
- The buffer from which the value is to be deserialized.pos
- Starting offset from the beginning of the buffer at which
the serialized bytes representing the value exist.
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |