Presentation is loading. Please wait.

Presentation is loading. Please wait.

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

Similar presentations


Presentation on theme: "1 Predictable Java Java Objekt 2, 19 August 2009 Anders P. Ravn and Hans Søndergaard Overview Implementations Next steps."— Presentation transcript:

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

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

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 } 3

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 } 4

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)); } 5

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 6

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); } 7

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(); } 8

9 Level 0 9 only Periodic Event Handlers cyclic scheduler

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

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

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 12

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 13

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 14

15 Next steps: Workbench 15

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

17 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-Critical Applications 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 } 18

19 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 20


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

Similar presentations


Ads by Google