The Next Generation of the Real-Time Specifj fjcation for Java Dr. - - PowerPoint PPT Presentation

the next generation of the real time specifj fjcation for
SMART_READER_LITE
LIVE PREVIEW

The Next Generation of the Real-Time Specifj fjcation for Java Dr. - - PowerPoint PPT Presentation

JTRES 2014 The Next Generation of the Real-Time Specifj fjcation for Java Dr. James J. Hunt JSR 282 Spec Lead CEO aicas GmbH JTRES 2014 What is the RTSJ? Support for realtime programming in Java importance vs fair scheduling determinism


slide-1
SLIDE 1

JTRES 2014

The Next Generation of the Real-Time Specifj fjcation for Java

  • Dr. James J. Hunt

JSR 282 Spec Lead CEO aicas GmbH JTRES 2014

slide-2
SLIDE 2

2 Real-TIme Specifj fjcation for Java 2.0

What is the RTSJ?

Support for realtime programming in Java

importance vs fair scheduling determinism vs responsiveness timeliness vs throughput priority inversion avoidance vs anitstarvation

Support for embedded programming in Java

device access interact with environment

A standard approach to realtime with Java

slide-3
SLIDE 3

3 Real-TIme Specifj fjcation for Java 2.0

Constraints

No changes to the language

same bytecode no new language features

Fully compatible with convention Java implementations such as OpenJDK

Java programs should run correctly on RTSJ implementations that supports the required profjle Maximize code reuse under time complexity constraints

slide-4
SLIDE 4

4 Real-TIme Specifj fjcation for Java 2.0

Why Update the RTSJ?

Environment evolution

better realtime garbage collection Java 1.4 Java 1.8 →

Marketing

support different levels of realtime: even for conventional Java implementations reduce need for JNI deemphisize memory areas differencial to Android

slide-5
SLIDE 5

5 Real-TIme Specifj fjcation for Java 2.0

RTSJ 1.0.2 Issues

Device memory access ineffjcient

Single class for accessing all precision for each of integral and fmoating types:

RawMemoryAccess RawMemoryFloatAccess

Unclear how I/O memory is address: fjlters under defjned Access testing on every access Cannot type restrict memory access Hard to inline

slide-6
SLIDE 6

6 Real-TIme Specifj fjcation for Java 2.0

RTSJ 1.0.2 Issues

Happening ill defjned

No standard way to add new happenings Happenings not objects Inconsistent with other AsyncEvent types

POSIX Clock User triggered

Too many levels of indirection: Happening AsyncEvent AsyncEventHandler → → No support for fjrst level interrupt handlers

slide-7
SLIDE 7

7 Real-TIme Specifj fjcation for Java 2.0

RTSJ 1.0.2 Issues

No way to defjne a new Clock ScopedMemory

No simple way to use scopes for Producer- Consumer pattern No way to manage backing store

Multicore

no way to assign SOs to processors

Miscellaneous Defjciencies

slide-8
SLIDE 8

8 Real-TIme Specifj fjcation for Java 2.0

New Raw Memory Architecture

FactoryBased

RawMemory class for registration RawMemoryFactory for implementation

Interfaces for each access type: RawInt, RawShort, RawByte, RawFloat, etc. Concrete classes for

Memory mapped devices, I/O mapped devices, and Generic mapped devices.

slide-9
SLIDE 9

9 Real-TIme Specifj fjcation for Java 2.0

RawMemory Interfaces

javax.realtime::RawFloatWriter «interface» +setFloat(fmoat v) +setFloat(int ofgset, fmoat data) +set(int ofgset, fmoat[] v): int +set(int ofgset, fmoat[] v, int start, int count): int +address():long javax.realtime::RawFloat «interface» javax.realtime::RawFloatReader «interface» +getFloat():fmoat +getFloat(int ofgset):fmoat +get(int ofgset, fmoat[] v): int +get(int ofgset, fmoat[] v, int start, int count): int +address():long javax.realtime::RawDoubleWriter «interface» +setDouble(double v) +setDouble(int ofgset, double data) +set(int ofgset, double[] v): int +set(int ofgset, double[] v, int start, int count): int +address():long javax.realtime::RawDoubleReader «interface» +get():double +getDouble(int ofgset):double +get(int ofgset, double[] v): int +get(int ofgset, double[] v, int start, int count): int +address():long javax.realtime::RawDouble «interface» javax.realtime::RawByteWriter «interface» +setByte(byte v) +setByte(int ofgset, byte v) +set(int ofgset, byte[] v):int +set(int ofgset, byte[] v, int start, int count):int +address():long javax.realtime::RawByte «interface» javax.realtime::RawByteReader «interface» +getByte():byte +getByte(int ofgset):byte +get(int ofgset, byte[] v):int +get(int ofgset, byte[] v, int start, int count):int +address():long javax.realtime::RawShortWriter «interface» +setShort(short v) +setShort(int ofgset, short v) +set(int ofgset, short[] v):int +set(int ofgset, short[] v, int start, int count):int +address():long javax.realtime::RawShortReader «interface» +getShort():short +getShort(int ofgset):short +get(int ofgset, short[] v):int +get(int ofgset, short[] v, int start, int count):int +address():long javax.realtime::RawShort «interface» javax.realtime::RawIntWriter «interface» +setInt(int v) +setInt(int ofgset, int v) +set(int ofgset, int[] v):int +set(int ofgset, int[] v, int start, int count):int +address():long javax.realtime::RawIntReader «interface» +getInt():int +getInt(int ofgset):int +get(int ofgset, int[] v):int +get(int ofgset, int[] v, int start, int count):int +address():long javax.realtime::RawInt «interface» javax.realtime::RawLongWriter «interface» +setLong(long v) +setLong(int ofgset, long v) +set(int ofgset, long[] v):int +set(int ofgset, long[] v, int start, int count):int +address():long javax.realtime::RawLongReader «interface» +getLong():long +getLong(int ofgset):long +get(int ofgset, long[] v):int +get(int ofgset, long[] v, int start, int count):int +address():long javax.realtime::RawLong «interface» javax.realtime::RawMemory «interface» java.io::Closable «interface» +close() Visibility + = public # = protected ~ = package

