1 / 16

How to Compile Aspects with Real-Time Java

How to Compile Aspects with Real-Time Java. Pengcheng Wu Northeastern University Mar. 14, 2005 FOAL Workshop with AOSD’05. Motivations. Real-time systems tend to have a lot of cross-cutting concerns, e.g., thread scheduling, memory management

hien
Download Presentation

How to Compile Aspects with Real-Time Java

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


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

  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 Specification’s 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 RTSJ’s special memory management model

  4. Background – RTSJ (cont.) • RTSJ’s 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 Objectsnever 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 √

  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(hasn’t 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. √ • 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

More Related