Main Page | Alphabetical List | Class List | File List | Class Members | File Members

system.h File Reference

#include "copyright.h"
#include "utility.h"
#include "thread.h"
#include "scheduler.h"
#include "interrupt.h"
#include "stats.h"
#include "timer.h"

Go to the source code of this file.

Defines

#define NSECS_PER_SEC   1000000000
#define PREEMPTION   1
#define TICKS_PER_SEC   15

Functions

void Initialize (int argc, char **argv)
void Cleanup ()

Variables

long timerCount
long secCount
ThreadcurrentThread
ThreadthreadToBeDestroyed
Schedulerscheduler
Interruptinterrupt
Statisticsstats
Timertimer


Define Documentation

#define NSECS_PER_SEC   1000000000
 

Definition at line 19 of file system.h.

Referenced by timerInit().

#define PREEMPTION   1
 

Definition at line 20 of file system.h.

Referenced by Scheduler::timerIntH().

#define TICKS_PER_SEC   15
 

Definition at line 21 of file system.h.

Referenced by Scheduler::timerIntH().


Function Documentation

void Cleanup  ) 
 

void Initialize int  argc,
char **  argv
 

Definition at line 90 of file system.cc.

References ASSERT, CallOnUserAbort(), Cleanup(), DebugInit(), Interrupt::Enable(), FALSE, interrupt, RandomInit(), scheduler, stats, threadToBeDestroyed, timer, and TRUE.

Referenced by main().

00091 { 00092 int argCount; 00093 char *debugArgs = ""; 00094 bool randomYield = FALSE; 00095 00096 00097 #ifdef USER_PROGRAM 00098 bool debugUserProg = FALSE; // single step user program 00099 #endif 00100 #ifdef FILESYS_NEEDED 00101 bool format = FALSE; // format disk 00102 #endif 00103 #ifdef NETWORK 00104 double rely = 1; // network reliability 00105 int netname = 0; // UNIX socket name 00106 #endif 00107 00108 for (argc--, argv++; argc > 0; argc -= argCount, argv += argCount) { 00109 argCount = 1; 00110 if (!strcmp(*argv, "-d")) { 00111 if (argc == 1) 00112 debugArgs = "+"; // turn on all debug flags 00113 else { 00114 debugArgs = *(argv + 1); 00115 argCount = 2; 00116 } 00117 } else if (!strcmp(*argv, "-rs")) { 00118 ASSERT(argc > 1); 00119 RandomInit(atoi(*(argv + 1))); // initialize pseudo-random 00120 // number generator 00121 randomYield = TRUE; 00122 argCount = 2; 00123 } 00124 #ifdef USER_PROGRAM 00125 if (!strcmp(*argv, "-s")) 00126 debugUserProg = TRUE; 00127 #endif 00128 #ifdef FILESYS_NEEDED 00129 if (!strcmp(*argv, "-f")) 00130 format = TRUE; 00131 #endif 00132 #ifdef NETWORK 00133 if (!strcmp(*argv, "-l")) { 00134 ASSERT(argc > 1); 00135 rely = atof(*(argv + 1)); 00136 argCount = 2; 00137 } else if (!strcmp(*argv, "-m")) { 00138 ASSERT(argc > 1); 00139 netname = atoi(*(argv + 1)); 00140 argCount = 2; 00141 } 00142 #endif 00143 } 00144 00145 DebugInit(debugArgs); // initialize DEBUG messages 00146 stats = new Statistics(); // collect statistics 00147 interrupt = new Interrupt; // start up interrupt handling 00148 scheduler = new Scheduler(); // initialize the ready queue 00149 //if (randomYield) // start the timer (if needed) 00150 //timer = new Timer(TimerInterruptHandler, 0, randomYield); 00151 timer = 0; 00152 00153 00154 threadToBeDestroyed = NULL; 00155 00156 // We didn't explicitly allocate the current thread we are running in. 00157 // But if it ever tries to give up the CPU, we better have a Thread 00158 // object to save its state. 00159 //currentThread = new Thread("main"); 00160 //currentThread->setStatus(RUNNING); 00161 00162 interrupt->Enable(); 00163 CallOnUserAbort(Cleanup); // if user hits ctl-C 00164 00165 #ifdef USER_PROGRAM 00166 machine = new Machine(debugUserProg); // this must come first 00167 #endif 00168 00169 #ifdef FILESYS 00170 synchDisk = new SynchDisk("DISK"); 00171 #endif 00172 00173 #ifdef FILESYS_NEEDED 00174 fileSystem = new FileSystem(format); 00175 #endif 00176 00177 #ifdef NETWORK 00178 postOffice = new PostOffice(netname, rely, 10); 00179 #endif 00180 }


Variable Documentation

Thread* currentThread
 

Definition at line 19 of file system.cc.

Referenced by Thread::Finish(), main(), Interrupt::OneTick(), Semaphore::P(), Machine::Run(), schedule(), Thread::Sleep(), Thread::Suspend(), Scheduler::timerIntH(), Thread::Yield(), and Thread::~Thread().

Interrupt* interrupt
 

Definition at line 22 of file system.cc.

Referenced by Console::CheckCharAvail(), Network::CheckPktAvail(), Cleanup(), Console::Console(), Machine::Debugger(), Thread::Finish(), Thread::Fork(), Initialize(), main(), Network::Network(), Semaphore::P(), PollFile(), Console::PutChar(), Machine::RaiseException(), Disk::ReadRequest(), Machine::Run(), schedule(), Network::Send(), Thread::Sleep(), Thread::Suspend(), Timer::Timer(), Timer::TimerExpired(), Scheduler::timerIntH(), Thread::UnSleep(), Semaphore::V(), Disk::WriteRequest(), and Thread::Yield().

Scheduler* scheduler
 

Definition at line 21 of file system.cc.

Referenced by Cleanup(), Thread::Fork(), Initialize(), main(), schedule(), Thread::Suspend(), Scheduler::timerIntH(), and Semaphore::V().

long secCount
 

Definition at line 29 of file system.cc.

Referenced by Statistics::Print(), and Scheduler::timerIntH().

Statistics* stats
 

Definition at line 23 of file system.cc.

Referenced by Console::CheckCharAvail(), Network::CheckPktAvail(), Disk::ComputeLatency(), Machine::Debugger(), Interrupt::DumpState(), Interrupt::Halt(), Initialize(), Interrupt::OneTick(), Disk::ReadRequest(), Machine::Run(), Interrupt::Schedule(), Network::SendDone(), Console::WriteDone(), and Disk::WriteRequest().

Thread* threadToBeDestroyed
 

Definition at line 20 of file system.cc.

Referenced by Thread::Finish(), Initialize(), and schedule().

Timer* timer
 

Definition at line 24 of file system.cc.

Referenced by Cleanup(), and Initialize().

long timerCount
 

Definition at line 28 of file system.cc.

Referenced by Statistics::Print(), and Scheduler::timerIntH().


Generated on Thu Sep 16 12:33:47 2004 for NachOS by doxygen 1.3.8