slide-10
SLIDE 10

10 Real-TIme Specifj fjcation for Java 2.0

Example

Public class IOBusController implements RawShort { private MemoryRawByte command; private MemoryRawByte fmag; private MemoryRawShort address; private MemoryRawInt data; public int get(short address) { address.put(address); command.put(READ); while (fmag.get() != DONE); return data.get(); } ...

slide-11
SLIDE 11

11 Real-TIme Specifj fjcation for Java 2.0

DMA Support

Special factory for direct byte buffer

Get byte buffer that is visible DMA controller Means to get address to pass to DMA controller Could be use to implement I/O Channels

Additional barrier types

provide write visibility across JNI boundary for supporting DMA with direct byte buffers Coordinating with Doug Lea (JEP 188: Java Memory Model Update)

slide-12
SLIDE 12

12 Real-TIme Specifj fjcation for Java 2.0

Event Architecture

AbstractAsyncEvent AsyncEvent POSIXSignal

POSIXRealtimeSignal

ActiveEvent AsyncLongEvent AsyncObjectEvent Happening ISR Timer PeriodicTimer OneShotTimer

slide-13
SLIDE 13

13 Real-TIme Specifj fjcation for Java 2.0

Event Handler Architecture

AbstractAsyncEventHandler AsyncEventHandler

BoundAsyncLongEventHandler

AsyncLongEventHandler AsyncObjectEventHandler BoundAsyncEventHandler AbstractBound AsyncEventHandler

BoundObjectLongEventHandler

slide-14
SLIDE 14

14 Real-TIme Specifj fjcation for Java 2.0

Mix and Match

Types AsyncEvent AsyncLongEvent AsyncObjectEvent AsyncEventHandler No payload No payload No payload AsyncLongEventHandler Event ID Payload Event ID AsyncObjectEventHandler Event Object Event Object Payload

slide-15
SLIDE 15

15 Real-TIme Specifj fjcation for Java 2.0

Timer States

disabled disabled stopped active relative absolute absolute

  • > FALSE

stop startDisabled stop

  • > TRUE
  • > TRUE

stop Any Call

  • > IllegalStateException

nonexistant new Timer(AbsoluteTime, ..) destroy OneShotTimer fire active skip OneShotTimer fire and selfreschedule PeriodicTimer isRunning

  • > TRUE

skip and selfreschedule PeriodicTimer isRunning

  • > FALSE

isRunning

  • > FALSE
  • > IllegalStateException

getFireTime new Timer(RelativeTime, ..) RelativeTime reschedule reschedule RelativeTime reschedule reschedule AbsoluteTime AbsoluteTime

  • > IllegalStateException

startDisabled IllegalStateException start getFireTime

  • > absoluteTime
  • > start +

relativeTime getFireTime start enable disable absolute enabled active relative disabled active enabled disabled relative stopped destroyed

slide-16
SLIDE 16

16 Real-TIme Specifj fjcation for Java 2.0

AbstractAsyncEvent States

new AbstractAsyncEvent(..)

isRunning isRunning

  • > FALSE
  • > TRUE

enable disable

enabled disabled nonexistant

slide-17
SLIDE 17

17 Real-TIme Specifj fjcation for Java 2.0

Happening: Kind of AsyncEvent

AsyncEvent

Passive (fjre mechanism) Runs all associated event handlers User defjnable

Happenings

supports active behavior too (trigger mechanism) Can have (needs) dispatcher to manage activity Can be triggered from outside the VM

slide-18
SLIDE 18

18 Real-TIme Specifj fjcation for Java 2.0

Happening Sequence

slide-19
SLIDE 19

19 Real-TIme Specifj fjcation for Java 2.0

User Defj fjned Clocks

Like an ISR

no active thread just triggers associated Timers

Manages Trigger Queue

next set of Timers (in priority order) to trigger time ordered set of Timer sets constant trigger time for top next Timer bound adding and deleting

slide-20
SLIDE 20

20 Real-TIme Specifj fjcation for Java 2.0

Clock Sequence Diagram

slide-21
SLIDE 21

21 Real-TIme Specifj fjcation for Java 2.0

Sleep with Application Clock

slide-22
SLIDE 22

22 Real-TIme Specifj fjcation for Java 2.0

Affj fjnity

Multicore control

enable pinning Threads and AsyncEventHandlers to a subset of processors. support collective pinning w/ ProcessingGroupParameters fjnd out what processors and processor subsets are available for pinning pinning to single processors is always supported.

  • rthogonal to all other RTSJ classes
slide-23
SLIDE 23

23 Real-TIme Specifj fjcation for Java 2.0

Entering MemoryAreas

Provide for passing arguments

use lamda and closure can be optimized to prevent allocation

Provide a return value

Use Supplier API adds many methods

fjve types: Object<T>, int, long, double, and boolean enter, executeInArea, joinAndEnter, and joinAndEnter with timeout 10–20 new methods!

slide-24
SLIDE 24

24 Real-TIme Specifj fjcation for Java 2.0

New ScopedMemory Areas

PinnedMemory

subclass of ScopedMemory similar to LT Memory except supports pinning

StackedMemory

subclass of ScopedMemory (supports SCJ Model) similar to LT Memory but reserves backing store backing store from parent when StackedMemory enterable only from MemoryArea where created resize to max reserved (when no sub area)

slide-25
SLIDE 25

25 Real-TIme Specifj fjcation for Java 2.0

StackedMemory Example

Nesting 0 Nesting 0 Split A Nesting 2 Nesting 1 Split B Nesting 1 Split A Nesting 1 Nesting 2 Split C Nesting 3

slide-26
SLIDE 26

26 Real-TIme Specifj fjcation for Java 2.0

Small Change

RealtimeThread

add waitForNextRelease() and release() for aperiodic processing

AsyncEventHandler

memory area entered on each release

  • ld behavior obtained by using PinnableMemory

ReleaseParameters

add blocking factor to support feasibility analysis

slide-27
SLIDE 27

27 Real-TIme Specifj fjcation for Java 2.0

Small Change

PreallocatedThrowable

ThrowBoundryException OutOfMemoryException

Phasing control for periodic schedulables

when start() called after absolute start time now, phased, all past, & exception

PhysicalMemory

Update documentation to improve clarity. Separate from RawMemory

slide-28
SLIDE 28

28 Real-TIme Specifj fjcation for Java 2.0

Small Change

RelativeTime

add compareTo0() add scale(int factor)

Timed

add reset() method better support for watchdog timers

PriorityCeilingEmulation

now required in base module

slide-29
SLIDE 29

29 Real-TIme Specifj fjcation for Java 2.0

Small Change

Consistency

provide for fjring an AsyncEvent (or release an AsyncEventHandler) on all resource limit errors. new methods as necessary to provide both a returned object and one that takes a destination, e.g., to reuse HighResolutionTime objects update semantics for cost enforcement to permit a schedulable's CPU use to be bound by its cost parameter in each period soft cost enforcement

slide-30
SLIDE 30

30 Real-TIme Specifj fjcation for Java 2.0

Modularization Goals

Provide useful subsets of the RTSJ

with and without a realtime GC with and without device support

Encourage more implementations

Hard realtime, e.g., for control systems Soft realtime, e.g. for system monitoring No realtime, e.g., for development

slide-31
SLIDE 31

31 Real-TIme Specifj fjcation for Java 2.0

Modules

Base

Schedulables Priority Inheritance Clock ...

Device

Happenings RawMemory ...

Memory Area

immortal physical scoped

Advanced Options

ATC ISR

slide-32
SLIDE 32

32 Real-TIme Specifj fjcation for Java 2.0

Conclusion

A common API for realtime Java

provides for realtime sceduling and control support interaction with environment reduce need for external code

Base for a dynamic cyberphysical platform

robust basis resource control recognizes realtime requirement

slide-33
SLIDE 33

33 aicas GmbH

Contact Information

  • Dr. James J. Hunt

aicas GmbH

Haid-und-Neu-Str. 18 D-76139 Karlsruhe Germany jjh@aicas.com

JSR 282

Current specifjcation: https://www.aicas.com/cms/en/rtsj Java Project Page: http://java.net/projects/rtsj-2 Mailing List: jsr282-feedback@aicas.com Discussion: http://www.linkedin.com/groups/ RTSJ-8147216 Twitter: @realtimejava #RTSJ