|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnachos.kernel.devices.DiskDriver
public class DiskDriver
This class defines a "synchronous" disk abstraction. As with other I/O devices, the raw physical disk is an asynchronous device -- requests to read or write portions of the disk return immediately, and an interrupt occurs later to signal that the operation completed. (Also, the physical characteristics of the disk device assume that only one operation can be requested at a time). This class provides the abstraction that for any individual thread making a request, it waits around until the operation finishes before returning.
Nested Class Summary | |
---|---|
private class |
DiskDriver.DiskIntHandler
DiskDriver interrupt handler class. |
Field Summary | |
---|---|
private nachos.machine.Disk |
disk
Raw disk device. |
private Lock |
lock
Only one read/write request can be sent to the disk at a time. |
private Semaphore |
semaphore
To synchronize requesting thread with the interrupt handler. |
Constructor Summary | |
---|---|
DiskDriver(java.lang.String name)
Initialize the synchronous interface to the physical disk, in turn initializing the physical disk. |
Method Summary | |
---|---|
void |
readSector(int sectorNumber,
byte[] data,
int index)
Read the contents of a disk sector into a buffer. |
void |
writeSector(int sectorNumber,
byte[] data,
int index)
Write the contents of a buffer into a disk sector. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private nachos.machine.Disk disk
private Semaphore semaphore
private Lock lock
Constructor Detail |
---|
public DiskDriver(java.lang.String name)
name
- UNIX file name to be used as storage for the disk data
(usually, "DISK")Method Detail |
---|
public void readSector(int sectorNumber, byte[] data, int index)
sectorNumber
- The disk sector to read.data
- The buffer to hold the contents of the disk sector.index
- Offset in the buffer at which to place the data.public void writeSector(int sectorNumber, byte[] data, int index)
sectorNumber
- The disk sector to be written.data
- The new contents of the disk sector.index
- Offset in the buffer from which to get the data.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |