Main Page   Compound List   File List   Compound Members   File Members  

sysdep.h

Go to the documentation of this file.
00001 // sysdep.h 
00002 //      System-dependent interface.  Nachos uses the routines defined
00003 //      here, rather than directly calling the UNIX library functions, to
00004 //      simplify porting between versions of UNIX, and even to
00005 //      other systems, such as MSDOS and the Macintosh.
00006 //
00007 // Copyright (c) 1992-1993 The Regents of the University of California.
00008 // All rights reserved.  See copyright.h for copyright notice and limitation 
00009 // of liability and disclaimer of warranty provisions.
00010 
00011 #ifndef SYSDEP_H
00012 #define SYSDEP_H
00013 
00014 #include "copyright.h"
00015 
00016 // Check file to see if there are any characters to be read.
00017 // If no characters in the file, return without waiting.
00018 extern bool PollFile(int fd);
00019 
00020 // File operations: open/read/write/lseek/close, and check for error
00021 // For simulating the disk and the console devices.
00022 extern int OpenForWrite(char *name);
00023 extern int OpenForReadWrite(char *name, bool crashOnError);
00024 extern void Read(int fd, char *buffer, int nBytes);
00025 extern int ReadPartial(int fd, char *buffer, int nBytes);
00026 extern void WriteFile(int fd, char *buffer, int nBytes);
00027 extern void Lseek(int fd, int offset, int whence);
00028 extern int Tell(int fd);
00029 extern void Close(int fd);
00030 extern bool Unlink(char *name);
00031 
00032 // Interprocess communication operations, for simulating the network
00033 extern int OpenSocket();
00034 extern void CloseSocket(int sockID);
00035 extern void AssignNameToSocket(char *socketName, int sockID);
00036 extern void DeAssignNameToSocket(char *socketName);
00037 extern bool PollSocket(int sockID);
00038 extern void ReadFromSocket(int sockID, char *buffer, int packetSize);
00039 extern void SendToSocket(int sockID, char *buffer, int packetSize,char *toName);
00040 
00041 // Process control: abort, exit, and sleep
00042 extern void Abort();
00043 extern void Exit(int exitCode);
00044 extern void Delay(int seconds);
00045 
00046 // Initialize system so that cleanUp routine is called when user hits ctl-C
00047 extern void CallOnUserAbort(VoidNoArgFunctionPtr cleanUp);
00048 
00049 // Initialize the pseudo random number generator
00050 extern void RandomInit(unsigned seed);
00051 extern int Random();
00052 
00053 // Allocate, de-allocate an array, such that de-referencing
00054 // just beyond either end of the array will cause an error
00055 extern char *AllocBoundedArray(int size);
00056 extern void DeallocBoundedArray(char *p, int size);
00057 
00058 // Other C library routines that are used by Nachos.
00059 // These are assumed to be portable, so we don't include a wrapper.
00060 extern "C" {
00061 int atoi(const char *str);
00062 double atof(const char *str);
00063 int abs(int i);
00064 
00065 #include <stdio.h>              // for printf, fprintf
00066 #include <string.h>             // for DEBUG, etc.
00067 }
00068 
00069 #endif // SYSDEP_H

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