2011.jtr.pbasanta

21
Enhancing OSGi with real-time Java support Pablo Basanta-Val, Marisol García-Valls, and Iria Estévez-Ayres mailto:[email protected] Jornadas de Tiempo Real 2012- Santander ( ) Acceptado en Software Practice and Experience (SPE)

Upload: universidad-carlos-iii-de-madrid

Post on 31-May-2015

262 views

Category:

Education


1 download

TRANSCRIPT

Page 1: 2011.jtr.pbasanta

Enhancing OSGi with real-time Java support

Pablo Basanta-Val, Marisol García-Valls, and Iria Estévez-Ayres

mailto:[email protected]

†Jornadas de Tiempo Real 2012- Santander ( ) Acceptado en Software Practice and Experience (SPE)

Page 2: 2011.jtr.pbasanta

Outline• OSGi and RTSJ

– Motivation and interesting issues

• TROSGi (real-Time foR OSGi)– Architecture: L0, L1, L2– API– Performance results

• Conclusion and ongoing work

2

Page 3: 2011.jtr.pbasanta

Context

• Java programmers may use OSGi for– Life-cycle management of Java applications

called bundles• start/stop/update bundles• export/lookup/unexport bundles/services

from the framework• Runlevels

• Some pieces work has addressed the provision of real-time with OSGi– [hybrid approaches]

• Java for soft-real time + C modules for hard real-time

– [pure Java approaches] • Using RTSJ (i.e., The Real-Time Specification for Java)

JRT-12 3

Execution Environment

Hardware/OS

Security

Module

Life cycle

Service

Bundles

Page 4: 2011.jtr.pbasanta

Some issues in OSGi and RTSJ integration

• Access to real-time Java facilities– I.e. RTSJ and/or DRTSJ

• Improving the predictability of the framework– Definition of a real-time bundle

• Real-time characterization• Access/modification of the characterization• Backward compatibility

– Predictability in bundle management• Execution environment, security, underlying OS

• New real-time services for OSGi– New APIs

• Other real-time improvements on exiting services – E.g. Real-time framework, real-time HTTP 4

Execution Environment

Hardware/OS

Security

Module

Life cycle

Service

Bundles

Page 5: 2011.jtr.pbasanta

In this work: TROSGi

• Primary goal:– Real-time and OSGi integration

• This presentation– Introducing the integration framework

proposed with RTSJ• Integration levels, architecture, and AP

• Outcomes,– TROSGi=={real-time for OSGi}

5

TROSGi Services

OSGi

Real-time Java

CPU Memory Network

CharacterizationService

SchedulerService

RecoveryService

CompositorService

Real-Time Java Access

L0

L1

L2

Page 6: 2011.jtr.pbasanta

TROSGi: Level 0

• Minimal access to real-time Java and OSGi

• Changes required from the env.:– javax.realtime.

– Real-time operating system (if any)– OSGi should export javax.realtime– Bundles should import javax.realtime

6

RTSJ compliant virtual machine

OSGi engineExport-Package: javax.realtime

Manifest

Import-Package: javax.realtime

Real-time Java

OSGi

Bundle

CPU Memory Network

Real-time Operating System

Page 7: 2011.jtr.pbasanta

