How to Compile Aspects with RealTime Java - PowerPoint PPT Presentation

1 / 16
About This Presentation
Title:

How to Compile Aspects with RealTime Java

Description:

Real-Time Java Specification (RTSJ) -- an emerging technology to enhance Java ... Official reference implementation by TimeSys Corp. ... – PowerPoint PPT presentation

Number of Views:27
Avg rating:3.0/5.0
Slides: 17
Provided by: wupc
Category:

less

Transcript and Presenter's Notes

Title: How to Compile Aspects with RealTime Java


1
How to Compile Aspects with Real-Time Java
  • Pengcheng Wu
  • Northeastern University
  • Mar. 14, 2005
  • FOAL Workshop with AOSD05

2
Motivations
  • Real-time systems tend to have a lot of
    cross-cutting concerns, e.g., thread scheduling,
    memory management
  • AOP is expected to be helpful to modularize those
    concerns
  • Real-Time Java Specification (RTSJ) -- an
    emerging technology to enhance Java with real
    time features
  • Current AspectJ compilation approaches do not
    work well with Real-Time Java Specifications
    special memory model.

3
Background Real-Time Java Specification (RTSJ)
  • Java is unsuitable to implement real-time systems
  • unpredictable garbage collection
  • unpredictable thread scheduling
  • RTSJ has been proposed to minimize those
    unpredictability
  • Official reference implementation by TimeSys
    Corp.
  • http//www.timesys.com
  • Open source implementations also available
  • We are particularly interested in RTSJs special
    memory management model

4
Background RTSJ (cont.)
  • RTSJs Scoped-memory based memory model
  • Scoped memory areas provide guarantee on object
    allocation time

5
Background RTSJ (cont.)
Objects are just like regular Java heap objects
Objects never reclaimed
Threads can enter scopes objects in a scope are
freed altogether when all threads left scope
6
Background RTSJ (cont.)
T1

A




B

C

7
Background RTSJ (cont.)
To avoid dangling pointers, an object reference
rule is checked by RTSJ-compliant JVMs.
Programmers are responsible for following the
rule.
ILLEGAL!
A
OK


B

C
8
Question How about using AspectJ with RTSJ?
  • How about aspect instantiation? It is implicit
    and beyond control of programmers.
  • Instance-based aspect instantiation (perthis,
    pertarget)
  • CFLOW-based aspect instantiation (percflow)
  • CFLOW pointcuts with variable bindings
  • Singleton aspect and reflective access to
    thisJoinPoint v

9
Problems of compiling Aspects with RTSJ Program
An Example
class Detector implements Runnable public void
run() Frame frame receiveFrame() //gets
a frame and stores it // into a table
//check if any two planes are //going to
collide
class App extends RealtimeThread public static
void main(String args) MemoryArea mem
ImmortalMemory.instance() App app (App)
mem.newInstance(App.class) app.start()
public void run() ScopedMemory m1 new
LTMemory( ... ) m1.enter(new Runner())
class Runner implements Runnable public
void run() Detector cd new Detector( ...
) LTMemory m2 new LTMemory( ... )
while(true) m2.enter(cd)
cd
m1
m2
cd.run()
10
Problems of compiling Aspects with RTSJ Program
An Example(cont.)
  • Now we want to aspectize it so that it only does
    periodical polling.

ILLEGAL!
aspect PeriodicPoll perthis(p()) Time
lastTimePolled pointcut p() execution(
Detector.run(..)) around() p() if(hasnt
yet been 2 seconds) getCurrentThread().yield()
//don't do polling else //update the
time lastTimePolled System.getCurrentTime()
proceed() //do polling
cd
m1
PeriodicPoll
m2
cd.run()
  • Aspect instantiation is implicit, programmers
    cannot avoid the problem.

11
Problems of compiling Aspects with RTSJ Program
cflow based aspect instantiation
  • Global
  • Stack
  • Similar problems exist for cflow pointcuts with
    variable bindings
  • Singleton aspect instantiation and reflective
    access to thisJoinPoint should be fine.

ILLEGAL!
aspect instance for level 2
aspect instance for level 1
12
Proposed compilation approaches for Aspects
RTSJ
  • Instance-based Aspect Instantiation
  • Make instantiation explicit?
  • Allocate aspect instances in ImmortalMemory or
    HeapMemory?
  • Allocate aspect instances in the same scoped
    memories as the host objects. v
  • CFLOW-based aspect instantiation
  • Make use of the Portal object of a scoped memory
    area.

13
Proposed compilation approaches for Aspects
RTSJ (cont.)
  • CFLOW-based aspect instantiation (cont. )

A
portal

portal
B
portal
C
  • CFLOW-based aspect instantiation looking up
    climbing up the memory chain and looking it up in
    each of the stacks.

14
Proposed compilation approaches for Aspects
RTSJ (cont.)
  • CFLOW-based Aspect Instantiation (cont.)
  • Problem portal object may be used by user
    program for threads communication purpose in
    RTSJ.
  • Solution do automatic adaptation during compile
    time. An aspect may do the job!
  • CFLOW pointcuts with variable bindings
  • Similar approach as cflow-based aspect
    instantiation

15
Future work
  • Implementation of an actual compiler
  • Formal proof that there will be no aspect
    introduced object reference violations using RTSJ
    semantics and probably enhanced AspectJ semantics.

16
  • Thank you!
  • Questions and Discussions
Write a Comment
User Comments (0)
About PowerShow.com