Contract-based synchronization of multi-threaded java programs

Today, most new software products use concurrency in some capacity. However, the expressive power afforded by the use of concurrency comes at the expense of increased complexity. Without proper synchronization, concurrent access to shared objects can lead to race conditions, and incorrect synchronization logic can lead to starvation or deadlock. Moreover, concurrency confounds the development of reusable software modules because code implementing an application's synchronization logic tends to be tightly interleaved with the “functional” code. Interleaving complicates program understanding and maintenance, producing brittle applications. Contract-based models of synchronization, such as the Synchronization Units Model (Szumo), attempt to address these problems by: (1) expressing synchronization concerns in declarative synchronization contracts to separate them from functional code; and (2) using a runtime system that dynamically interprets and “negotiates” the contracts, thereby automatically synchronizing threads. However, this approach requires a special compiler and runtime system, making it difficult to integrate Szumo into mainstream object-oriented programming languages or conduct empirical studies to understand software engineering tradeoffs when using Szumo or hand coding synchronization. This thesis investigates two “lighter-weight” approaches for integrating a contract-based synchronization model with a mainstream object-oriented programming language. The first approach works with any multi-threaded Java program. In this approach, an application programmer adds special Java annotations to a class whose methods contain only functional code. A compiler plugin generates synchronization code from the annotated program based on synchronization concerns declared in the annotations; the generated synchronization code is added to the annotated program, which then executes in a standard JVM. The second approach targets IP telecommunication (IPT) services that are deployed to a SIP servlets container. It makes use of a synchronization middleware. Instead of embedding synchronization code in the message handlers that implement a service, a programmer provides a synchronization contract that is loaded when the service is deployed to a container running our middleware. The middleware intercepts messages that a container routes to the service and consults the contract to determine when to schedule the message handler thread. Contributions of work reported in this thesis include: (1) Development of a generative approach that permits use of synchronization annotations with a mainstream object-oriented language. (2) Development of a middleware approach that permits use of contract-based synchronization with a standard execution platform for services. (3) Demonstration that contract-based synchronization enables packaging the implementation of synchronization as an OTS component, which can be seamlessly swapped with one that implements a different protocol, e.g., to tune performance. (4) Presentation of results of case studies with both approaches. The work described in this thesis was performed in collaboration with AT&T Research Labs and Oracle Research Labs.

[1]  Yi Huang,et al.  Prototyping synchronization policies for existing programs , 2009, 2009 IEEE 17th International Conference on Program Comprehension.

[2]  Andrew M. Lister The problem of nested monitor calls , 1977, OPSR.

[3]  R. E. Kurt Stirewalt,et al.  The universe model: an approach for improving the modularity and reliability of concurrent programs , 2000, SIGSOFT '00/FSE-8.

[4]  Ralph Johnson,et al.  design patterns elements of reusable object oriented software , 2019 .

[5]  Patrick Th. Eugster,et al.  Can Aspects Implement Contracts? , 2005, RISE.

[6]  Anne Dinning,et al.  A survey of synchronization methods for parallel computers , 1989, Computer.

[7]  Alan B. Johnston,et al.  SIP: Understanding the Session Initiation Protocol , 2001 .

[8]  Hans-Arno Jacobsen,et al.  Externalizing Java Server Concurrency with CAL , 2008, ECOOP.

[9]  Charles Zhang FlexSync: An aspect-oriented approach to Java synchronization , 2009, 2009 IEEE 31st International Conference on Software Engineering.

[10]  R. Stirewalt,et al.  Developing an Alloy Framework akin to OO Frameworks , 2006 .

[11]  Karl J. Lieberherr,et al.  Aspect-oriented programming with adaptive methods , 2001, CACM.

[12]  Robert C. Martin Clean Code - a Handbook of Agile Software Craftsmanship , 2008 .

[13]  Mitchell Wand,et al.  Continuation-Based Multiprocessing , 1980, High. Order Symb. Comput..

[14]  Michael Philippsen,et al.  Fair multi-branch locking of several locks , 1997 .

[15]  Maged M. Michael,et al.  Software Transactional Memory: Why Is It Only a Research Toy? , 2008, ACM Queue.

[16]  Martin Odersky,et al.  Scala Actors: Unifying thread-based and event-based programming , 2009, Theor. Comput. Sci..

[17]  Simon L. Peyton Jones,et al.  Composable memory transactions , 2005, CACM.

[18]  Per Brinch Hansen,et al.  Operating System Principles , 1973 .

[19]  Mark Moir,et al.  Hybrid transactional memory , 2006, ASPLOS XII.

[20]  William G. Griswold,et al.  An Overview of AspectJ , 2001, ECOOP.

[21]  Tevfik Bultan,et al.  Verifiable concurrent programming using concurrency controllers , 2004 .

[22]  Nir Shavit,et al.  On the inherent weakness of conditional synchronization primitives , 2004, PODC '04.

[23]  Victor Luchangco Transaction Synchronizers , 2005 .

[24]  R. E. Kurt Stirewalt,et al.  The interleaving problem in program understanding , 1995, Proceedings of 2nd Working Conference on Reverse Engineering.

[25]  Klaus-Peter Löhr,et al.  JAC: declarative Java concurrency: Research Articles , 2006 .

