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

Slides:



Advertisements
Similar presentations
AspectWerkz 2 - and the road to AspectJ 5 Jonas Bonér Senior Software Engineer BEA Systems.
Advertisements

Introduction to Memory Management. 2 General Structure of Run-Time Memory.
Topic 10 Java Memory Management. 1-2 Memory Allocation in Java When a program is being executed, separate areas of memory are allocated for each class.
ITEC 320 Lecture 11 Pointers(1). Pointers Review Packages –Generic –Child Homework 3 is posted.
CS 326 Programming Languages, Concepts and Implementation Instructor: Mircea Nicolescu Lecture 18.
Chapter 8 Runtime Support. How program structures are implemented in a computer memory? The evolution of programming language design has led to the creation.
Chapter 9 Subprogram Control Consider program as a tree- –Each parent calls (transfers control to) child –Parent resumes when child completes –Copy rule.
CSE 2501 Review Declaring a variable allocates space for the type of datum it is to store int x; // allocates space for an int int *px; // allocates space.
© Andy Wellings, 2004 Roadmap  Introduction  Concurrent Programming  Communication and Synchronization  Completing the Java Model  Overview of the.
1 Names, Scopes and Bindings. 2 Names Kinds of names Kinds of names Variables, functions, classes, types, labels, blocks, operators, tasks, etc. Variables,
Run-Time Storage Organization
Celina Gibbs Software Architecture Seng 522 STARS Scoped Types and Aspects for Realtime Systems.
© Andy Wellings, 2004 Roadmap  Introduction  Concurrent Programming  Communication and Synchronization  Completing the Java Model  Overview of the.
Run time vs. Compile time
The environment of the computation Declarations introduce names that denote entities. At execution-time, entities are bound to values or to locations:
1 Scenario: Audio Clip Imagine that your application played an audio clip Based on user action, a different audio clip may begin playing You want only.
© Andy Wellings, 2004 Roadmap  Introduction  Concurrent Programming  Communication and Synchronization  Completing the Java Model  Overview of the.
More on AspectJ. aspect MoveTracking { private static boolean _flag = false; public static boolean testAndClear() { boolean result = _flag; _flag = false;
Abstract data types & object-oriented paradigm. Abstraction Abstraction: a view of an entity that includes only the attributes of significance in a particular.
1 Run time vs. Compile time The compiler must generate code to handle issues that arise at run time Representation of various data types Procedure linkage.
© Andy Wellings, 2004 Roadmap  Introduction  Concurrent Programming  Communication and Synchronization  Completing the Java Model  Overview of the.
Programming Languages and Paradigms Object-Oriented Programming.
 2006 Pearson Education, Inc. All rights reserved Classes: A Deeper Look.
Dynamic Memory Allocation Questions answered in this lecture: When is a stack appropriate? When is a heap? What are best-fit, first-fit, worst-fit, and.
CS 403: Programming Languages Lecture 2 Fall 2003 Department of Computer Science University of Alabama Joel Jones.
EE4E. C++ Programming Lecture 1 From C to C++. Contents Introduction Introduction Variables Variables Pointers and references Pointers and references.
Real-Time Java on JOP Martin Schöberl. Real-Time Java on JOP2 Overview RTSJ – why not Simple RT profile Scheduler implementation User defined scheduling.
1 Comp 104: Operating Systems Concepts Java Development and Run-Time Store Organisation.
Chapter 5: Programming Languages and Constructs by Ravi Sethi Activation Records Dolores Zage.
CSSE501 Object-Oriented Development. Chapter 12: Implications of Substitution  In this chapter we will investigate some of the implications of the principle.
Enhancements to Java for Real Time Systems Theresa Dsena CSE Fall 2006 Prof. Ganesan.
Basic Semantics Associating meaning with language entities.
Constructors CMSC 202. Object Creation Objects are created by using the operator new in statements such as… The following expression invokes a special.
1 Records Record aggregate of data elements –Possibly heterogeneous –Elements/slots are identified by names –Elements in same fixed order in all records.
Dynamic Memory Allocation. Domain A subset of the total domain name space. A domain represents a level of the hierarchy in the Domain Name Space, and.
EEL The Real-Time Specification for Java (1)
IDENTIFYING SEMANTIC DIFFERENCES IN ASPECTJ PROGRAMS Martin Görg and Jianjun Zhao Computer Science Department, Shanghai Jiao Tong University.
1 Homework HW5 due today Review a lot of things about allocation of storage that may not have been clear when we covered them in our initial pass Introduction.
Run-Time Storage Organization Compiler Design Lecture (03/23/98) Computer Science Rensselaer Polytechnic.
Inter-Type Declarations in AspectJ Awais Rashid Steffen Zschaler © Awais Rashid, Steffen Zschaler 2009.
Demeter Aspects We study techniques for the emerging area of Aspect-Oriented Software Development and focus on the following areas:  Aspectual Collaborations.
The life time of local variables (in a method). Local variables Local variable: A local variable is used to store information that is relevant for the.
111 G53SRP: RTSJ Memory Areas Chris Greenhalgh School of Computer Science.
Classes. Constructor A constructor is a special method whose purpose is to construct and initialize objects. Constructor name must be the same as the.
Programming Languages and Design Lecture 6 Names, Scopes and Binding Instructor: Li Ma Department of Computer Science Texas Southern University, Houston.
1 Lecture07: Memory Model 5/2/2012 Slides modified from Yin Lou, Cornell CS2022: Introduction to C.
 2006 Pearson Education, Inc. All rights reserved Classes: A Deeper Look, Part 1.
AOSD'04, Lancaster, UK 1 Remote Pointcut - A Language Construct for Distributed AOP Muga Nishizawa (Tokyo Tech) Shigeru Chiba (Tokyo Tech) Michiaki Tatsubori.
Implementing Subprograms
Object Lifetime and Pointers
Data Types In Text: Chapter 6.
Chapter 5: Enhancing Classes
Java Memory Management
Names and Attributes Names are a key programming language feature
Overview 4 major memory segments Key differences from Java stack
CSE 374 Programming Concepts & Tools
Java Programming Language
CSE 3302 Programming Languages
Dynamically Allocated Memory
Implementing Subprograms
Storage.
Names, Binding, and Scope
Complex Data Types One very important measure of the “goodness” of a PL is the capability of its data types to model the problem space variables Design.
Overview 4 major memory segments Key differences from Java stack
LoD in AspectJ Karl Lieberherr.
Dynamic Memory.
Local variables and how to recognize them
RUN-TIME STORAGE Chuen-Liang Chen Department of Computer Science
Run-time environments
Implementing Subprograms
Presentation transcript:

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 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.

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.  Open source implementations also available We are particularly interested in RTSJ’s special memory management model

Background – RTSJ (cont.) RTSJ’s Scoped-memory based memory model  Scoped memory areas provide guarantee on object allocation time

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

Background – RTSJ (cont.) A T1 B × C × × × × ×

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

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 √

Problems of compiling Aspects with RTSJ Program – An Example 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); } 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 } m1 m2 cd cd.run()

Problems of compiling Aspects with RTSJ Program – An Example(cont.) Now we want to aspectize it so that it only does periodical polling. 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 } m1 m2 cd cd.run() PeriodicPoll ILLEGAL! Aspect instantiation is implicit, programmers cannot avoid the problem.

Problems of compiling Aspects with RTSJ Program – cflow based aspect instantiation Global Stack aspect instance for level 1 aspect instance for level 2 ILLEGAL! Similar problems exist for cflow pointcuts with variable bindings Singleton aspect instantiation and reflective access to thisJoinPoint should be fine.

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.

Proposed compilation approaches for Aspects + RTSJ (cont.) CFLOW-based aspect instantiation (cont. ) × A B C portal CFLOW-based aspect instantiation looking up – climbing up the memory chain and looking it up in each of the stacks.

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

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.

Thank you! Questions and Discussions