#include <disk.h>
Inheritance diagram for Disk::

Public Methods | |
| Disk (char *name, CallBackObj *toCall) | |
| Create a simulated disk. Invoke toCall->CallBack() when each request completes. More... | |
| ~Disk () | |
| Deallocate the disk. More... | |
| void | ReadRequest (int sectorNumber, char *data) |
| Read a single disk sector. These routines send a request to the disk and return immediately. Only one request allowed at a time! More... | |
| void | WriteRequest (int sectorNumber, char *data) |
| Write a single disk sector. These routines send a request to the disk and return immediately. Only one request allowed at a time! More... | |
| void | CallBack () |
| Invoked when disk request finishes. In turn calls, callWhenDone. More... | |
| int | ComputeLatency (int newSector, bool writing) |
| Return how long a request to newSector will take: (seek + rotational delay + transfer). More... | |
Private Methods | |
| int | TimeToSeek (int newSector, int *rotate) |
| time to get to the new track. More... | |
| int | ModuloDiff (int to, int from) |
| # sectors between to and from. More... | |
| void | UpdateLast (int newSector) |
Private Attributes | |
| int | fileno |
| UNIX file number for simulated disk. More... | |
| CallBackObj* | callWhenDone |
| Invoke when any disk request finishes. More... | |
| bool | active |
| Is a disk operation in progress? More... | |
| int | lastSector |
| The previous disk request. More... | |
| int | bufferInit |
| When the track buffer started being loaded. More... | |
Definition at line 56 of file disk.h.
|
|
Create a simulated disk. Invoke toCall->CallBack() when each request completes. Disk::Disk() Initialize a simulated disk. Open the UNIX file (creating it if it doesn't exist), and check the magic number to make sure it's ok to treat it as Nachos disk storage. "name" -- text name of the file simulating the Nachos disk "toCall" -- object to call when disk read/write request completes |
|
|
Deallocate the disk. Disk::~Disk() Clean up disk simulation, by closing the UNIX file representing the disk. |
|
|
Invoked when disk request finishes. In turn calls, callWhenDone. Disk::CallBack() Called by the machine simulation when the disk interrupt occurs. Reimplemented from CallBackObj. |
|
|
Return how long a request to newSector will take: (seek + rotational delay + transfer). Disk::ComputeLatency() Return how long will it take to read/write a disk sector, from the current position of the disk head. Latency = seek time + rotational latency + transfer time Disk seeks at one track per SeekTime ticks (cf. stats.h) and rotates at one sector per RotationTime ticks To find the rotational latency, we first must figure out where the disk head will be after the seek (if any). We then figure out how long it will take to rotate completely past newSector after that point. The disk also has a "track buffer"; the disk continuously reads the contents of the current disk track into the buffer. This allows read requests to the current track to be satisfied more quickly. The contents of the track buffer are discarded after every seek to a new track. Definition at line 245 of file disk.cc. Referenced by ReadRequest(), and WriteRequest().
|
|
|
# sectors between to and from. Disk::ModuloDiff() Return number of sectors of rotational delay between target sector "to" and current sector position "from" Definition at line 215 of file disk.cc. Referenced by ComputeLatency().
|
|
|
Read a single disk sector. These routines send a request to the disk and return immediately. Only one request allowed at a time! Disk::ReadRequest Simulate a request to read a single disk sector Do the read immediately to the UNIX file Set up an interrupt handler to be called later, that will notify the caller when the simulator says the operation has completed. Note that a disk only allows an entire sector to be read, not part of a sector. "sectorNumber" -- the disk sector to read "data" -- the buffer to hold the incoming bytes Definition at line 113 of file disk.cc. Referenced by SynchDisk::ReadSector().
|
|
|
time to get to the new track. Disk::TimeToSeek() Returns how long it will take to position the disk head over the correct track on the disk. Since when we finish seeking, we are likely to be in the middle of a sector that is rotating past the head, we also return how long until the head is at the next sector boundary. Disk seeks at one track per SeekTime ticks (cf. stats.h) and rotates at one sector per RotationTime ticks Definition at line 192 of file disk.cc. Referenced by ComputeLatency(), and UpdateLast().
|
|
|
Disk::UpdateLast Keep track of the most recently requested sector. So we can know what is in the track buffer. Definition at line 274 of file disk.cc. Referenced by ReadRequest(), and WriteRequest().
|
|
|
Write a single disk sector. These routines send a request to the disk and return immediately. Only one request allowed at a time! Disk::WriteRequest Simulate a request to write a single disk sector Do the write immediately to the UNIX file Set up an interrupt handler to be called later, that will notify the caller when the simulator says the operation has completed. Note that a disk only allows an entire sector to be written, not part of a sector. "sectorNumber" -- the disk sector to write "data" -- the bytes to be written Definition at line 149 of file disk.cc. Referenced by SynchDisk::WriteSector().
|
|
|
Is a disk operation in progress?
|
|
|
When the track buffer started being loaded.
|
|
|
Invoke when any disk request finishes.
|
|
|
UNIX file number for simulated disk.
|
|
|
The previous disk request.
|
1.2.8.1 written by Dimitri van Heesch,
© 1997-2001