[26]  Jeff Magee,et al.  Concurrency - state models and Java programs , 2006 .

[27]  Maurice Herlihy,et al.  A flexible framework for implementing software transactional memory , 2006, OOPSLA '06.

[28]  James W. Havender Avoiding Deadlock in Multitasking Systems , 1968, IBM Syst. J..

[29]  Michael F. Kilian A conditional critical region pre-processor for C based on the Owicki and Gries scheme , 1985, SIGP.

[30]  R. E. Kurt Stirewalt,et al.  Contract-based synchronization of IP telecommunication services: a case study , 2011, COMSWARE.

[31]  Daniel P. Friedman,et al.  Engines build process abstractions , 1984, LFP '84.

[32]  Martin C. Rinard,et al.  Effective fine-grain synchronization for automatically parallelized programs using optimistic synchronization primitives , 1999, TOCS.

[33]  R. E. Kurt Stirewalt,et al.  Safe and Reliable Use of Concurrency in Multi-Threaded Shared-Memory Systems , 2005, 29th Annual IEEE/NASA Software Engineering Workshop.

[34]  Gustavo Alonso,et al.  Dynamic weaving for aspect-oriented programming , 2002, AOSD '02.

[35]  James E. Allchin,et al.  Synchronization and recovery of actions , 1985, OPSR.

[36]  Michael Schöttner,et al.  Optimistic Synchronization and Transactional Consistency , 2002, 2nd IEEE/ACM International Symposium on Cluster Computing and the Grid (CCGRID'02).

[37]  Ivar Jacobson,et al.  Object Design: Roles, Responsibilities, and Collaborations , 2002 .

[38]  James R. Larus,et al.  Transactional memory , 2008, CACM.

[39]  Stuart Kent,et al.  Navigation Expressions in OO Modelling , 1998 .

[40]  Bertrand Meyer,et al.  Applying 'design by contract' , 1992, Computer.

[41]  R. E. Kurt Stirewalt,et al.  A component-oriented model for the design of safe multi-threaded applications , 2005, CBSE'05.

[42]  Sreekaanth S. Isloor,et al.  The Deadlock Problem: An Overview , 1980, Computer.

[43]  R. E. Stirewalt,et al.  Designing and implementing a model of synchronization contracts in object-oriented languages , 2003 .

[44]  Mauricio Cortes,et al.  On SIP performance , 2004, Bell Labs Technical Journal.

[45]  P. Strevens Iii , 1985 .

[46]  Dieter Zöbel,et al.  The Deadlock problem: a classifying bibliography , 1983, OPSR.

[47]  David Notkin,et al.  Using role components in implement collaboration-based designs , 1996, OOPSLA '96.

[49]  Shreekant S. Thakkar,et al.  Synchronization algorithms for shared-memory multiprocessors , 1990, Computer.

[50]  Yi Huang,et al.  On Mechanisms for Deadlock Avoidance in SIP Servlet Containers , 2008, IPTComm.

[51]  Yi Huang,et al.  A thread synchronization model for SIP servlet containers , 2009, IPTComm.

[52]  R. E. Kurt Stirewalt,et al.  A Model-Based Design-for-Verification Approach to Checking for Deadlock in Multi-Threaded Applications , 2007, Int. J. Softw. Eng. Knowl. Eng..

[53]  Filip De Turck,et al.  ISE01-2: J2EE-based Middleware for Low Latency Service Enabling Platforms , 2006, IEEE Globecom 2006.

[54]  Domenico Ferrari Client requirements for real-time communication services , 1990 .

[55]  Rodolfo Azevedo,et al.  STM versus lock-based systems: An energy consumption perspective , 2010, 2010 ACM/IEEE International Symposium on Low-Power Electronics and Design (ISLPED).

[56]  Cristina V. Lopes,et al.  Aspect-oriented programming , 1999, ECOOP Workshops.

[57]  C. A. R. Hoare,et al.  Communicating sequential processes , 1978, CACM.

[58]  Martin Fowler,et al.  Patterns of Enterprise Application Architecture , 2002 .

[59]  Keir Fraser,et al.  Language support for lightweight transactions , 2003, SIGP.

[60]  Masaaki Mizuno,et al.  Invariant-based specification, synthesis, and verification of synchronization in concurrent programs , 2002, ICSE '02.

[61]  Jörg Kienzle,et al.  AOP: Does It Make Sense? The Case of Concurrency and Failures , 2002, ECOOP.

[62]  Charles Antony Richard Hoare Towards a theory of parallel programming , 2002 .

[63]  Doug Lea,et al.  Concurrent Programming In Java , 1996 .

[64]  Joe Armstrong,et al.  Making reliable distributed systems in the presence of software errors , 2003 .

[65]  Tom Mens,et al.  Separation of concerns for software evolution , 2002, J. Softw. Maintenance Res. Pract..

[66]  C. A. R. Hoare,et al.  Monitors: an operating system structuring concept , 1974, CACM.

[67]  Ivar Jacobson,et al.  The unified modeling language reference manual , 2010 .

[68]  Gregory W. Bond,et al.  ECharts for SIP servlets: a state-machine programming environment for VoIP applications , 2007, IPTComm '07.