[ RCOS.java Home ]

Interrupt scenario

There are four classes of interrupt

The RCOS.java CPU maintains a Queue of possible interrupts that includes a time at which they should occur. For example

The Process

The following is a fairly generic outline of how an interrupt is processed.

CPU.HandleInterrupts()

  if NOT CPU.InterruptQ.IsEmpty()
  {
    CPU.InterruptQ.GoToHead();
    do
    {
      theInterrupt = CPU.InterruptQ.Peek();
      if ( theInterrupt due to happen )
      {
        Kernel.HandleInterrupt( theInterrupt );
      }
      CPU.InterruptQ.GoToNext();
    } while ( NOT CPU.InterruptQ.AtTail() )
  }
  

Kernel.HandleInterupt( Interrupt theInterrupt )

  // work out which component should handle this interrupt
  MessageHandler theDestination = Kernel.CalculateDestination( theInterrupt );
  // create the message to send the component
  Message theMessage = Kernel.ConstructMessage( theInterrupt 
  Kernel.SendMessage( theDestination, theMessage );
  

Kernel.SendMessage( MessageHandler theDestination, Message theMessage );


All SendMessage functions use this format The SendMessage function is used simply to give the illusion of "real" message passing.
    theDestination.ReceiveMessage( theMessage );
  

theDestination.ReceiveMessage( Message theMessage )

  if theDestination.ValidMessage( theMessage ) then
  {
    theDestination.HandleMessage( theMessage )
  }
  else
  {
    error = theDestination.GetError( theMessage );
    returnMessage = theDestinationErrorMessage( error );
    returnDestination = theMessage.GetSource();
    theDestination.SendMessage( returnDestination, returnMessage );
  }
  

theDestination.HandleMessage( theMessage )

  type = theMessage.GetType();

  switch (type )
  {
    case .....:
        do_something;
        break;
    case ...:
        do_something_else;
        returnMessage = generate_a_return_message(); // return value for a syscall
        returnDestination = theMessage.GetSource();
        theDestination.SendMessage( returnDestination, returnMessage );
        break;
    .
    .
  }
  

HTML HaL Mozilla Checked! URL: http://cq-pan.cqu.edu.au/david-jones/papers/projects/rcos/java/design/scenario/interrupt.html
Last modified: DATE
Author: David Jones