SCOOP: Simple Concurrent Object-Oriented Programming Piotr Nienaltowski, Volkan Arslan, Bertrand...

24
SCOOP: Simple Concurrent Object- Oriented Programming Piotr Nienaltowski, Volkan Arslan, Bertrand Meyer presented by: Mark Schall
  • date post

    21-Dec-2015
  • Category

    Documents

  • view

    218
  • download

    0

Transcript of SCOOP: Simple Concurrent Object-Oriented Programming Piotr Nienaltowski, Volkan Arslan, Bertrand...

Page 1: SCOOP: Simple Concurrent Object-Oriented Programming Piotr Nienaltowski, Volkan Arslan, Bertrand Meyer presented by: Mark Schall.

SCOOP: Simple Concurrent Object-Oriented Programming

Piotr Nienaltowski, Volkan Arslan, Bertrand Meyer

presented by: Mark Schall

Page 2: SCOOP: Simple Concurrent Object-Oriented Programming Piotr Nienaltowski, Volkan Arslan, Bertrand Meyer presented by: Mark Schall.

The Problem

“What is the simplest, smallest and most convincing extension to the method of systematic object-oriented software construction that can address the needs of concurrent and distributed computing as well as those of sequential computation?” – Bertrand Meyer

Page 3: SCOOP: Simple Concurrent Object-Oriented Programming Piotr Nienaltowski, Volkan Arslan, Bertrand Meyer presented by: Mark Schall.

SCOOP Model

• High-level concurrency mechanism• Based on Design by Contract• Full use of inheritance• Applicable to many physical setups:

multiprocessing, multithreading, distributed execution

Page 4: SCOOP: Simple Concurrent Object-Oriented Programming Piotr Nienaltowski, Volkan Arslan, Bertrand Meyer presented by: Mark Schall.

Brief History

• First published in 1993 by Bertrand Meyer• Designed as extension to Eiffel• First prototype was implemented in 1995

Page 5: SCOOP: Simple Concurrent Object-Oriented Programming Piotr Nienaltowski, Volkan Arslan, Bertrand Meyer presented by: Mark Schall.

Architecture

• Top Layer:– platform independent

• Bottom Layer:– language/platform specific

Page 6: SCOOP: Simple Concurrent Object-Oriented Programming Piotr Nienaltowski, Volkan Arslan, Bertrand Meyer presented by: Mark Schall.

Bottom Layer

• Eiffel:– Added single new keyword separate

• .NET– Add two new classes to be inherited:• SEPARATE_CLIENT• SEPARATE_SUPPLIER

Page 7: SCOOP: Simple Concurrent Object-Oriented Programming Piotr Nienaltowski, Volkan Arslan, Bertrand Meyer presented by: Mark Schall.

Separate Calls

• Keyword separate declares if an object should be handled on the same processor or not

SOME_ROUTINE( x: separate CLASS ) isdo

x.f()end

…x: separate CLASScreate x.makeb.SOME_ROUTINE(x)

x.f() will be handled on a different processor then the call b.SOME_ROUTINE(x)

Page 8: SCOOP: Simple Concurrent Object-Oriented Programming Piotr Nienaltowski, Volkan Arslan, Bertrand Meyer presented by: Mark Schall.

Client and Supplier

Object b (Client)

Processor 1

Object x (Supplier)

Processor 2

SOME_ROUTINE(x)

x.f()

f() is do

… end

Page 9: SCOOP: Simple Concurrent Object-Oriented Programming Piotr Nienaltowski, Volkan Arslan, Bertrand Meyer presented by: Mark Schall.

Processors

• Not just mean physical CPU• Threads• Processes• Computers in a distributed system• Application Domain

Page 10: SCOOP: Simple Concurrent Object-Oriented Programming Piotr Nienaltowski, Volkan Arslan, Bertrand Meyer presented by: Mark Schall.

Access control policy• Separate calls are valid if the target of the call is an

argument of the enclosing routine

SOME_ROUTINE( x: separate CLASS ) isdo

x.f()end

…a: separate CLASScreate a.makeSOME_ROUTINE(a) -- instead of a.f()

Page 11: SCOOP: Simple Concurrent Object-Oriented Programming Piotr Nienaltowski, Volkan Arslan, Bertrand Meyer presented by: Mark Schall.

Basic Access Control Policy Example

Processor 1

while( !lock(a) )wait( a )

SOME_ROUTINE(a)a.f()release(a)

Processor 2

f() isdo

…end

Page 12: SCOOP: Simple Concurrent Object-Oriented Programming Piotr Nienaltowski, Volkan Arslan, Bertrand Meyer presented by: Mark Schall.

Access control policy• Using Design by Contractstore(buffer: separate BUFFER; value: INTEGER) is

require -- preconditionbuffer_not_full: not buffer.is_full

dobuffer.put(value)

ensure -- postconditionbuffer_not_empty: not buffer.is_empty

end…buf: separate BUFFERstore(buf, 20)

