Chair of Software Engineering 1 Concurrent Object-Oriented Programming Arnaud Bailly, Bertrand Meyer and Volkan Arslan.

Slides:



Advertisements
Similar presentations
SCOOP: Simple Concurrent Object-Oriented Programming Extend the pure, strongly typed, object-oriented language Eiffel with a general and powerful concurrency.
Advertisements

Stacks, Queues, and Linked Lists
Programming with App Inventor Computing Institute for K-12 Teachers Summer 2012 Workshop.
Object-Oriented Programming. 2 An object, similar to a real-world object, is an entity with certain properties, and with the ability to react in certain.
Chair of Software Engineering Concurrent Object-Oriented Programming Prof. Dr. Bertrand Meyer Lecture 10: Advanced Object-Oriented Mechanisms (based on.
Templates in C++ Template function in C++ makes it easier to reuse classes and functions. A template can be viewed as a variable that can be instantiated.
© SERG Dependable Software Systems (OO Protocol Testing) Dependable Software Systems Testing the Protocols of Classes in Object-Oriented Programs Material.
2 nd Microsoft Rotor Workshop, Pisa, April 23-25, SCOOPLI for.NET: a library for concurrent object-oriented programming Volkan Arslan, Piotr Nienaltowski.
Concurrency Important and difficult (Ada slides copied from Ed Schonberg)
©Ian Sommerville 2000 Software Engineering, 6th edition. Chapter 12Slide 1 Software Design l Objectives To explain how a software design may be represented.
Chapter 6 Process Synchronization Bernard Chen Spring 2007.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 6: Process Synchronization.
Chair of Software Engineering OOSC - Summer Semester Object-Oriented Software Construction Bertrand Meyer Lecture 3: Abstract Data Types.
Stacks  a data structure which stores data in a Last-in First-out manner (LIFO)  has a pointer called TOP  can be implemented by either Array or Linked.
ADT Stacks and Queues. Stack: Logical Level “An ordered group of homogeneous items or elements in which items are added and removed from only one end.”
© 2006 ITT Educational Services Inc. SE350 System Analysis for Software Engineers: Unit 9 Slide 1 Appendix 3 Object-Oriented Analysis and Design.
Chair of Software Engineering PPoPP 2003, , San Diego SCOOP it up! Piotr Nienaltowski Chair of Software Engineering, ETH Zurich, Switzerland.
Chair of Software Engineering OOSC - Summer Semester Object-Oriented Software Construction Bertrand Meyer.
Formal Methods of Systems Specification Logical Specification of Hard- and Software Prof. Dr. Holger Schlingloff Institut für Informatik der.
Chair of Software Engineering OOSC - Summer Semester Object-Oriented Software Construction Bertrand Meyer.
Chair of Software Engineering Concurrent Object-Oriented Programming Concurrent Object-Oriented Programming Bertrand Meyer, Piotr Nienaltowski.
1 SWE Introduction to Software Engineering Lecture 23 – Architectural Design (Chapter 13)
Chair of Software Engineering 1 Concurrent Object-Oriented Programming Arnaud Bailly, Bertrand Meyer and Volkan Arslan.
Chair of Software Engineering 1 Concurrent Object-Oriented Programming Arnaud Bailly, Bertrand Meyer and Volkan Arslan.
Unit 11 1 Unit 11: Data Structures H We explore some simple techniques for organizing and managing information H This unit focuses on: Abstract Data Types.
Chair of Software Engineering ATOT - Lecture 26, 30 June Advanced Topics in Object Technology Bertrand Meyer.
Chair of Software Engineering 1 Concurrent Object-Oriented Programming Arnaud Bailly, Bertrand Meyer and Volkan Arslan.
Chair of Software Engineering OOSC - Lecture 4 1 Object-Oriented Software Construction Bertrand Meyer.
Collaboration Diagrams. Example Building Collaboration Diagrams.
Chair of Software Engineering 1 Concurrent Object-Oriented Programming Arnaud Bailly, Bertrand Meyer and Volkan Arslan.
Chair of Software Engineering Concurrent Object-Oriented Programming Prof. Dr. Bertrand Meyer Lecture 9: Contracts and Inheritance (based on work with.
Copyright W. Howden1 Lecture 15: Generalization, Polymorphism and States.
Chair of Software Engineering ATOT - Lecture 14, 19 May Advanced Topics in Object Technology Bertrand Meyer.
Chair of Software Engineering Concurrent Object-Oriented Programming Concurrent Object-Oriented Programming Bertrand Meyer, Piotr Nienaltowski.
Chair of Software Engineering Einführung in die Programmierung Introduction to Programming Prof. Dr. Bertrand Meyer Exercise Session 10.
Lecture a: Additional UML Models: Package, Activity, Deployment Lecture b: Generalization, Aggregation and Additional Domain Model Notation Copyright W.
Chair of Software Engineering Concurrent Object-Oriented Programming Prof. Dr. Bertrand Meyer Lecture 2: an overview of SCOOP.
SE-565 Software System Requirements More UML Diagrams.
Subclasses and Subtypes CMPS Subclasses and Subtypes A class is a subclass if it has been built using inheritance. ▫ It says nothing about the meaning.
Data Structures Data structures permit the storage of related data for use in your program. –Arrays.
More with Methods (parameters, reference vs. value, array processing) Corresponds with Chapters 5 and 6.
Semaphores, Locks and Monitors By Samah Ibrahim And Dena Missak.
1 Concurrency Architecture Types Tasks Synchronization –Semaphores –Monitors –Message Passing Concurrency in Ada Java Threads.
Automated Software Engineering with Concurrent Class Machines Radu Grosu SUNY at Stony Brook joint work with Y. Liu, S. Smolka, S.Stoller, J. Yan SUNY.
Data Structures (part 2). Stacks An Everyday Example Your boss keeps bringing you important items to deal with and keeps saying: “Put that last ‘rush’
Refactoring Deciding what to make a superclass or interface is difficult. Some of these refactorings are helpful. Some research items include Inheritance.
Denis Caromel1 Institut universitaire de France (IUF) INRIA Sophia-Antipolis – CNRS – I3S – Université de Nice Luis Mateu DCC – Universidad de Chile Eric.
ICS 313: Programming Language Theory Chapter 13: Concurrency.
SOFTWARE DESIGN. INTRODUCTION There are 3 distinct types of activities in design 1.External design 2.Architectural design 3.Detailed design Architectural.
Protocols Software Engineering II Wirfs Brock et al, Designing Object-Oriented Software, Prentice Hall, Mitchell, R., and McKim, Design by Contract,
Testing OO software. State Based Testing State machine: implementation-independent specification (model) of the dynamic behaviour of the system State:
ISP RAS Java Specification Extension for Automated Test Development Igor B. Bourdonov, Alexei V. Demakov, Andrei A. Jarov, Alexander S. Kossatchev, Victor.
13-1 Chapter 13 Concurrency Topics Introduction Introduction to Subprogram-Level Concurrency Semaphores Monitors Message Passing Java Threads C# Threads.
Banaras Hindu University. A Course on Software Reuse by Design Patterns and Frameworks.
Conditional statements and boolean expressions Arithmetic, relational and logical operators.
CE Operating Systems Lecture 8 Process Scheduling continued and an introduction to process synchronisation.
Concurrency/synchronization using UML state models November 27th, 2007 Michigan State University.
Sections 3.4 Formal Specification
Design by Contract Jim Fawcett CSE784 – Software Studio
Design by Contract Jim Fawcett CSE784 – Software Studio
Simple Concurrent Object-Oriented Programming
Concurrency/synchronization using UML state models
Inheritance Anomalies
Thread Synchronization
Queues: Implemented using Arrays
Software Design Lecture : 14.
Stack A data structure in which elements are inserted and removed only at one end (called the top). Enforces Last-In-First-Out (LIFO) Uses of Stacks Evaluating.
Circular Queues: Implemented using Arrays
Software Design Lecture : 39.
CHAPTER 3: Collections—Stacks
Presentation transcript:

Chair of Software Engineering 1 Concurrent Object-Oriented Programming Arnaud Bailly, Bertrand Meyer and Volkan Arslan

Chair of Software Engineering 2 Lecture 5: Inheritance Anomaly.

Chair of Software Engineering 3 In a Sequential World…  A class is an implementation pattern.  One is interested in functional behavior.  A type contains operation signatures for a class.  Objects offer uniform services.

Chair of Software Engineering 4 In a Concurrent World…  Classes are still implementation patterns.  One is interested in interactive behavior:  the sequence of requests sent to an object,  the sequence of requests sent by an object.  A type is a state machine.  Objects offer naturally non-uniform services.

Chair of Software Engineering 5 Inheritance and Subtyping  Class B inherits ( ) from Class A.  Instances a of A, b of B.  Re-usability of classes is substitution:  B subtype ( ) of A meaning  any object c can use b as if it were a.  Generally, in a sequential world:  B inherits from A implies B subtype of A.  B subtype of A implies B inherits from A.  This really not true in the concurrent world!

Chair of Software Engineering 6 Inheritance Anomaly  Incremental inheritance ( ):  without redefining features of A.  Inheritance anomaly:  Depends on the notion of type and on the inheritance mechanism.

Chair of Software Engineering 7 First Example  Live routine as in POOL.  Queue2 with a deq2() method taking 2 elements.  Queue2 is a subtype of Queue1!  Queue2 has to redefine BODY. CLASS Queue1… BODY DO IF empty THEN ANSWER(enq) ELSIF full THEN ANSWER(deq) ELSE ANSWER ANY FI OD YDOB CLASS Queue2… BODY DO IF empty THEN ANSWER (enq) IF one THEN ANSWER (deq) ELSIF full THEN ANSWER (deq, deq2) ELSE ANSWER ANY FI OD YDOB

Chair of Software Engineering 8 Other Notations with Similar Problem  When synchronization is:  interwoven (monitors, delay queues), or  isolated but not separable (path expressions).  Can be further studied:  Behavior abstractions,  Enable sets,  Method guards.

Chair of Software Engineering 9 Behavior Abstractions: The Good class BUFFER_LAST inherits BUFFER is public interface: … // added method Last behavior: empty_= renames empty; partial_= {put, get, last}redefines partial; full_= {get, last}redefines full; implementation: Boolean isFull, isEmpty; put (t: OBJECT) is … // INHERITED, NOT MODIFIED if (isFull) then become full; else become partial; end;... OBJECT: last () is … // returns the bottom of the stack if (isEmpty) then become empty_; else become partial_; end; end BBUFFER;

Chair of Software Engineering 10 Behavior Abstractions: The Not-So-Good class BUFFER2 inherits BUFFER is public interface: … // as before behavior: empty_= renames empty; one_= {put, get} partial_= {put, get, get2}redefines partial; full_= {get, get2}redefines full; implementation: Boolean isOne; // added to isEmpty, isFull put (t: OBJECT) is … if (isFull) then become full_; if isOne then become one_; else become partial_; end;... // similar redefinition is necessary for get(). Couple: get2 () is … // returns the two elements on top if (isEmpty) then become empty_; if isOne then become one_ else become partial_; end; end BBUFFER;

Chair of Software Engineering 11 The previous anomaly… is usually called: the Partition Refinement Anomaly.

Chair of Software Engineering 12 Method Guards: The Good class BBUFFER is public interface: … // as before guards: put: !isFull() get: !isEmpty() implementation: int in, out, buf[size]; Boolean isFull() is in = out + size end; Boolean isEmpty() is in = out end; BBUFFER (s: int) is size = s end; put (t: OBJECT) is … in := in + 1; end; OBJECT get is … out := out + 1; end; end BBUFFER; class BBUFFER2 inherits BBUFFER is … guards: get2: plusOne() implementation: Boolean plusOne is in >= out + 2; end; Couple get2() is … in := in + 2; end; end;

Chair of Software Engineering 13 Method Guards: The Not-So-Good (1) class GGET_BUFFER inherits BBUFFER is … guards: gget: (afterPut = false and not isEmpty()) implementation: Boolean afterPut := false; Object gget() is … out := out + 1; afterPut := false; end; // both put and get need re-definition!! put(t: Object) is … in := in + 1; afterPut := true end; Object get() is … in := in + 1; afterPut := false end; end;  Method gget() may execute only after method get().  This is called history-only sensitiveness.  The guards are not re-defined but the bodies are.

Chair of Software Engineering 14 Method Guards: The Not-So-Good (2) class LOCKER is … guards: lock: (not locked) unlock: (locked) implementation: Boolean locked := false; lock() is locked := true; end; unlock() is locked := false; end; end; class LOCKED_BUF inherits BBUFFER, LOCKER is … guards: // need to redefine all the guards from BBUFFER!! put: (not locked and not isFull()) get: (not locked and not isEmpty()) implementation: … // nothing changes… end;

Chair of Software Engineering 15 The previous anomaly… is usually called: the Modification of Acceptable States.

Chair of Software Engineering 16 Other Remedies  Either:  Based on reflective mechanisms, or  Based on automatic parallelization.  Isolate the code completely.  Try to reduce (suppress) its total amount.  When code is left, still poor on separability.  Example: Enable Sets.

Chair of Software Engineering 17 References  Matsuoka and Yonezawa, Analysis of Inheritance Anomaly in OOCP, in Gul Agha, Peter Wegner, Akinori Yonezawa (Editors): Research Directions in Concurrent Object-Oriented Programming. MIT Press,  Lobel Crnogorac, Anand S. Rao, Kotagiri Ramamohanarao: Classifying Inheritance Mechanisms in Concurrent Object Oriented Programming. ECOOP 1998, LNCS  Cosimo Laneve, Inheritance for Concurrent Objects, in Howard Bowman and John Derrick (Editors): Formal methods for distributed processing: a survey of object-oriented approaches. Cambridge University Press, 2001.

Chair of Software Engineering 18 Next  Formal models and logics for concurrency.