the rpeanut simulator provides buffering of the


The rPeANUt simulator provides buffering of the characters that are typed into the terminal. However, this would generally not be the case so if the program did not consume a character before the next one is typed then a character may be lost. So in this next part of the lab you are required to write an interrupt handler for the IO terminal that will capture characters as they are typed and place them in a buffer. The read system call would then read them out of this buffer rather than directly from the device. The psudo code for interrupt handler with a single character buffer:

void iohandler () {

   if (buffcount == 0) {

      buff = getchar();  // no need to poll on the status register

      buffcount = 1;

   } else {

      getchar(); // no room in the buffer so we lost a character!!!

   }

   enableInterrupts();

}

void traphandler ()  {

   enableInterruptes();

   if (R0 == 0) { // read system call

      while (buffcount == 0) ;

      R1 = buff;

      buffcount = 0;

   } else if (R0 == 1) { // write system call

      putchar(R1); // just store R1 to memory location 0xfff0

   }

}

char buff;

int buffcount;

void main() {

   buffcount = 0;

   enableIOterminalInterrupts();  // involves writing to the control register of the IO terminal device.

   char c;

   while (1) {

      c = read();

      write(c);

   }

}

 

Request for Solution File

Ask an Expert for Answer!!
C/C++ Programming: the rpeanut simulator provides buffering of the
Reference No:- TGS0209417

Expected delivery within 24 Hours