Пример #1
0
  public static void raiseException(int which, int badVAddr) {
    Debug.println('m', "Exception: " + exceptionNames[which]);
    
    Debug.ASSERT(Interrupt.getStatus() == Interrupt.UserMode);
    registers[BadVAddrReg] = badVAddr;
    delayedLoad(0, 0);			// finish anything in progress
    Interrupt.setStatus(Interrupt.SystemMode);
    Nachos.exceptionHandler(which); // interrupts are enabled at this point
    Interrupt.setStatus(Interrupt.UserMode);
}
Пример #2
0
  public static void run() {
    Instruction instr = new Instruction(); // storage for decoded instruction

    Debug.println('m', "Starting user thread " + 
		  Thread.currentThread().getName() +
		  "at time " + Nachos.stats.totalTicks);

    Interrupt.setStatus(Interrupt.UserMode);
    for (;;) {
      oneInstruction(instr);
      Interrupt.oneTick();
      if (singleStep && (runUntilTime <= Nachos.stats.totalTicks))
	debugger();
    }
  }
Пример #3
0
  public static void debugger() {
    //Debug.println('m', "Debugger not implemented");

    int num;
    char inputChar;  // char read from input stream
    

    Interrupt.dumpState();
    dumpState();
    System.out.print(Nachos.stats.totalTicks + "> ");
    System.out.flush();

    // get user input, character at a time.

    try {
      inputChar = (char)(System.in.read());
    } catch (IOException _) {
      inputChar = 'x';
    }

    if (inputChar == 'c')
      singleStep = false;
    else if (inputChar == '?') {
      System.out.println("Machine commands:");
      System.out.println("    <return>  execute one instruction");
      System.out.println("    <number>  run until the given timer tick");
      System.out.println("    c         run until completion");
      System.out.println("    ?         print this help message");
    }
    else if (Character.isDigit(inputChar)) {
      int tempNum = 0;

      while (Character.isDigit(inputChar)) {
	tempNum *= 10;
	tempNum += Character.digit(inputChar, 10);
	try {
	  inputChar = (char)(System.in.read());
	} catch (IOException _) {
	  inputChar = 'x';
	  break;
	}
	runUntilTime = tempNum;
      }
    }
      
  }