Jalada home about archive

Asynchronous Notification in the RTSJ

11th February 2010

These are lecture notes from my Computer Science course, not a general reference for "Asynchronous Notification in the RTSJ"

Asynchronous Event Handling

RTSJ uses event handling to communicate asynchronously. Asynchronous events (AE) are data-less ‘happenings’ are fired by the program or associate with interrupts in the environment.

One or more handlers (AEH) can be associated with a single event, and a single AEH can be associated with one or more events. The association is dynamic. An AEH has a count of the number of outstanding firings.

Guess what, the events are classes. They’re similar to POSIX signals. The 3 main classes are:

When an event occurs all the handlers associated with the event are scheduled for execution.

ATC in RTJ

Allows one RT thread to interrupt another RT thread. It is integrated into the Java exception handling and interrupt facility. RTJ requires that each method indicates if it is prepared to allow an ATC; a bit like switching a mobile phone on to ‘say’ you are prepared to be interrupted.

To use ATC you must:

There are some examples of ATCs in the slides.

The key thing about Asynchronous Exceptions is that you should only have to handle one at once; otherwise it’ll be quite difficult to reason what is going to happen.

There’s also a few examples of what happens, with pictures. It looks a bit complicated and convoluted. Maybe this needs a practical to get the hang of it. He did say that it is ‘quite a complex model’. I swear Ada was simpler.

The ‘Interruptible’ interface

If you want to write some code that is interruptible, implement the Interruptible interface, which has two methods. interruptAction and run. You can guess what happens.

Again there’s an example of what you have to do to implement this.

Mode changes

As we have discussed before realtime systems might want to change modes. You can do this by implementing the Interruptible interface for each Mode (e.g. two classes: ModeA and ModeB).

Then, if the mode gets interrupted, it resets the internal state so that it can continue again at some point if necessary.

Then you have a ModeChanger class which extends AsynchronouslyInterruptedException. It is passed the initial mode and then keeps track of the current mode. This class can then set or toggle the mode. All this code is in the slides again, so take a look there as to exactly how you would implement this.

ATC Ada versus RTSJ

They are similar because:

They are different because:

Comments

blog comments powered by Disqus