Main Page   Class Hierarchy   Compound List   File List   Compound Members   File Members  

SynchDisk Class Reference

The following 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. More...

#include <synchdisk.h>

Inheritance diagram for SynchDisk::

CallBackObj List of all members.

Public Methods

 SynchDisk (char *name)
 Initialize a synchronous disk, by initializing the raw Disk. More...

 ~SynchDisk ()
 De-allocate the synch disk data. More...

void ReadSector (int sectorNumber, char *data)
 Read a disk sector, returning only once the data is actually read . It calls Disk::ReadRequest and then waits until the request is done. More...

void WriteSector (int sectorNumber, char *data)
 Write a disk sector, returning only once the data is actually written. It calls Disk::WriteRequest and then waits until the request is done. More...

void CallBack ()
 Called by the disk device interrupt handler, to signal that the current disk operation is complete. More...


Private Attributes

Diskdisk
 Raw disk device. More...

Semaphoresemaphore
 To synchronize requesting thread with the interrupt handler. More...

Locklock
 Only one read/write request can be sent to the disk at a time. More...


Detailed Description

The following 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.

Definition at line 29 of file synchdisk.h.


Constructor & Destructor Documentation

SynchDisk::SynchDisk ( char * name )
 

Initialize a synchronous disk, by initializing the raw Disk.

SynchDisk::SynchDisk Initialize the synchronous interface to the physical disk, in turn initializing the physical disk.

"name" -- UNIX file name to be used as storage for the disk data (usually, "DISK")

Definition at line 30 of file synchdisk.cc.

SynchDisk::~SynchDisk ( )
 

De-allocate the synch disk data.

SynchDisk::~SynchDisk De-allocate data structures needed for the synchronous disk abstraction.

Definition at line 43 of file synchdisk.cc.


Member Function Documentation

void SynchDisk::CallBack ( ) [virtual]
 

Called by the disk device interrupt handler, to signal that the current disk operation is complete.

SynchDisk::CallBack Disk interrupt handler. Wake up any thread waiting for the disk request to finish.

Reimplemented from CallBackObj.

Definition at line 93 of file synchdisk.cc.

void SynchDisk::ReadSector ( int sectorNumber,
char * data )
 

Read a disk sector, returning only once the data is actually read . It calls Disk::ReadRequest and then waits until the request is done.

SynchDisk::ReadSector Read the contents of a disk sector into a buffer. Return only after the data has been read.

"sectorNumber" -- the disk sector to read "data" -- the buffer to hold the contents of the disk sector

Definition at line 60 of file synchdisk.cc.

void SynchDisk::WriteSector ( int sectorNumber,
char * data )
 

Write a disk sector, returning only once the data is actually written. It calls Disk::WriteRequest and then waits until the request is done.

SynchDisk::WriteSector Write the contents of a buffer into a disk sector. Return only after the data has been written.

"sectorNumber" -- the disk sector to be written "data" -- the new contents of the disk sector

Definition at line 78 of file synchdisk.cc.


Member Data Documentation

Disk * SynchDisk::disk [private]
 

Raw disk device.

Definition at line 54 of file synchdisk.h.

Lock * SynchDisk::lock [private]
 

Only one read/write request can be sent to the disk at a time.

Definition at line 57 of file synchdisk.h.

Semaphore * SynchDisk::semaphore [private]
 

To synchronize requesting thread with the interrupt handler.

Definition at line 55 of file synchdisk.h.


The documentation for this class was generated from the following files:
Generated at Wed Jul 4 11:32:24 2001 for Nachos by doxygen1.2.8.1 written by Dimitri van Heesch, © 1997-2001