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

main.cc File Reference

#include "copyright.h"
#include "utility.h"
#include "thread.h"
#include "system.h"
#include <sys/time.h>
#include <stdio.h>
#include <signal.h>
#include <time.h>
#include <unistd.h>
#include <setjmp.h>
#include "synch.h"

Go to the source code of this file.

Defines

#define MAIN

Functions

void ThreadTest1 (int)
void Copy (char *unixFile, char *nachosFile)
void Print (char *file)
void PerformanceTest (void)
void StartProcess (char *file)
void ConsoleTest (char *in, char *out)
void MailTest (int networkID)
int main (int argc, char **argv)

Variables

sigjmp_buf schd_jmp


Define Documentation

#define MAIN
 

Definition at line 49 of file main.cc.


Function Documentation

void ConsoleTest char *  in,
char *  out
 

Referenced by main().

void Copy char *  unixFile,
char *  nachosFile
 

Referenced by main().

void MailTest int  networkID  ) 
 

Referenced by main().

int main int  argc,
char **  argv
 

Definition at line 92 of file main.cc.

References ASSERT, ConsoleTest(), Copy(), currentThread, DEBUG(), Delay(), Interrupt::Halt(), Initialize(), interrupt, Scheduler::IsEmpty(), MailTest(), PerformanceTest(), Print(), schd_jmp, schedule(), scheduler, StartProcess(), ThreadTest1(), and timerInit().

00093 { 00094 int argCount; // the number of arguments 00095 // for a particular command 00096 00097 DEBUG('t', "Entering main"); 00098 00099 if (sigsetjmp(schd_jmp, 1) != 0) // entry point for the scheduler 00100 { 00101 schedule(); 00102 00103 if (!scheduler->IsEmpty()) 00104 { 00105 while(1) 00106 ; 00107 } 00108 // never gets here 00109 printf("Yikes...\n"); 00110 } 00111 else 00112 { 00113 (void) Initialize(argc, argv); 00114 00115 for (argc--, argv++; argc > 0; argc -= argCount, argv += argCount) 00116 { 00117 argCount = 1; 00118 if (!strcmp(*argv, "-z")) // print copyright 00119 printf (copyright); 00120 #ifdef USER_PROGRAM 00121 if (!strcmp(*argv, "-x")) 00122 { // run a user program 00123 ASSERT(argc > 1); 00124 StartProcess(*(argv + 1)); 00125 argCount = 2; 00126 } 00127 else if (!strcmp(*argv, "-c")) 00128 { // test the console 00129 if (argc == 1) 00130 ConsoleTest(NULL, NULL); 00131 else 00132 { 00133 ASSERT(argc > 2); 00134 ConsoleTest(*(argv + 1), *(argv + 2)); 00135 argCount = 3; 00136 } 00137 interrupt->Halt(); // once we start the console, then 00138 // Nachos will loop forever waiting 00139 // for console input 00140 } 00141 #endif // USER_PROGRAM 00142 #ifdef FILESYS 00143 if (!strcmp(*argv, "-cp")) 00144 { // copy from UNIX to Nachos 00145 ASSERT(argc > 2); 00146 Copy(*(argv + 1), *(argv + 2)); 00147 argCount = 3; 00148 } 00149 else if (!strcmp(*argv, "-p")) 00150 { // print a Nachos file 00151 ASSERT(argc > 1); 00152 Print(*(argv + 1)); 00153 argCount = 2; 00154 } else if (!strcmp(*argv, "-r")) 00155 { // remove Nachos file 00156 ASSERT(argc > 1); 00157 fileSystem->Remove(*(argv + 1)); 00158 argCount = 2; 00159 } 00160 else if (!strcmp(*argv, "-l")) 00161 { // list Nachos directory 00162 fileSystem->List(); 00163 } 00164 else if (!strcmp(*argv, "-D")) 00165 { // print entire filesystem 00166 fileSystem->Print(); 00167 } 00168 else if (!strcmp(*argv, "-t")) 00169 { // performance test 00170 PerformanceTest(); 00171 } 00172 #endif // FILESYS 00173 #ifdef NETWORK 00174 if (!strcmp(*argv, "-o")) 00175 { 00176 ASSERT(argc > 1); 00177 Delay(2); // delay for 2 seconds 00178 // to give the user time to 00179 // start up another nachos 00180 MailTest(atoi(*(argv + 1))); 00181 argCount = 2; 00182 } 00183 #endif // NETWORK 00184 } 00185 00186 currentThread = 0; 00187 timerInit(); 00188 00189 ThreadTest1(0); 00190 if (!scheduler->IsEmpty()) 00191 schedule(); // to start the threads going 00192 } 00193 00194 // returns, then the program "nachos" 00195 // will exit (as any other normal program 00196 // would). But there may be other 00197 // threads on the ready list. We switch 00198 // to those threads by saying that the 00199 // will exit (as any other normal program 00200 // would). But there may be other 00201 // threads on the ready list. We switch 00202 // to those threads by saying that the 00203 // "main" thread is finished, preventing 00204 // it from returning. 00205 return(0); // Not reached... 00206 }

void PerformanceTest void   ) 
 

Referenced by main().

void Print char *  file  ) 
 

Referenced by main().

void StartProcess char *  file  ) 
 

Referenced by main().

void ThreadTest1 int   ) 
 

Definition at line 78 of file threadtest.cc.

References Thread::Fork(), PingPong(), and SimpleThread1().

Referenced by main().

00079 { 00080 printf("Entering SimpleTest\n"); 00081 00082 00083 Thread *t1 = new Thread("A thread"); 00084 Thread *t2 = new Thread("B thread"); 00085 Thread *t3 = new Thread("C thread"); 00086 Thread *t4 = new Thread("D thread"); 00087 Thread *t5 = new Thread("E thread"); 00088 Thread *t6 = new Thread("F thread"); 00089 Thread *t7 = new Thread("G thread"); 00090 t1->Fork(SimpleThread1, 'A'); 00091 t2->Fork(SimpleThread1, 'B'); 00092 t3->Fork(SimpleThread1, 'C'); 00093 t4->Fork(SimpleThread1, 'D'); 00094 t5->Fork(SimpleThread1, 'E'); 00095 t6->Fork(SimpleThread1, 'F'); 00096 t7->Fork(SimpleThread1, 'G'); 00097 00098 printf("Doing Ping Pong\n"); 00099 PingPong(); 00100 } /* ThreadTest1 */


Variable Documentation

sigjmp_buf schd_jmp
 

Definition at line 31 of file scheduler.cc.

Referenced by main().


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