Main Page   Class Hierarchy   Compound List   File List   Compound Members   File Members  

sysdep.cc File Reference

#include "copyright.h"
#include "debug.h"
#include "sysdep.h"
#include "stdlib.h"
#include "unistd.h"
#include "sys/time.h"
#include "sys/file.h"
#include <sys/socket.h>
#include <sys/un.h>
#include <signal.h>
#include <sys/types.h>
#include <sys/mman.h>

Go to the source code of this file.

Functions

int getpagesize (void)
unsigned sleep (unsigned)
int mprotect (char *, unsigned int, int)
void CallOnUserAbort (void(*func)(int))
void Delay (int seconds)
void Abort ()
void Exit (int exitCode)
void RandomInit (unsigned seed)
unsigned int RandomNumber ()
char* AllocBoundedArray (int size)
void DeallocBoundedArray (char *ptr, int size)
bool PollFile (int fd)
int OpenForWrite (char *name)
int OpenForReadWrite (char *name, bool crashOnError)
void Read (int fd, char *buffer, int nBytes)
int ReadPartial (int fd, char *buffer, int nBytes)
void WriteFile (int fd, char *buffer, int nBytes)
void Lseek (int fd, int offset, int whence)
int Tell (int fd)
void Close (int fd)
bool Unlink (char *name)


Function Documentation

void Abort ( )
 

Abort Quit and drop core.

Definition at line 120 of file sysdep.cc.

char * AllocBoundedArray ( int size )
 

AllocBoundedArray Return an array, with the two pages just before and after the array unmapped, to catch illegal references off the end of the array. Particularly useful for catching overflow beyond fixed-size thread execution stacks.

Note: Just return the useful part!

"size" -- amount of useful space needed (in bytes)

Definition at line 172 of file sysdep.cc.

void CallOnUserAbort ( void(* cleanup)(int) )
 

CallOnUserAbort Arrange that "func" will be called when the user aborts (e.g., by hitting ctl-C.

Definition at line 96 of file sysdep.cc.

void Close ( int fd )
 

Close Close a file. Abort on error.

Definition at line 346 of file sysdep.cc.

void DeallocBoundedArray ( char * p,
int size )
 

DeallocBoundedArray Deallocate an array of integers, unprotecting its two boundary pages.

"ptr" -- the array to be deallocated

"size" -- amount of useful space in the array (in bytes)

Definition at line 196 of file sysdep.cc.

void Delay ( int seconds )
 

Sleep Put the UNIX process running Nachos to sleep for x seconds, to give the user time to start up another invocation of Nachos in a different UNIX shell.

Definition at line 109 of file sysdep.cc.

void Exit ( int status )
 

Exit Quit without dropping core.

Definition at line 131 of file sysdep.cc.

void Lseek ( int fd,
int offset,
int whence )
 

Lseek Change the location within an open file. Abort on error.

Definition at line 318 of file sysdep.cc.

int OpenForReadWrite ( char * name,
bool crashOnError )
 

OpenForReadWrite Open a file for reading or writing. Return the file descriptor, or error if it doesn't exist.

"name" -- file name

Definition at line 267 of file sysdep.cc.

int OpenForWrite ( char * name )
 

OpenForWrite Open a file for writing. Create it if it doesn't exist; truncate it if it does already exist. Return the file descriptor.

"name" -- file name

Definition at line 250 of file sysdep.cc.

bool PollFile ( int fd )
 

PollFile Check open file or open socket to see if there are any characters that can be read immediately. If so, read them in, and return TRUE.

"fd" -- the file descriptor of the file to be polled

Definition at line 219 of file sysdep.cc.

void RandomInit ( unsigned seed )
 

RandomInit Initialize the pseudo-random number generator. We use the now obsolete "srand" and "rand" because they are more portable!

Definition at line 143 of file sysdep.cc.

unsigned int RandomNumber ( )
 

RandomNumber Return a pseudo-random number.

Definition at line 154 of file sysdep.cc.

Referenced by NetworkOutput::Send(), and Timer::SetInterrupt().

void Read ( int fd,
char * buffer,
int nBytes )
 

Read Read characters from an open file. Abort if read fails.

Definition at line 281 of file sysdep.cc.

int ReadPartial ( int fd,
char * buffer,
int nBytes )
 

ReadPartial Read characters from an open file, returning as many as are available.

Definition at line 294 of file sysdep.cc.

int Tell ( int fd )
 

Tell Report the current location within an open file.

Definition at line 330 of file sysdep.cc.

bool Unlink ( char * name )
 

Unlink Delete a file.

Definition at line 358 of file sysdep.cc.

void WriteFile ( int fd,
char * buffer,
int nBytes )
 

WriteFile Write characters to an open file. Abort if write fails.

Definition at line 306 of file sysdep.cc.

int getpagesize ( void )
 

Referenced by AllocBoundedArray(), and DeallocBoundedArray().

int mprotect ( char *,
unsigned int,
int )
 

Referenced by AllocBoundedArray(), and DeallocBoundedArray().

unsigned sleep ( unsigned )
 

Referenced by Delay().


Generated at Wed Jul 4 11:32:22 2001 for Nachos by doxygen1.2.8.1 written by Dimitri van Heesch, © 1997-2001