TROSGi: Level 0 – Example (1/2)00: import javax.realtime.*;01: import org.osgi.framework.*;02: public class ExampleRT implements BundleActivator{03: BundleContext ctx;04: RealtimeThread rt;05: public void start(BundleContext context) throws Exception {06: rt=new RealtimeThread(){07: public void run(){08: try{09: do{ System.out.println(“RT hello”);10: RealtimeThread.sleep(new AbsoluteTime(10,0)); //mit=10 ms11: }while (true);12: }catch(Exception e){13: System.out.println(“STOP called: bye, bye”);}14: };15: rt.start(); //Launch the real-time thread16: }17: public void stop(BundleContext context) throws Exception {18: rt.interrupt(); //Launch an exception 19: }20:.}

7Listing 1. Example of a bundle activator that

starts/stops a real-time thread

Page 8: 2011.jtr.pbasanta

TROSGi: Level 0 – Example (2/2)

00: Bundle-Name: Hello RT Threads01: Bundle-SymbolicName: es.uc3m.it.drequiem.trosgi.Rtthreads02: Bundle-Description: A Hello World bundle for RTSJ03: Bundle-ManifestVersion: 204: Bundle-Version: 1.0.005: Bundle-Activator: ExampleRT06: Import-Package: org.osgi.framework, javax.realtime

8

Listing 2. Bundle descriptor

Page 9: 2011.jtr.pbasanta

TROSGi: Level 1 – Real-time characterization service• Goal:

– Real-time charaterization

• Solution:– Stored in the bundle in an xml file– Accessed from the bundle using a

service

9

RTSJ compliant virtual machine

OSGi engineExport-Package: javax.realtime

ManifestResource-model: info.xmlImport-Package: javax.realtime,es.uc3m.it.trosgi

Real-time Java

OSGi

Bundle

CPU Memory Network

Real-time Operating System

//TROSGI bundle

Export-Packagees.uc3m.it.trosgiImport-Packagejavax.realtime

00: <!--Bundle-Name: Hello RT Threads ->01: <schedulable name="RTHello">02: <mit>10000</mit> 03: </schedulable>

Page 10: 2011.jtr.pbasanta

TROSGi-Level 1: Example and API

JTR-12 10

00: import javax.realtime.*;01: import org.osgi.framework.*;02: import es.uc3m.it.trosgi.*;03: import org.w3c.dom.*;04: public class ExampleRT implements BundleActivator{05: BundleContext ctx;06: RealtimeThread rt;07: int mit=0; 08: public void start(BundleContext context) throws Exception {09: rt=new RealtimeThread(){10: public void run(){11: ServiceReference c_rf1= // Ref to the service 12: Context.getServiceReference(“CharacterizationService”);13: RealtimeCharacterizationService client1=\\14: (RealtimeCharacterizationService) context.getService(c_rf1);15: Bundle bundle=context.getBundle();16: Document doc=client1.getRealtimeCharacterization(bundle);17: NodeListlist nlist=doc.getElementsByTagName("mit");

00: import org.osgi.framework.*;01: public interface RealtimeCharacterizationService 02: extends RealTimeService{03: public Document 04: getRealtimeCharacterization(Bundle b);05: public boolean setRealtimeCharacterization(06: Bundle bnd, Document doc);07:}

Page 11: 2011.jtr.pbasanta

TROSGi: Level 2 – Real-time characterization service• Three new services:

– Admission controlers• Based on RTSJ’s model

– Fault-tolerance• Partiatilly taken from DRTSJ

– Compositor• Inspired in iLAND gained

experience and • DRTSJ’s distributable threads

11

RTSJ compliant virtual machine

RT-OSGi engineExport-Package: javax.realtime

ManifestResource-model: info.xmlImport-Package: javax.realtime,es.uc3m.it.trosgi.*

Real-time Java

RT-OSGi

Services

CPU Memory Network

Real-time Operating System

//TROSGI service

Export-Packagees.uc3m.it.trosgi.modelImport-Packagejavax.realtime

//TROSGI service

Export-Packagees.uc3m.it.trosgi.schedulerImport-Packagejavax.realtime

Bundles

//TROSGI service

Export-Packagees.uc3m.it.trosgi.recoverImport-Packagejavax.realtime

//TROSGI service

Export-Packagees.uc3m.it.trosgi.compositorImport-Packagejavax.realtime

JTR-12

Page 12: 2011.jtr.pbasanta

TROSGi: Level 2 – API:BundleScheduler, BundleRecover, BundleCompositor

JTR-12 12

00: import org.osgi.framework.*;01: import org.w3c.dom.*;02: public interface BundleSchedulerService03: extends RealTimeService{04: public boolean setIfFeassible(Bundle bnd);05: public boolean removeFromScheduler(Bundle bnd);06: }

00: import org.osgi.framework.*;01: public interface BundleRecoverService03: extends RealTimeService{04: public boolean addBundle(Bundle bnd);05: public boolean removeBundle(Bundle bnd);}

00: import org.osgi.framework.*;01: public interface BundleCompositorService03: extends RealTimeService{03: public boolean addComposedBundle(Bundle bnd);04: public boolean removeComposedBundle(Bundle bnd);}

Page 13: 2011.jtr.pbasanta

Level 2: Common Services API(inspired in RTSJ’s resource model)f

00: <!DOCTYPE resourcemodel[ 01: <!ELEMENT resourcemodel(bundlescheduler|02: bundlerecover|bundlecompositor) 03: <!ELEMENT bundlescheduler(schedulable*)> 04: <!ELEMENT schedulable (releaseparameters?,scheduling?)>05: <!ATTLIST alt name (#PCDATA)>06: <!ELEMENT releaseparameters (periodic|sporadic07: |aperiodic)> 08: <!ELEMENT periodic (start?,period?,cost?,deadline?)> 09: <!ELEMENT sporadic (start?,mit?,cost?,deadline?)> 10: <!ELEMENT aperiodic> 11: <!ELEMENT start (#PCDATA)> 12: <!ELEMENT period (#PCDATA)> 13: <!ELEMENT cost (#PCDATA)> 14: <!ELEMENT deadline (#PCDATA)> 15: <!ELEMENT mit (#PCDATA)> 16: <!ELEMENT scheduling (priority?)> 17: <!ELEMENT priority (#PCDATA)> 18: <!ELEMENT bundlerecover (policy+)> 19: <!ELEMENT policy (mit?, cost?,deadline?,priority?)> 20: <!ATTLIST policy name #PCDATA> 21: <!ELEMENT bundlecompositor (alt*)> 22: <!ELEMENT alt (block+)> 23: <!ATTLIST alt type (#PCDATA)> 24: <!ELEMENT block (schedulable*)> 25: ]>

JTR-12 13

Page 14: 2011.jtr.pbasanta

Implementation

• Prototype:– Oracle’s JTR– Real-time Linux kernel 2.6.28– Knopflerfish 3.0

• TROSGi– RUB admission controller– Re-starting fault policy– Multi-constrained recovery

service– 50 kbytes footprint

JTR-12 14

TROSGi Services

OSGi(knopflerfish 3.0)

Real-time Java(1.5.0_20_Java_RTS-2.2.fcs_b19)

Real-time operating system(2.6.28-3-rt)

CPU(1.5 Ghz)

Memory(5 Gb)

Network

CharacterizationService

SchedulerService

RecoveryService

CompositorService

Real-Time Java Access

Page 15: 2011.jtr.pbasanta

Level 0 and Level 1 results

JTR-12 15

Page 16: 2011.jtr.pbasanta

Level 2: BundleScheduler results

• Admission control takes reduced amout of time (see 1st figure)– 1024 tasks in 50 ms

• Most of the time consumed in XML processing (see 2nd figure)

JTR-12 16

Page 17: 2011.jtr.pbasanta

Level 2: RecoveryService results

JTR-12 17

ApproachWorst Case

Cost (ms)

Soft (99%) Case Cost

(ms)

Including Installation Cost(full installation)

257 157

Without Installation Cost (start only) 177 137

Page 18: 2011.jtr.pbasanta

Level 2: Bundle Compositor results

JTR-12 18

Much overhead !!!- Compared against the scheduler service

Page 19: 2011.jtr.pbasanta

Conclusions

• The definition of real-time OSGi is a rather open issue– No standard, nor functional solutions

• TROSGi offers a service-based approach for real-time integrations– Three integration levels : L0, L1, and L2– Tested on RTSJ, and validated with simple implementation services

JTR-12 19

Page 20: 2011.jtr.pbasanta

Ongoing work

• Two main ongoing issues– Improving the implementation

• Use of DRTSJ, new service implementations, real-time security

• New compositor policies

– Introducing hooks for other languages• C and Ada integration

20

Page 21: 2011.jtr.pbasanta

21JTR-12