Chair of Software Engineering SCOOP: an introduction Bertrand Meyer Chair of Software Engineering, ETH Zurich, Switzerland

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

Chair of Software Engineering Concurrent Object-Oriented Programming Prof. Dr. Bertrand Meyer Lecture 10: Advanced Object-Oriented Mechanisms (based on.
2 nd Microsoft Rotor Workshop, Pisa, April 23-25, SCOOPLI for.NET: a library for concurrent object-oriented programming Volkan Arslan, Piotr Nienaltowski.
SCOOP on.NET Volkan Arslan Chair of Software Engineering ETH Zurich, Switzerland
Chapter 6: Process Synchronization
CMSC 330: Organization of Programming Languages Threads Classic Concurrency Problems.
CS 5704 Fall 00 1 Monitors in Java Model and Examples.
Kevin Doyle With Jenna Lau, Jonathan Ostroff and Faraz Ahmadi Torshizi. Department of Computer Science and Engineering, York University, 4700 Keele Street,
Chair of Software Engineering Concurrent Object-Oriented Programming Prof. Dr. Bertrand Meyer Lecture 7: SCOOP Type System (based on work with Piotr Nienaltowski)
Chair of Software Engineering PPoPP 2003, , San Diego SCOOP it up! Piotr Nienaltowski Chair of Software Engineering, ETH Zurich, Switzerland.
1 Concurrency Specification. 2 Outline 4 Issues in concurrent systems 4 Programming language support for concurrency 4 Concurrency analysis - A specification.
1 Software Architecture Bertrand Meyer ETH Zurich, March-May 2009 Lecture 15: Designing for concurrency & real-time.
Computer Systems/Operating Systems - Class 8
Chair of Software Engineering OOSC - Summer Semester Object-Oriented Software Construction Bertrand Meyer.
Multithreading The objectives of this chapter are:
Chair of Software Engineering OOSC Lecture 20 - Concurrency Object-Oriented Software Construction Bertrand Meyer.
Chair of Software Engineering Piotr Nienaltowski, SCOOP Simple Concurrent Object-Oriented Programming.
Chair of Software Engineering OOSC - Summer Semester Object-Oriented Software Construction Bertrand Meyer.
Chair of Software Engineering Piotr Nienaltowski, , Concurrent Object-Oriented Programming Bertrand Meyer, Piotr Nienaltowski.
Chair of Software Engineering Piotr Nienaltowski, , Concurrent Object-Oriented Programming Bertrand Meyer, Piotr Nienaltowski.
OS Fall ’ 02 Introduction Operating Systems Fall 2002.
Chair of Software Engineering SCOOP for ROTOR Bertrand Meyer Capstone (ROTOR final workshop), 2005 © Bertrand Meyer, 2005.
Chair of Software Engineering ATOT - Lecture 26, 30 June Advanced Topics in Object Technology Bertrand Meyer.
CS220 Software Development Lecture: Multi-threading A. O’Riordan, 2009.
3.5 Interprocess Communication Many operating systems provide mechanisms for interprocess communication (IPC) –Processes must communicate with one another.
3.5 Interprocess Communication
SCOOP: Simple Concurrent Object-Oriented Programming Piotr Nienaltowski, Volkan Arslan, Bertrand Meyer presented by: Mark Schall.
Chair of Software Engineering ATOT - Lecture 25, 30 June Advanced Topics in Object Technology Bertrand Meyer.
Chair of Software Engineering Concurrent Object-Oriented Programming Prof. Dr. Bertrand Meyer Lecture 9: Contracts and Inheritance (based on work with.
Multithreading in Java Nelson Padua-Perez Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
1 Organization of Programming Languages-Cheng (Fall 2004) Concurrency u A PROCESS or THREAD:is a potentially-active execution context. Classic von Neumann.
Chair of Software Engineering Concurrent Object-Oriented Programming Prof. Dr. Bertrand Meyer Lecture 6:Computational Model (based on work with Piotr Nienaltowski)
Chair of Software Engineering Concurrent Object-Oriented Programming Prof. Dr. Bertrand Meyer Lecture 2: an overview of SCOOP.
Chair of Software EngineeringPiotr Nienaltowski, 2 nd SCOOP workshop, SCOOP update and proposed extensions Piotr Nienaltowski.
Chair of Software EngineeringOOSC – Summer Semester 2005 Object-Oriented Software Construction Bertrand Meyer Lecture 19: SCOOP Simple Concurrent Object-Oriented.
Chair of Software Engineering ATOT - Lecture 21, 16 June 2003 Advanced Topics in Object Technology Bertrand Meyer.
Fundamentals of Python: From First Programs Through Data Structures
What is Concurrent Programming? Maram Bani Younes.
Operating System A program that controls the execution of application programs An interface between applications and hardware 1.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 2: System Structures.
Object-Oriented Implementation of Reconciliations M.Sc. Seminar Talk by Costa Shapiro under supervision of Prof. Shmuel Katz Computer Science – Technion.
Threads in Java. History  Process is a program in execution  Has stack/heap memory  Has a program counter  Multiuser operating systems since the sixties.
Multi-Threaded Application CSNB534 Asma Shakil. Overview Software applications employ a strategy called multi- threaded programming to split tasks into.
Multithreading in Java Project of COCS 513 By Wei Li December, 2000.
Java Threads 11 Threading and Concurrent Programming in Java Introduction and Definitions D.W. Denbo Introduction and Definitions D.W. Denbo.
111 © 2002, Cisco Systems, Inc. All rights reserved.
 2004 Deitel & Associates, Inc. All rights reserved. 1 Chapter 4 – Thread Concepts Outline 4.1 Introduction 4.2Definition of Thread 4.3Motivation for.
1 Web Based Programming Section 8 James King 12 August 2003.
ABSTRACT The real world is concurrent. Several things may happen at the same time. Computer systems must increasingly contend with concurrent applications.
Contracts for Concurrency - Contracts & Inheritance Aryabrata Basu University of Georgia.
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.
Java Thread and Memory Model
SPL/2010 Guarded Methods and Waiting 1. SPL/2010 Reminder! ● Concurrency problem: asynchronous modifications to object states lead to failure of thread.
13-1 Chapter 13 Concurrency Topics Introduction Introduction to Subprogram-Level Concurrency Semaphores Monitors Message Passing Java Threads C# Threads.
Threads and Singleton. Threads  The JVM allows multiple “threads of execution”  Essentially separate programs running concurrently in one memory space.
Thread A thread represents an independent module of an application that can be concurrently execution With other modules of the application. MULTITHREADING.
Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition Chapter 5: Process Synchronization.
Concurrent Programming in Java Based on Notes by J. Johns (based on Java in a Nutshell, Learning Java) Also Java Tutorial, Concurrent Programming in Java.
Chapter 4 – Thread Concepts
SCOOPLI for .NET: a library for concurrent object-oriented programming
Topics Covered What is Real Time Operating System (RTOS)
Simple Concurrent Object-Oriented Programming
Outline Other synchronization primitives
Chapter 4 – Thread Concepts
Threads, Concurrency, and Parallelism
Concurrency Specification
Multithreading.
Multithreading.
Presentation transcript:

Chair of Software Engineering SCOOP: an introduction Bertrand Meyer Chair of Software Engineering, ETH Zurich, Switzerland

Chair of Software Engineering Why SCOOP?  Extend object technology with general and powerful concurrency support  Provide the industry with simple techniques for parallel, distributed, internet, real-time programming  Make programmers sleep better!

Chair of Software Engineering The SCOOP model  Simple Concurrent Object-Oriented Programming  High-level concurrency mechanism  Fully uses inheritance and other O-O techniques  Applicable to many physical setups: multiprocessing, multithreading, distributed execution, Web services...  Based on Design by Contract and Eiffel concepts

Chair of Software Engineering Object-oriented computation To perform a computation is  to use certain processors  to apply certain actions  to certain objects. Processor ActionsObjects

Chair of Software Engineering What makes an application concurrent? Processor: autonomous thread of control supporting sequential execution of instructions on one or more objects Can be implemented as:  Process  Thread  AppDomain (.NET)  Web service Processor ActionsObjects

Chair of Software Engineering Feature call: synchronous x: CLASS_X... x.f (a) Object 1Object 2 (CLASS_T)(CLASS_X) previous_instruction x. f ( a ) next_instruction Processor f (a: A) require a /= Void ensure not a.empty

Chair of Software Engineering Separate feature call (asynchronous) x: separate CLASS_X... x.f (a) (CLASS_T)(CLASS_X) Processor 1 Processor 2 Object 1Object 2 previous_instruction x. f ( a ) next_instruction f (a: A) require a /= Void ensure not a.empty

Chair of Software Engineering Access control policy Target of separate call must be formal argument of enclosing routine: store (buffer: separate BUFFER [INTEGER]; value: INTEGER) is -- Store value into buffer. do buffer.put (value) end Call with separate argument gives exclusive access: store (my_buffer, 10)

Chair of Software Engineering Contracts in Eiffel store (buffer: BUFFER [INTEGER]; value: INTEGER) is -- Store value into buffer. require not buffer.is_full value > 0 do buffer.put (value) ensure not buffer.is_empty end... store (my_buffer, 10)  If b is separate, precondition becomes wait condition (instead of correctness condition) Precondition

Chair of Software Engineering From preconditions to wait-conditions store (buffer: separate BUFFER [INTEGER]; value: INTEGER) is -- Store value into buffer. require not buffer.is_full value > 0 do buffer.put (value) ensure not buffer.is_empty end... store (my_buffer, 10)  If buffer is separate,. On separate target, precondition becomes wait condition

Chair of Software Engineering Wait by necessity  No special mechanism for client to resynchronize with supplier after separate call.  The client will wait only when it needs to: x.f x.g (a) y.f … value := x.some_query Wait here!

Chair of Software Engineering Duels Problem: Impatient client (challenger) wants to snatch object from another client (holder)  Can’t just interrupt holder, service challenger, and resume holder: would produce inconsistent object.  But: can cause exception, which will be handled safely.

Chair of Software Engineering Challenger → ↓ Holder normal_serviceimmediate_service retain Challenger waitsException in challenger yield Challenger waitsException in holder; serve challenger Duels

Chair of Software Engineering Mapping processors to physical resources Concurrency Control File (CCF) create system "lincoln" (4): "c:\prog\appl1\appl1.exe" "roosevelt" (2): "c:\prog\appl2\appl2.dll" "Current" (5): "c:\prog\appl3\appl3.dll" end external Database_handler: "jefferson" port 9000 ATM_handler: "gates" port 8001 end default port: 8001; instance: 10 end

Chair of Software Engineering Two-level architecture of SCOOP  Can be implemented on various platforms  Microsoft.NET is our reference platform SCOOP platform-independent.NET Compact Framework POSIX Threads …

Chair of Software Engineering SCOOPLI: Library for SCOOP  Library-based solution  Implemented in Eiffel for.NET (from Eiffel Software: EiffelStudio / ENViSioN! for Visual Studio.NET)  Aim: try out solutions without bothering with compiler issues  Can serve as a basis for compiler implementations

Chair of Software Engineering  separate client  separate supplier Each separate client & separate supplier handled by different processor Class gets separateness through multiple inheritance: SEPARATE_ SUPPLIER X SEPARATE_X SCOOPLI concepts

Chair of Software Engineering SCOOPLI emulation of SCOOP concepts SCOOPSCOOPLI x: separate X x: X -- class X is separate x: SEPARATE_X -- SEPARATE_X inherits from X and -- SEPARATE_SUPPLIER r (x, y) -- x and y are separate r (x: separate X; y: separate Y) is require not x.is_empty y.count > 5 i > 0 -- i non-separate x /= Void do... end separate_execute ([x, y], agent r (x, y), agent r_precondition) r_precondition: BOOLEAN is do Result := not x.is_empty and y.count > 5 end -- client class inherits from -- class SEPARATE_CLIENT

Chair of Software Engineering SCOOPLI Architecture  SEPARATE_HANDLER: locking; checking wait conditions; scheduling of requests  PROCESSOR_HANDLERs: execute separate calls; implement processors

Chair of Software Engineering Example: Dining philosophers class PHILOSOPHER inherit PROCESS rename setup as getup redefine step end feature {BUTLER} step is do think ; eat (left, right) end eat (l, r: separate FORK) is -- Eat, having grabbed l and r. do … end end

Chair of Software Engineering Example: Bounded buffer usage Usage of bounded buffers buff: BUFFER_ACCESS [MESSAGE] my_buffer: BOUNDED_BUFFER [MESSAGE] create my_buffer create buff.make (my_buffer) buff.put (my_buffer, my_message) … buff.put (my_buffer, her_message) … my_query := buff.item (my_buffer)

Chair of Software Engineering Example: elevator For maximal concurrency, all objects are separate Inheritance Client

Chair of Software Engineering Dynamic diagram CABIN_BUTTONELEVATOR ENGINE Scenario: Pressing the cabin button to move the elevator Cabin button calls elevator.accept (target) 2 Elevator calls engine.move (floor) 3 Engine calls gui_main_window.move_elevator (cabin_number, floor) 4 Engine calls elevator.record_stop (position) GUI_MAIN_WINDOW 3 asynchronous call synchronous call

Chair of Software Engineering Class BUTTON separate class BUTTON feature target: INTEGER end

Chair of Software Engineering Class CABIN_BUTTON separate class CABIN_BUTTON inherit BUTTON feature cabin: ELEVATOR request is -- Send to associated elevator a request to stop on level target. do actual_request (cabin) end actual_request (e: ELEVATOR) is -- Get hold of e and send a request to stop on level target. do e.accept (target) end

Chair of Software Engineering Class ELEVATOR separate class ELEVATOR feature {BUTTON, DISPATCHER} accept (floor: INTEGER) is -- Record and process a request to go to floor. do record (floor) if not moving then process_request end end feature {MOTOR} record_stop (floor: INTEGER) is -- Record information that elevator has stopped on floor. do moving := False ; position := floor ; process_request end

Chair of Software Engineering Class ELEVATOR feature {NONE} -- Implementation process_request is -- Handle next pending request, if any. local floor: INTEGER do if not pending.is_empty then floor := pending.item ; actual_process (puller, floor) pending.remove end actual_process (m: MOTOR; floor: INTEGER) is -- Handle next pending request, if any. do moving := true ; m.move (floor) end feature {NONE} -- Implementation puller: MOTOR ; pending: QUEUE [INTEGER] end

Chair of Software Engineering Class MOTOR separate class MOTOR feature {ELEVATOR} move (floor: INTEGER) is -- Go to floor; once there, report. do gui_main_window.move_elevator (cabin_number, floor) signal_stopped (cabin) end signal_stopped (e: ELEVATOR) is -- Report that elevator e stopped on level position. do e.record_stop (position) end feature {NONE} cabin: ELEVATOR ; position: INTEGER -- Current floor level. gui_main_window: GUI_MAIN_WINDOW end

Chair of Software Engineering Distributed execution  Processors (AppDomains) located on different machines .NET takes care of the "dirty work"  Marshalling  Minimal cost of inter-AppDomain calls Computer1 AppDomain1 o1 o2 Computer2 AppDomain2 o3 o9 Computer3 AppDomain3 o4 o5 AppDomain4 o6 o7 o8 o9.f o1.g o6.f (o3) o8.g o4.f

Chair of Software Engineering Conclusions  SCOOP model  Simple yet powerful  Easier and safer than common concurrent techniques, e.g. Java Threads  Full concurrency support  Full use O-O and Design by Contract  Supports various platforms and concurrency architectures  One new keyword: separate  SCOOPLI library  SCOOP-based syntax  Implemented on.NET  Distributed execution with.NET Remoting

Chair of Software Engineering Current work  Prevent deadlock  Statically checkable rules  Run-time deadlock avoidance  Extend access control policy  Multiple locking of separate objects  Extend for real-time  Duel mechanism with priorities  Timing assertions?  Integrate with Eiffel Software compiler  Direct support for processors in the CLI?