public abstract class InterruptServiceRoutine
extends java.lang.Object
handle()
method to provide
the code to be run when an interrupt occurs. This class must always
be present in the Device module, but may do nothing in a context that
does not provide direct access to interrupts, e.g., in user space on an
operating system that does not support user space device drivers.
Futhermore, it may only have its monitor set to one of type
InterruptMasking
. The default is InterruptInheritance
for
instance associated with a maskable interrupt and
InterruptUnmaskable
for one associated with an unmaskable interrupt.Constructor and Description |
---|
InterruptServiceRoutine(long Interrupt,
MemoryArea area)
Creates an interrupt service routine for a particular interrupt line
with a particular memory area.
|
Modifier and Type | Method and Description |
---|---|
static Affinity |
getAffinity(long interrupt)
Generally, the program cannot determine the affinity of interrupt
handling; however, it is necessary for determining schedulability.
|
static InterruptServiceRoutine |
getHandler(long interrupt)
Gets the
InterruptServiceRoutine that is handling a given
interrupt. |
protected abstract void |
handle()
The code to execute for first level interrupt handling.
|
boolean |
isRegistered()
Obtains the registration state.
|
void |
register()
Registers this interrupt service routine with the system so that it
can be triggered.
|
void |
unregister()
Deregisters this interrupt service routine with the system so that
it can no longer be triggered.
|
public InterruptServiceRoutine(long Interrupt, MemoryArea area) throws java.lang.NullPointerException, StaticIllegalArgumentException
InterruptInheritance
.Interrupt
- A reference to the Interrupt associate with this
handler.area
- The allocation context in which the handle()
method runs.java.lang.NullPointerException
- when area
is null.StaticIllegalArgumentException
- when
area
is a memory area that cannot be accessed from
an ISR.public static InterruptServiceRoutine getHandler(long interrupt)
InterruptServiceRoutine
that is handling a given
interrupt.interrupt
- A system-dependent identifier for the interrupt.InterruptServiceRoutine
registered to the
given interrupt. When nothing is registered, null
is returned.public static Affinity getAffinity(long interrupt) throws StaticIllegalArgumentException
interrupt
- The identifier for the interrupt to testinterrupt
or null
when it cannot.StaticIllegalArgumentException
- when
interrupt
is not in the set of descriptors managed by
the InterruptDescriptor
class.public final boolean isRegistered()
public void register() throws RegistrationException, ScopedCycleException
RegistrationException
- when this
is already registered,
some other InterruptServiceRoutine
is registered for
interrupt
, or the handle
method is synchronized.ScopedCycleException
- when the initial memory area for this
InterruptServiceRoutine
is already present in the
scope tree at a different location than the rules for
reservation would imply.public void unregister() throws DeregistrationException
DeregistrationException
- when this interrupt service
routine is not registered.protected abstract void handle()
RawMemory
classes may be used to access the associated device registers and a
Happening
may be triggered for second level interrupt
handling.
The code used to implement this method should not block itself
or induce a context switch, e.g., sleep or perform I/O. Only
spin waits may be used. The effects of unbounded blocking and
inducing a context switch here are undefined and could result in a
deadlock. Object.notify()
and Object.notifyAll()
may be called, but Happening.trigger(int)
is preferred for ease of
linking with the event handling system and
RealtimeThread.release()
for releasing a realtime thread with
AperiodicParameters
. In any case,
Object.wait()
should not be called.
Synchronizing with the code in a handle()
method can only be
done by sychronizing with the instance of InterruptServiceRoutine
containing that handle()
method. The handle()
method
itself may not be synchronized, since this generates unnecessary extra
code which could cause blocking. Instead, the platform interrupt masking
is used to ensure mutual exclusion. The containing instance can only
have a monitor control policy of type InterruptMasking
.
When a memory area is provided, that memory is entered before
this method is invoked and exited after it returns. When no memory
area is provided, the method may not allocate. Any attempt to allocate
will result in an OutOfMemoryError
.
Any exceptions thrown by this method cause the method to about and are silently caught and discarded by the infrastructure.