next up previous contents
Next: FileSystem Object Up: Nachos Filesystem Previous: Nachos Filesystem

SynchDisk

The SynchDisk object resides above the raw disk, providing a cleaner interface to its services. Specifically, it provides operations that block the calling thread until after the corresponding I/O complete interrupt takes place. In contrast, the Disk object provides the mechanism for initiating an I/O operation, but does not provide a convenient way of blocking the caller until the request completes. In addition, SynchDisk provides mutual exclusion, so that multiple threads can safely call the SynchDisk routines concurrently (recall that Disk cannot service more than one request at a time). Rather than using the Disk object directly, most applications will find it appropriate to use SynchDisk instead. SynchDisk provides the following operations:

SynchDisk(char *name):
Constructor takes the name of Unix file that holds the disk's contents.

This routine is called once at system ``boot time'' (e.g., as part of Nachos initialization process in system.cc), and it uses the Unix file ``DISK'' as its backing store. The SynchDisk object can be accessed through the global variable synchDisk.

RequestDone():
Interrupt service routine the underlying Disk object calls when an I/O operation completes. Simply issues the semaphore V operation.

ReadSector(int sectorNumber, char *data):
Acquire a mutual exclusion lock, invoke the underlying Disk::ReadSector operation and then wait on the semaphore that RequestDone signals when the I/O operation completes.

WriteSector(int sectorNumber, char *data):
Acquire a mutual exclusion lock, invoke the underlying Disk::WriteSector operation and then wait on the semaphore that RequestDone signals when the I/O operation completes.



Thomas Narten
Mon Feb 3 15:00:27 EST 1997