Main Page   Compound List   File List   Compound Members   File Members  

progtest.cc File Reference

#include "copyright.h"
#include "system.h"
#include "console.h"
#include "addrspace.h"
#include "synch.h"

Go to the source code of this file.

Functions

void StartProcess (char *filename)
void ReadAvail (int arg)
void WriteDone (int arg)
void ConsoleTest (char *in, char *out)

Variables

Consoleconsole
SemaphorereadAvail
SemaphorewriteDone


Function Documentation

void ConsoleTest char *    in,
char *    out
 

Definition at line 69 of file progtest.cc.

References Console::GetChar, Semaphore::P, Console::PutChar, ReadAvail, and WriteDone.

Referenced by main.

00070 {
00071     char ch;
00072 
00073     console = new Console(in, out, ReadAvail, WriteDone, 0);
00074     readAvail = new Semaphore("read avail", 0);
00075     writeDone = new Semaphore("write done", 0);
00076     
00077     for (;;) {
00078         readAvail->P();         // wait for character to arrive
00079         ch = console->GetChar();
00080         console->PutChar(ch);   // echo it!
00081         writeDone->P() ;        // wait for write to finish
00082         if (ch == 'q') return;  // if q, quit
00083     }
00084 }

void ReadAvail int    arg [static]
 

Definition at line 59 of file progtest.cc.

References Semaphore::V.

Referenced by ConsoleTest.

00059 { readAvail->V(); }

void StartProcess char *    filename
 

Definition at line 24 of file progtest.cc.

References ASSERT, FALSE, AddrSpace::InitRegisters, NULL, and AddrSpace::RestoreState.

Referenced by main.

00025 {
00026     OpenFile *executable = fileSystem->Open(filename);
00027     AddrSpace *space;
00028 
00029     if (executable == NULL) {
00030         printf("Unable to open file %s\n", filename);
00031         return;
00032     }
00033     space = new AddrSpace(executable);    
00034     currentThread->space = space;
00035 
00036     delete executable;                  // close file
00037 
00038     space->InitRegisters();             // set the initial register values
00039     space->RestoreState();              // load page table register
00040 
00041     machine->Run();                     // jump to the user progam
00042     ASSERT(FALSE);                      // machine->Run never returns;
00043                                         // the address space exits
00044                                         // by doing the syscall "exit"
00045 }

void WriteDone int    arg [static]
 

Definition at line 60 of file progtest.cc.

References Semaphore::V.

Referenced by ConsoleTest.

00060 { writeDone->V(); }


Variable Documentation

Console* console [static]
 

Definition at line 50 of file progtest.cc.

Semaphore* readAvail [static]
 

Definition at line 51 of file progtest.cc.

Semaphore* writeDone [static]
 

Definition at line 52 of file progtest.cc.


Generated on Mon Feb 10 09:54:51 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