1 / 20

Predictable Java

Predictable Java. Overview Implementations Next steps. Java Objekt 2, 19 August 2009. Anders P. Ravn and Hans Søndergaard . A Real-Time Application. Periodic Event Handlers Aperiodic Event Handlers collected in a mission Mission Handler Each handler has a Memory is Scheduled.

kerry
Download Presentation

Predictable Java

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Predictable Java • Overview • Implementations • Next steps Java Objekt 2, 19 August 2009 Anders P. Ravn and Hans Søndergaard

  2. A Real-Time Application • Periodic Event Handlers • Aperiodic Event Handlers collected in a mission • Mission Handler Each handler • has a Memory • is Scheduled

  3. Periodic handler class Periodic extends PeriodicEventHandler { protected Periodic(.., PeriodicParameters pp, Scheduler scheduler, MemoryArea memory); public void handleEvent() { // the logic to be executed every period } }

  4. Aperiodic handler class Aperiodic extends AperiodicEventHandler { protected Aperiodic(.., AperiodicParameters ap, Scheduler scheduler, MemoryArea memory); public void handleEvent() { // the logic to be executed when an event occurs } }

  5. A simple mission public class Basic extends Mission { protected Basic(.., AperiodicParameters ap, Scheduler scheduler, MemoryArea memoryArea) { ... // initialization } public static void main (String[] args) { new Basic( null, null, new CyclicScheduler(), new LTMemory(10*1024)); } }

  6. …The mission addToMission( new Periodic( null, pp, getScheduler(), new LTMemory(1024))); addToMission( new Periodic( null, pp, getScheduler(), new LTMemory(1024))); ... add(); // mission to its scheduler

  7. Complex mission private Mission[] mission; private int active = 0; static AperiodicEvent event; public ThreeSequentialMissions(...) { mission = new Mission[3]; // set up the three missions mission[0] = new Mission(...); // add handlers for mission 0 // including the mission termination ... mission[1] = new Mission(); ... // start the first mission mission[active].add(); event = new AperiodicEvent(this); }

  8. Changing mission private Mission[] mission; private int active = 0; static AperiodicEvent event; public ThreeSequentialMissions(...) { ... } public void handleEvent() { mission[active].remove(); active = (active + 1) % mission.length; mission[active].add(); }

  9. Level 0 • only Periodic Event Handlers • cyclic scheduler

  10. Level 1 SO 3 has the highest priority • periodic and aperiodic event handlers • fixed-priority preemptive scheduler

  11. Implementations • On top of RTSJ (adapter) • Native implementation using • JamVM • Xenomai/Linux • Mechatronic Brick

  12. Schedulers • Cyclic scheduler • Only one mission, with periodic handlers • Using cyclic executive model • The Scheduler: a periodic RT_TASK • period = gcd of all the handler periods • Fixed priority pre-emptive scheduler • Missions with periodic and aperiodic handlers • Implemented as RT_TASKs

  13. Memory • No GC • Two types of memory • Immortal memory = Heap (without GC) • Lifetime = lifetime of the application • Scoped memory • Each handler has its own private memory • Lifetime = lifetime of the handler • Object allocation rewritten in JamVM

  14. Synchronization • Java’s locking model (synchronization) • does not fit to avoid priority inversion • Xenomai's MUTEX enforce priority inheritance • Rewritten JamVM • synchronized methods in classes for shared objects: • uses MUTEX lock/unlock

  15. Next steps: Workbench

  16. Next steps • Eclipse plugins • Homepage for Predictable Java • Different tools for static analysis • Examples • ...

  17. References • A predictable Java profile - rationale and implementations Thomas Bøgholm, René R. Hansen, Anders P. Ravn, Bent Thomsen, and Hans Søndergaard JTRES’09. 23-25 September 2009. • Safety-Critical Java JSR 302: Safety Critical Java Technology http://jcp.org/en/jsr/detail?id=302 • Java for Safety-CriticalApplications Thomas Henties, James J. Hunt, Doug Locke, Kelvin Nilsen, Martin Schoeberl, Jan Vitek. SafeSert 2009. • Safety Critical Specification for Java Version 0.5. August 2008. Draft.

  18. Periodic event handler execution Periodic Rt_task: for (;;) { JNI-callback-to-scheduler-dispatch(handlerNo) rt_task_wait_period(NULL); } class PriorityScheduler extends Scheduler { create Native handlers, start them, etc. .. void dispatch(int handlerNo) { EventHandler evh = getEvh(handlerNo); evh.getMemoryArea().enter(evh); } } public abstract class MemoryArea { long memSize; int memID; // a reference to the MEM_AREA public void enter (Runnable logic) { Native.enterNativeMemArea (memID); logic.run(); Native.leaveNativeMemArea (memID); } ... } abstract class PeriodicEventHandler { .. public final void run() { handleEvent(); // abstract method } } class MyPeriodicEvH extends PeriodicEventHandler { .. public void handleEvent() { // the logic to be executed every period } }

  19. Xenomai Architecture • Xenomai runs on top of the Linux kernel and handles all incoming interrupts first, before the Linux kernel • Adeos (Adaptive Domain Environment for Operating Systems) • a nanokernel hardware abstraction layer (HAL) • operates between computer hardware and the operating system • Xenomai has some skins • Native, POSIX, etc.

  20. Native Xenomai API • RT services for • RT_TASKs • rt_task_create, rt_task_start, rt_task_set_priority • rt_task_set_periodic, rt_task_wait_period • rt_task_suspend, rt_task_resume • .. • RT_EVENTs • RT_INTERRUPTs • RT_MUTEXs

More Related