tac0S
Template Affectional Command Operating System
synchdisk.h
Go to the documentation of this file.
1 
10 #include "copyright.h"
11 
12 #ifndef SYNCHDISK_H
13 #define SYNCHDISK_H
14 
15 #include "disk.h"
16 #include "synch.h"
17 
28 class SynchDisk {
29  public:
30  SynchDisk(const char* name); // Initialize a synchronous disk,
31  // by initializing the raw Disk.
32  ~SynchDisk(); // De-allocate the synch disk data
33 
34  void ReadSector(int sectorNumber, char* data);
35  // Read/write a disk sector, returning
36  // only once the data is actually read
37  // or written. These call
38  // Disk::ReadRequest/WriteRequest and
39  // then wait until the request is done.
40  void WriteSector(int sectorNumber, char* data);
41 
42  void RequestDone(); // Called by the disk device interrupt
43  // handler, to signal that the
44  // current disk operation is complete.
45 
46  private:
47  Disk *disk; // Raw disk device
48  Semaphore *semaphore; // To synchronize requesting thread
49  // with the interrupt handler
50  Lock *lock; // Only one read/write request
51  // can be sent to the disk at a time
52 };
53 
54 #endif // SYNCHDISK_H
void WriteSector(int sectorNumber, char *data)
SynchDisk::WriteSector Write the contents of a buffer into a disk sector. Return only after the data ...
Definition: synchdisk.cc:94
void ReadSector(int sectorNumber, char *data)
SynchDisk::ReadSector Read the contents of a disk sector into a buffer. Return only after the data ha...
Definition: synchdisk.cc:76
The following class defines a physical disk I/O device. The disk has a single surface, split up into "tracks", and each track split up into "sectors" (the same number of sectors on each track, and each sector has the same number of bytes of storage).
Definition: disk.h:57
void RequestDone()
SynchDisk::RequestDone Disk interrupt handler. Wake up any thread waiting for the disk request to fin...
Definition: synchdisk.cc:109
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).
Definition: synchdisk.h:28
The following class defines a "semaphore" whose value is a non-negative integer. The semaphore has on...
Definition: synch.h:42
SynchDisk(const char *name)
SynchDisk::SynchDisk Initialize the synchronous interface to the physical disk, in turn initializing ...
Definition: synchdisk.cc:46
Data structures for synchronizing threads.
Definition: synch.h:73
Definition: out.c:36
~SynchDisk()
SynchDisk::~SynchDisk De-allocate data structures needed for the synchronous disk abstraction...
Definition: synchdisk.cc:59
Data structures to emulate a physical disk