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

interrupt.cc

Go to the documentation of this file.
00001 // interrupt.cc 
00002 //      Routines to simulate hardware interrupts.
00003 //
00004 //      The hardware provides a routine (SetLevel) to enable or disable
00005 //      interrupts.
00006 //
00007 //      In order to emulate the hardware, we need to keep track of all
00008 //      interrupts the hardware devices would cause, and when they
00009 //      are supposed to occur.  
00010 //
00011 //      This module also keeps track of simulated time.  Time advances
00012 //      only when the following occur: 
00013 //              interrupts are re-enabled
00014 //              a user instruction is executed
00015 //              there is nothing in the ready queue
00016 //
00017 //  DO NOT CHANGE -- part of the machine emulation
00018 //
00019 // Copyright (c) 1992-1996 The Regents of the University of California.
00020 // All rights reserved.  See copyright.h for copyright notice and limitation 
00021 // of liability and disclaimer of warranty provisions.
00022 
00023 #include "copyright.h"
00024 #include "interrupt.h"
00025 #include "main.h"
00026 
00027 // String definitions for debugging messages
00028 
00029 static char *intLevelNames[] = { "off", "on"};
00030 static char *intTypeNames[] = { "timer", "disk", "console write", 
00031                         "console read", "elevator", "network send", 
00032                         "network recv"};
00033 
00046 PendingInterrupt::PendingInterrupt(CallBackObj *callOnInt, 
00047                                         int time, IntType kind)
00048 {
00049     callOnInterrupt = callOnInt;
00050     when = time;
00051     type = kind;
00052 }
00053 
00059 static int
00060 PendingCompare (PendingInterrupt *x, PendingInterrupt *y)
00061 {
00062     if (x->when < y->when) { return -1; }
00063     else if (x->when > y->when) { return 1; }
00064     else { return 0; }
00065 }
00066 
00074 Interrupt::Interrupt()
00075 {
00076     level = IntOff;
00077     pending = new SortedList<PendingInterrupt *>(PendingCompare);
00078     inHandler = FALSE;
00079     yieldOnReturn = FALSE;
00080     status = SystemMode;
00081 }
00082 
00107 
00125 
00149 
00191 
00209 
00236 
00259 
00283 
00332 
00345 

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