tac0S
Template Affectional Command Operating System
Macros | Functions
exception.cc File Reference

Entry point into the Nachos kernel from user programs. More...

#include "copyright.h"
#include "system.h"
#include "syscall.h"
#include "userthread.h"

Macros

#define MAX_FILENAME_BUFFER   200
 

Functions

void ExitThread (void *object)
 
void copyStringFromMachine (int from, char *to, unsigned size)
 
void copyMachineFromString (char *from, int to, unsigned size)
 
void ProcedurePutInt (int n)
 
void ProcedureGetInt (int *n)
 
unsigned int SYScreateUserThread (void *f, void *arg)
 SYScreateUserThread Syscall function that create a UserThread (and the thread) More...
 
void * SYSWaitForChildExited (unsigned int CID)
 SYSWaitForChildExited. More...
 
void SYSWaitForAllChildExited ()
 SYSWaitForAllChildExited Call SYSWaitForChildExited on all child.
 
void SYSExitThread (void *object)
 SYSExitThread Syscall function to exit a thread (Kill it) Function called at end of all thread if no return and/or ExitThread() More...
 
void StartUserThread (int data)
 StartUserThread Init the NachOS thread. More...
 
int SYSStopChild (unsigned int CID)
 UserThread::StopChild Put the thread in BLOCKED status. More...
 
int SYSWakeUpChild (unsigned int CID)
 UserThread::WakeUpChild Put a thread in Ready status. More...
 
void ExceptionHandler (ExceptionType which)
 ExceptionHandler Entry point into the Nachos kernel. Called when a user program is executing, and either does a syscall, or generates an addressing or arithmetic exception. More...
 

Detailed Description

Entry point into the Nachos kernel from user programs.

Author
Olivier Hureau, Hugo Feydel , Julien ALaimo

Copyright (c) 1992-1993 The Regents of the University of California. All rights reserved. See copyright.h for copyright notice and limitation of liability and disclaimer of warranty provisions. syscall – The user code explicitly requests to call a procedure Entry point into the Nachos kernel from user programs. There are two kinds of things that can cause control to transfer back to here from user code:

syscall – The user code explicitly requests to call a procedure in the Nachos kernel. Right now, the only function we support is "Halt".

exceptions – The user code does something that the CPU can't handle. For instance, accessing memory that doesn't exist, arithmetic errors, etc. Interrupts (which can also cause control to transfer from user code into the Nachos kernel) are handled elsewhere.

For now, this only handles the Halt() system call. Everything else core dumps. Copyright (c) 1992-1993 The Regents of the University of California.

Function Documentation

void copyMachineFromString ( char *  from,
int  to,
unsigned  size 
)

copyMachineFromString Copy a string from Kernel to Mips

Parameters
void copyStringFromMachine ( int  from,
char *  to,
unsigned  size 
)

copyStringFromMachine Copy a string from MIPS to Kernel

Parameters
from: the Machine adresse where the string is
to: the Kernel adresse where to copy the string
size: the string's adresse
void ExceptionHandler ( ExceptionType  which)

ExceptionHandler Entry point into the Nachos kernel. Called when a user program is executing, and either does a syscall, or generates an addressing or arithmetic exception.

For system calls, the following is the calling convention:

system call code – r2 arg1 – r4 arg2 – r5 arg3 – r6 arg4 – r7

The result of the system call, if any, must be put back into r2.

And don't forget to increment the pc before returning. (Or else you'll loop making the same system call forever!

Parameters
whichis the kind of exception. The list of possible exceptions are in machine.h.
void ProcedureGetInt ( int *  n)

ProcedurePutInt Get the int that have been written int the input stream of the SynchConsole Be carefull the absolute value of the int must be lower than 10^10-1 Negative int is supported

Parameters
n: The adress where the int will be written
void ProcedurePutInt ( int  n)

ProcedurePutInt Put an int in the SynchConsole current output stream Be carefull the absolute value of the int must be lower than 10^10-1 Negative int is supported

Parameters
n: The int to be printed
void StartUserThread ( int  data)

StartUserThread Init the NachOS thread.

Parameters
data
unsigned int SYScreateUserThread ( void *  f,
void *  arg 
)

SYScreateUserThread Syscall function that create a UserThread (and the thread)

Parameters
fThe function where the thread will begin
argthe adress of the argument needed by this function
Returns
The unsigned int TID
void SYSExitThread ( void *  object)

SYSExitThread Syscall function to exit a thread (Kill it) Function called at end of all thread if no return and/or ExitThread()

Parameters
object
int SYSStopChild ( unsigned int  CID)

UserThread::StopChild Put the thread in BLOCKED status.

Parameters
CID
Returns
0 if the child have been stoped, 1 if the child is currently stop, 2 if it's not a child's TID
void* SYSWaitForChildExited ( unsigned int  CID)

SYSWaitForChildExited.

Parameters
CID
Returns
the adress of the object returned
int SYSWakeUpChild ( unsigned int  CID)

UserThread::WakeUpChild Put a thread in Ready status.

Parameters
CID
Returns
0 if the child have been WakeUp, 1 if the child is currently Ready, 2 if it's not a child's TID