Oplægget blev holdt ved et seminar i InfinIT-interessegruppen højniveau sprog til indlejrede systemer den 2. februar 2011.
Læs mere om interessegruppen på http://www.infinit.dk/dk/interessegrupper/hoejniveau_sprog_til_indlejrede_systemer/
Ph.d. thesis modeling and simulation of z source inverter design and its con...
Similar to Real-Time Java by Example. Experiences from a 9th Semester Software Project at AAU af Kasper S. Luckow, Christian Frost and Casper S. Jensen
Java Performance and Using Java Flight RecorderIsuru Perera
Similar to Real-Time Java by Example. Experiences from a 9th Semester Software Project at AAU af Kasper S. Luckow, Christian Frost and Casper S. Jensen (20)
Real-Time Java by Example. Experiences from a 9th Semester Software Project at AAU af Kasper S. Luckow, Christian Frost and Casper S. Jensen
1. Real-Time Java by Example
Experiences from a 9th Semester Software Project
at AAU
Kasper S. Luckow, Christian Frost, and Casper S. Jensen
2. February 2011
InfinIT
1
2. Focus of the Project
• Gain knowledge in the area of real-time systems
• Specifically embedded and safety-critical real-time systems
• Determine how temporal correctness can be ensured
(schedulability, WCET)
• Determine how Java can be applied to this area
• Conduct a case-study for practical experience
2
3. Java for Real-Time Systems Development
• It would be nice to use Java for real-time systems
development over languages such as C/C++
• Increased productivity
• Reduced risk of errors
• A more common language for newly educated programmers
• Using Java poses a number of interesting problems
• How can we express the necessary real-time concepts in Java?
• How can we verify properties such as WCET and
schedulability?
3
4. The Real-Time Specification for Java
At a quick glance
• Java, in the traditional sense lacks facilities for real-time
systems
• The RTSJ is broad, flexible, and contains many details
Facilities and concepts introduced in the RTSJ:
• Schedulable objects and scheduling.
• Real-time threads.
• Asynchronous event handling and timers.
• Asynchronous transfer of control (ATC).
• Physical and raw memory access.
• Time values and clocks.
• Synchronization and resource sharing.
• Memory management, scoped and immortal memory.
4
5. Profiles
• Desire to certify safety-critical systems
• Desire to reduce resource usage for embedded systems
• Profiles are used to reduce complexity of the RTSJ and allow
for easier analysis
• Ravenscar-Java (RJ)
• Safety-Critical Java (SCJ)
• Predictable Java (PJ)
5
6. Changes to the RTSJ
Example from the Ravenscar-Java
“The key aim of the Ravenscar-Java profile is to develop
a concurrent Java programming model that supports
predictable and reliable execution of application
programs, thus benefiting the construction of modern
high integrity software”
Changes can be categorised into three areas:
• Predictability of memory utilisation.
• Predictability of timing.
• Predictability of control and data flow.
6
7. Case - The Mine Pump
Overview
• Classic text-book example of a real-time system
• Pump starts when water level is high
• Pump stops when water level is low
• Pump never runs when methane level is high
Water flow sensor
Methane sensor
Air flow sensor
Carbon monoxide sensor
High water level detector
Low water level detector
7
8. Modelling the Mine Pump
The LEGO Construction
1 Brick feeder
2 Conveyor belt
3 JOP board
4 High water sensor
5 Low water sensor
6 Mine shaft
7 Water pump
8 Methane sensor
9 Conveyor belt
10 Slide
11 Environment motor
12 Environment motor
8
9. Modelling the Mine Pump
Hardware
• Java Optimized Processor (JOP) (jopdesign.com)
• Implemented on a Cyclone EP1C12 FPGA
• 100MHz processor, 512KB flash, 1MB SRAM
Implementation language: Ravenscar-Java
9
11. Walk-through of the Implementation
Declaring Tasks
new P e r i o d i c T h r e a d (
new P r i o r i t y P a r a m e t e r s ( PERIODIC PRIORITY ) ,
new P e r i o d i c P a r a m e t e r s (
new A b s o l u t e T i m e ( 0 , 0 ) ,
new R e l a t i v e T i m e ( PERIODIC PERIOD , 0 ) ) ,
new W a t e r L e v e l D e t e c t i o n R u n n a b l e ( . . . ) ) ;
new S p o r a d i c W a t e r L e v e l H i g h (
new P r i o r i t y P a r a m e t e r s ( SPORADIC PRIORITY ) ,
new S p o r a d i c P a r a m e t e r s (
new R e l a t i v e T i m e ( SPORADIC PERIOD , 0 ) , 1 ) ,
waterpumpMotor ) ;
11
12. Walk-through of the Implementation
Handling the Periodic Event
p u b l i c c l a s s WaterLevelDetectionRunnable implements
{
...
p u b l i c void run ( ) {
i f ( highWaterSensor . isWaterLevelReached ( ) ) {
waterHighEvent.fire();
}
e l s e i f ( lowWaterSensor . isNoWaterPresent ( ) ) {
waterLowEvent . f i r e ( ) ;
}
}
}
12
13. Walk-through of the Implementation
Handling the Sporadic Event
public c l a s s SporadicWaterLevelHigh
extends SporadicEventHandler
{
p u b l i c void handleAsyncEvent () {
t h i s . waterpumpMotor . s t a r t ( ) ;
}
}
13
14. Comparing the Profiles
Safety Critical Java
addToMission (
new P e r i o d i c G a s D e t e c t i o n (
new P r i o r i t y P a r a m e t e r s ( GAS PRIORITY ) ,
new P e r i o d i c P a r a m e t e r s ( new R e l a t i v e T i m e ( 0 ,
Scheduler . getDefaultScheduler () ,
new LTMemory ( 1 0 ∗ 1 0 2 4 ) ,
gasSensor ,
waterPumpMotor )
));
14
15. Temporal Correctness
• WCET analysis
• Can be determined through e.g. measurements, simulation,
and static analysis
• In our case safe WCETs are required and tight WCETs are
desirable
• Often dependent on the underlying hardware, operating system
and virtual-machine
• Predictability is the key!
• Schedulability analysis
• “Tightness” of schedulability analysis desirable
• Must take necessary factors into account to ensure the
schedulability
15
17. Analysing the Program
Schedulability Analysis using TIMES
Idle
waterLevelChanged==1
go?
C
WaterDetection
C Low C High
SporadicLowWaterLevel SporadicHighWaterLevel
C
Cleanup
waterLevelChanged:=0
Furthermore schedulability analysis was also conducted using
17
18. Summary
• The Java language is being adapted for easier analysis
through profiles
• Tools can help determine properties such as WCET and
schedulability for the programmer
• Still a lot of limitations regarding the capabilities of these tools
18