A Synchronized Block Join Point for AspectJ Chenchen Xi, Bruno Harbulot and John Gurd The University of Manchester Brussels, April 2008.

Slides:



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

Mohamed M. Saad & Mohamed A. Mohamedin.  Static Execution Graph  Nodes; can be either ▪ Basic Blocks; a sequence of non-branching instructions ▪ Variables.
Mohamed. M. Saad Mohamed A. Mohamedin & Prof. Binoy Ravindran VT-MENA Program Electrical & Computer Engineering Department Virginia Polytechnic Institute.
Runtime checking of expressive heap assertions Greta Yorsh, Martin Vechev, Eran Yahav, Bard Bloom.
Concurrency Important and difficult (Ada slides copied from Ed Schonberg)
Written by: Dr. JJ Shepherd
Unit 141 Threads What is a Thread? Multithreading Creating Threads – Subclassing java.lang.Thread Example 1 Creating Threads – Implementing java.lang.Runnable.
George Blank University Lecturer. CS 602 Java and the Web Object Oriented Software Development Using Java Chapter 4.
11-Jun-15 Producer-Consumer An example of using Threads.
Aspect-Oriented Software Development (AOSD) Tutorial #2 AspectJ Basics.
Synchronization in Java Nelson Padua-Perez Bill Pugh Department of Computer Science University of Maryland, College Park.
PRESTO: Program Analyses and Software Tools Research Group, Ohio State University Regression Test Selection for AspectJ Software Guoqing Xu and Atanas.
Synchronization in Java Fawzi Emad Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
ThreadThread Thread Basics Thread Synchronization Animations.
Java Exception Handling ● Exception = an event that occurs during the execution of a program that disrupts the normal flow of instructions: – Examples:
12.1 Exceptions The limitations of traditional methods of exception handling Error conditions are a certainty in programming Programmers make.
© Amir Kirsh Threads Written by Amir Kirsh. 2 Lesson’s Objectives By the end of this lesson you will: Be familiar with the Java threads syntax and API.
1 CSCD 330 Network Programming Lecture 13 More Client-Server Programming Sometime in 2014 Reading: References at end of Lecture.
A Bridge to Your First Computer Science Course Prof. H.E. Dunsmore Concurrent Programming Threads Synchronization.
Introduction to Aspect Oriented Programming Presented By: Kotaiah Choudary. Ravipati M.Tech IInd Year. School of Info. Tech.
Accelerating Precise Race Detection Using Commercially-Available Hardware Transactional Memory Support Serdar Tasiran Koc University, Istanbul, Turkey.
Lecture 5 : JAVA Thread Programming Courtesy : MIT Prof. Amarasinghe and Dr. Rabbah’s course note.
Quick overview of threads in Java Babak Esfandiari (extracted from Qusay Mahmoud’s slides)
Class 14: Object-Oriented Programming Fall 2010 University of Virginia David Evans cs2220: Engineering Software.
1162 JDK 5.0 Features Christian Kemper Principal Architect Borland.
Imperial College - Department of Computing Continuous Performance Testing in Virtual Time Nikos Baltas & Tony Field Department of Computing Imperial College.
Processes & Threads Bahareh Goodarzi. Single & Multiple Thread of control code files data code files data.
Netprog: Java Intro1 Crash Course in Java. Netprog: Java Intro2 Why Java? Network Programming in Java is very different than in C/C++ –much more language.
1 CMSC 341: Data Structures Nilanjan Banerjee Data Structures University of Maryland Baltimore County
Threads in Java. Processes and Threads Processes –A process has a self-contained execution environment. –Has complete set of runtime resources including.
AOP-1 Aspect Oriented Programming. AOP-2 Aspects of AOP and Related Tools Limitation of OO Separation of Concerns Aspect Oriented programming AspectJ.
Internet Software Development Controlling Threads Paul J Krause.
Synchronized and Monitors. synchronized is a Java keyword to denote a block of code which must be executed atomically (uninterrupted). It can be applied.
1 Interfacing & embedding. 2 References  Full tutorial and references Embedding and Interfacing Manual Windows - select “Documentation” from the ECLiPSe.
Synchronizing threads, thread pools, etc.
Multithreading in Java Sameer Singh Chauhan Lecturer, I. T. Dept., SVIT, Vasad.
Region Pointcut for AspectJ Shumpei Akai Shigeru Chiba Muga Nishizawa.
BEGINNING PROGRAMMING.  Literally – giving instructions to a computer so that it does what you want  Practically – using a programming language (such.
Upcoming Presentations ILM Professional Service – Proprietary and Confidential ( DateTimeTopicPresenter March PM Distributed.
Threads in Java1 Concurrency Synchronizing threads, thread pools, etc.
Multithreaded programming  Java provides built-in support for multithreaded programming. A multithreaded program contains two or more parts that can run.
Monitors CSCI 201L Jeffrey Miller, Ph.D. HTTP :// WWW - SCF. USC. EDU /~ CSCI 201 USC CSCI 201L.
CMSC 330: Organization of Programming Languages Threads.
Recitation 3 2D Arrays, Exceptions. 2D arrays 2D Arrays Many applications have multidimensional structures: ●Matrix operations ●Collection of lists ●Board.
Threads in Java Threads Introduction: After completing this chapter, you will be able to code your own thread, control them efficiently without.
Computer Science 320 A First Program in Parallel Java.
Multithreading. Multitasking The multitasking is the ability of single processor to perform more than one operation at the same time Once systems allowed.
AOP with AspectJ Awais Rashid, Steffen Zschaler © Awais Rashid, Steffen Zschaler 2009.
Threads b A thread is a flow of control in a program. b The Java Virtual Machine allows an application to have multiple threads of execution running concurrently.
ABC: an implementation of AspectJ Oege de Moor Programming Tools Group University of Oxford joint work with Ganesh Sittampalam, Sascha Kuzins, Chris Allan,
Concurrency in Java MD. ANISUR RAHMAN. slide 2 Concurrency  Multiprogramming  Single processor runs several programs at the same time  Each program.
Introduction to Java Programming by Laurie Murphy Revised 09/08/2016.
CSCD 330 Network Programming
Multi Threading.
AKA the birth, life, and death of variables.
Interface.
RADE new features via JAVA
Multithreading in Java
null, true, and false are also reserved.
Introduction to Java Programming
Exception Handling in Java
Multithreading.
Android Topics UI Thread and Limited processing resources
Units with – James tedder
AKA the birth, life, and death of variables.
CSCD 330 Network Programming
Tutorial MutliThreading.
Lecture 19 Threads CSE /6/2019.
Java Chapter 3 (Estifanos Tilahun Mihret--Tech with Estif)
Presentation transcript:

A Synchronized Block Join Point for AspectJ Chenchen Xi, Bruno Harbulot and John Gurd The University of Manchester Brussels, April 2008

2  The goal of SoC in parallel programming  loop join point  Full control of the thread behavior  Thread:: notify()/notifyAll()/wait().  Distributed Java programs,  sharing data among multiple threads  sharing among clusters of JVMs  sharing among clusters of physical computers.  Replace lock-based synchronization  Transactional Memory Introduction

3 Synchronized Block vs. Synchronized Method Synchronized block class Foo { public void bar1() {...} } class Example { public static void main(String arg[ ]) { Foo objecta = new Foo() ; Foo objectb = new Foo() ; synchronized (objecta) { objecta.bar1() ; } objectb.bar1() ; } } Synchronized method class Foo { public synchronized void bar1() {...} } class Example { public static void main(String arg[ ]){ Foo objecta = new Foo() ; Foo objectb = new Foo() ; objecta.bar1() ; objectb.bar2() ; } }

4 class Example { public static void main(String arg[ ]) { Foo objecta = new Foo() ; Foo objectb = new Foo() ; synchronized(objecta) { objecta.bar1() ; } objectb.bar1() ; } } arg java.lang.String[]; $r0 = new Foo; specialinvoke $r0. ()>(); objecta = $r0; $r1 = new Foo; specialinvoke $r1. ()>(); objectb = $r1; entermonitor objecta; label0: virtualinvoke objecta. (); exitmonitor objecta; label1: goto label5; label2: $r2 label3: exitmonitor objecta; label4: throw $r2; label5: return; JavaJimple Example of Synchronized Block in Java and Jimple

5 entermonitor $r0 0: //in the synchronized block exitmonitor $r0; 1: goto label5 ; 2: $r1 3: exitmonitor $r0; 4: throw $r1; 5: return; 5b: return; 5a: nop; 1: goto label5a; Control-flow Graph

6 void around(Object t): synchronize(t) && withincode(* main(..)) && args(t) { proceed(t) ; } void around(Object t): synchronize_body(t) && withincode(* main(..)) && args(t) { proceed(t) ; } void around(Object t): synchronize(t) && withincode(* main(..)) && args(t) { rm_proceed(t) ; } Pointcuts and Advice Semantics for a Synchronized Block Join Point lock (Type t) && withincode (* main(..)) && args(t) unlock (Type t) && withincode (* main(..)) && args(t) Lock based synchronized (Type t) && withincode (* main(..)) && args(t) synchronized_body( Type t) && withincode (* main(..)) && args(object) Block based Jimple Code arg java.lang.String[]; $r0 = new Foo; specialinvoke $r0. ()>(); objecta = $r0; $r1 = new Foo; specialinvoke $r1. ()>(); objectb = $r1; entermonitor objecta; label0: virtualinvoke objecta. (); exitmonitor objecta; label1: goto label5; label2: $r2 label3: exitmonitor objecta; label4: throw $r2; label5: return; catch java.lang.Throwable from label0 to label1 with label2; catch java.lang.Throwable from label3 to label4 with label2; Jimple Code arg java.lang.String[]; $r0 = new Foo; specialinvoke $r0. ()>(); objecta = $r0; $r1 = new Foo; specialinvoke $r1. ()>(); objectb = $r1; label0: virtualinvoke objecta. (); label1: goto label5; label5: return;

7 void around(Object obj): synchronized(obj) && args(obj) { if( isDistributed(obj)) { ClusterManager.aquireDistributedLock(obj) ; rm_proceed() ; ClusterManager.releaseDistributedLock(obj) ; } else proceed() ; } Example to Change Lock Implementation. * J. Boner and E. Kuleshov. Clustering the Java Virtual Machine using Aspect-Oriented Programming. In AOSD ’07: Industry Track.

8 void around(Object obj): synchronized(obj) && args(obj) { /* before proceed(), limits the CPU usage */ double receivedCPUUsage = SystemInformation. getProcessCPUUsage (m_prevSnapshot, event); assert (receivedCPUUsage < 50) ; /* before proceed(), check re-entrant locking, handle re-entrant locking if it happens */ if( !Thread.holdsLock(obj)) proceed(obj) ; else if (isLegalLock(obj)) rm_proceed(obj) ; else throw new Exception("Acquired illegal Lock") ; } Example to Check CPU Usage and Re-entrant Risk. * L. Stepanian. Inlining Java Native calls at runtime. In VEE ’05.

9 String intern() { synchronized(map) { Object o = map.get(this) ; if(o!=null) return (String) o ; map.put(this,this) ; return this ; } void around(Object map): synchronize(map) && withincode(* *.intern(..)){ atomic{ rm_proceed(map) ; } Converting Synchronized Blocks into Transactions * A. Adl-Tabatabai, C. Kozyrakis and B. Saha. Unlocking Concurrency: Multicore programming with transactional memory. Queue, v.4 n.10,2007.

10