[ RCOS.java Home ]
There are four classes of interrupt
- software/program
These are the system calls made by user programs.- timer
Interrupts generated by the system clock built into the CPU- I/O
Generated by I/O devices either by the completion of an I/O request or maybe because of errors.- errors
Divide by 0, ?memory protection/access faults?, others???The RCOS.java CPU maintains a Queue of possible interrupts that includes a time at which they should occur. For example
- I/O
When the disk is asked to perform a task it calculates how long it would take to fulfill that task and then adds the appropriate Interrupt to the CPU queue specifying the time at which it should occur.- software
Under RCOS there is a particular instruction that is used to make a system call (CSP). The CPU.ExecuteInstruction function will automatically generate an interrupt when it sees this instruction. It will probably bypass the Interrupt Queue and execute the CPU.HandleInterrupt method directly (is this a good idea?)- errors
Most will be caught in a similar manner to the system call interrupts.- timer
The CPU.OneTick method increments the system timer, if the timer is equal to the time for the next Timer interrupt it will add the appropriate Interrupt to the Queue so it is picked up next time around the CPU loop.
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; . . }
URL: http://cq-pan.cqu.edu.au/david-jones/papers/projects/rcos/java/design/scenario/interrupt.html
Last modified: DATE
Author: David Jones