Main Page   Compound List   File List   Compound Members   File Members  

system.cc File Reference

#include "copyright.h"
#include "system.h"

Go to the source code of this file.

Functions

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

Variables

ThreadcurrentThread
ThreadthreadToBeDestroyed
Schedulerscheduler
Interruptinterrupt
Statisticsstats
Timertimer


Function Documentation

void Cleanup  
 

Definition at line 172 of file system.cc.

References Exit.

Referenced by Interrupt::Halt, and Initialize.

00173 {
00174     printf("\nCleaning up...\n");
00175 #ifdef NETWORK
00176     delete postOffice;
00177 #endif
00178     
00179 #ifdef USER_PROGRAM
00180     delete machine;
00181 #endif
00182 
00183 #ifdef FILESYS_NEEDED
00184     delete fileSystem;
00185 #endif
00186 
00187 #ifdef FILESYS
00188     delete synchDisk;
00189 #endif
00190     
00191     delete timer;
00192     delete scheduler;
00193     delete interrupt;
00194     
00195     Exit(0);
00196 }

void Initialize int    argc,
char **    argv
 

Definition at line 78 of file system.cc.

References ASSERT, atof, atoi, CallOnUserAbort, Cleanup, DebugInit, Interrupt::Enable, FALSE, NULL, RandomInit, RUNNING, Thread::setStatus, TimerInterruptHandler, and TRUE.

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

void TimerInterruptHandler int    dummy [static]
 

Definition at line 61 of file system.cc.

References Interrupt::getStatus, IdleMode, and Interrupt::YieldOnReturn.

Referenced by Initialize.

00062 {
00063     if (interrupt->getStatus() != IdleMode)
00064         interrupt->YieldOnReturn();
00065 }


Variable Documentation

Thread* currentThread
 

Definition at line 14 of file system.cc.

Interrupt* interrupt
 

Definition at line 17 of file system.cc.

Scheduler* scheduler
 

Definition at line 16 of file system.cc.

Statistics* stats
 

Definition at line 18 of file system.cc.

Thread* threadToBeDestroyed
 

Definition at line 15 of file system.cc.

Timer* timer
 

Definition at line 19 of file system.cc.


Generated on Mon Feb 10 09:54:52 2003 for nachos by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002
The University of Southern California does not screen or control the content on this website and thus does not guarantee the accuracy, integrity, or quality of such content. All content on this website is provided by and is the sole responsibility of the person from which such content originated, and such content does not necessarily reflect the opinions of the University administration or the Board of Trustees