Page 13: SCOOP: Simple Concurrent Object-Oriented Programming Piotr Nienaltowski, Volkan Arslan, Bertrand Meyer presented by: Mark Schall.

Wait by necessity

• Client Objects– do not need to wait for feature calls of a supplier

in order to call another feature call– must wait on query calls for all previous calls to

finish on the same supplier

Page 14: SCOOP: Simple Concurrent Object-Oriented Programming Piotr Nienaltowski, Volkan Arslan, Bertrand Meyer presented by: Mark Schall.

Examplesome_feature( x, y, z: separate CLASS ) is

dox.fy.fx.gz.fy.gv := x.is_empty -- wait for x.f and x.gv := x.value > y.value -- wait for y.f and y.g

end

Page 15: SCOOP: Simple Concurrent Object-Oriented Programming Piotr Nienaltowski, Volkan Arslan, Bertrand Meyer presented by: Mark Schall.

Producer/Consumer ExampleProduceAndConsume( p: separate PRODUCER, c: separate CONSUMER ) is

doc.consume_n(5);p.produce_n(5);

end…buf: separate BUFFERconsumer: separate CONSUMERproducer: separate PRODUCERcreate c.make(buf)create p.make(buf)ProduceAndConsume(producer, consumer)

Page 16: SCOOP: Simple Concurrent Object-Oriented Programming Piotr Nienaltowski, Volkan Arslan, Bertrand Meyer presented by: Mark Schall.

Producerproduce_n (n: INTEGER) is

localvalue: INTEGERi: INTEGER

dofrom i := 1until i > nloop

value := random_gen.next

store (buf, value)i := i + 1

endend

end -- class PRODUCER

store (buffer: separate BUFFER [INTEGER];value: INTEGER) isrequire

buffer_not_full: not buffer.is_fullvalue_provided: value /= Void

dobuffer.put (value)

end

Page 17: SCOOP: Simple Concurrent Object-Oriented Programming Piotr Nienaltowski, Volkan Arslan, Bertrand Meyer presented by: Mark Schall.

Consumerconsume_n (n: INTEGER) is

locali: INTEGER

dofrom i := 1

until i > nloop

consume_one (buf)

i := i + 1end

end

consume_one (buffer: separateBUFFER [INTEGER]) isrequirebuffer_specified: buffer /= Voidbuffer_not_empty: not buffer.is_emptydovalue := buffer.itembuffer.removeend

Page 18: SCOOP: Simple Concurrent Object-Oriented Programming Piotr Nienaltowski, Volkan Arslan, Bertrand Meyer presented by: Mark Schall.

Producer/Consumer ExampleProduceAndConsume( p: separate PRODUCER, c: separate CONSUMER ) is

doc.consume_n(5);p.produce_n(5);

end…buf: separate BUFFERconsumer: separate CONSUMERproducer: separate PRODUCERcreate c.make(buf)create p.make(buf)ProduceAndConsume(producer, consumer)

Page 19: SCOOP: Simple Concurrent Object-Oriented Programming Piotr Nienaltowski, Volkan Arslan, Bertrand Meyer presented by: Mark Schall.

Reusing old software

• Support for inheritance allows for reuse of non-concurrent software

• May only require a simple wrapper classseparate class BUFFER

inherit QUEUEend

Page 20: SCOOP: Simple Concurrent Object-Oriented Programming Piotr Nienaltowski, Volkan Arslan, Bertrand Meyer presented by: Mark Schall.

Distributed Computing

• Processors can be Computers in the network• Concurrency Control File– maps processors to physical addresses• machines• processes• etc.

• Can take advantage of .NET Remoting library

Page 21: SCOOP: Simple Concurrent Object-Oriented Programming Piotr Nienaltowski, Volkan Arslan, Bertrand Meyer presented by: Mark Schall.

Distributed Computing

Home Desktoppacific.cse.msu.edu

arctic.cse.msu.edu

Processor 1Processor 3

Processor 2

Processor 4

Processor 5

o1

o2

o3

o4

o5

o6

LANInternet

Page 22: SCOOP: Simple Concurrent Object-Oriented Programming Piotr Nienaltowski, Volkan Arslan, Bertrand Meyer presented by: Mark Schall.

Duels• An attempt to grab a shared object from the

current holder• Holder– retain (default)– yield

• Challenger– wait_turn (default)– demand– insist

• Exceptions interrupt either the Holder or Challenger to settle the Duel

Page 23: SCOOP: Simple Concurrent Object-Oriented Programming Piotr Nienaltowski, Volkan Arslan, Bertrand Meyer presented by: Mark Schall.

Future Work

• Real-time programming– Priority mechanisms– Timeout controls

• Deadlock Avoidance

Page 24: SCOOP: Simple Concurrent Object-Oriented Programming Piotr Nienaltowski, Volkan Arslan, Bertrand Meyer presented by: Mark Schall.

Future Work

• RECOOP – Reliable and Efficient Concurrent Object-Oriented Programs

• Microsoft’s Safe and Scalable Multicore Computing RFP

• Continuation of SCOOP• Developing a practical formal semantics and

proof mechanism