Schall Scoop

Embed Size (px)

Citation preview

  • 8/14/2019 Schall Scoop

    1/24

    SCOOP: Simple Concurrent

    Object-OrientedProgrammingPiotr Nienaltowski, Volkan

    Arslan, Bertrand Meyer

    presented by: Mark Schall

  • 8/14/2019 Schall Scoop

    2/24

    The Problem

    What is the simplest, smallest andmost convincing extension to themethod of systematic object-orientedsoftware construction that canaddress the needs of concurrent anddistributed computing as well as

    those of sequential computation? Bertrand Meyer

  • 8/14/2019 Schall Scoop

    3/24

    SCOOP Model

    High-level concurrency mechanism

    Based on Design by Contract

    Full use of inheritance Applicable to many physical setups:

    multiprocessing, multithreading,

    distributed execution

  • 8/14/2019 Schall Scoop

    4/24

    Brief History

    First published in 1993 by BertrandMeyer

    Designed as extension to Eiffel First prototype was implemented in

    1995

  • 8/14/2019 Schall Scoop

    5/24

    Architecture

    Top Layer:

    platform independent

    Bottom Layer: language/platform specific

  • 8/14/2019 Schall Scoop

    6/24

    Bottom Layer

    Eiffel:

    Added single new keyword separate

    .NET Add two new classes to be inherited:

    SEPARATE_CLIENT

    SEPARATE_SUPPLIER

  • 8/14/2019 Schall Scoop

    7/24

    Separate Calls

    Keyword separatedeclares if anobject should be handled on thesame processoror not

    SOME_ROUTINE( x: separateCLASS ) isdo

    x.f()end

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

    x.f() will be handledon a different

    processor then thecallb.SOME_ROUTINE(x)

  • 8/14/2019 Schall Scoop

    8/24

    Client and Supplier

    Object b(Client)

    Processor 1

    Object x (Supplier)

    Processor 2

    SOME_ROUTINE(x)

    x.f()

    f() is

    do

    end

  • 8/14/2019 Schall Scoop

    9/24

    Processors

    Not just mean physical CPU

    Threads

    Processes Computers in a distributed system

    Application Domain

  • 8/14/2019 Schall Scoop

    10/24

    Access control policy

    Separate calls are valid if the target of the call isan argument of the enclosing routine

    SOME_ROUTINE( x: separate CLASS ) is

    dox.f()end

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

  • 8/14/2019 Schall Scoop

    11/24

    Basic Access Control PolicyExample

    Processor 1

    while( !lock(a) )

    wait( a )

    SOME_ROUTINE(a)

    a.f()release(a)

    Processor 2

    f() isdo

    end

  • 8/14/2019 Schall Scoop

    12/24

    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

    endbuf: separate BUFFERstore(buf, 20)

  • 8/14/2019 Schall Scoop

    13/24

    Wait by necessity

    Client Objects

    do not need to wait for feature calls of asupplier in order to call another feature

    call must wait on query calls for all previous

    calls to finish on the same supplier

  • 8/14/2019 Schall Scoop

    14/24

    Example

    some_feature( x, y, z: separate CLASS ) isdox.fy.fx.gz.fy.gv := x.is_empty -- wait for x.f and x.g

    v := x.value > y.value -- wait for y.f and y.gend

  • 8/14/2019 Schall Scoop

    15/24

    Producer/ConsumerExample

    ProduceAndConsume( p: separate PRODUCER, c: separateCONSUMER ) isdoc.consume_n(5);p.produce_n(5);

    endbuf: separate BUFFERconsumer: separate CONSUMERproducer: separate PRODUCER

    create c.make(buf)create p.make(buf)ProduceAndConsume(producer, consumer)

  • 8/14/2019 Schall Scoop

    16/24

    Producer

    produce_n (n: INTEGER) islocal

    value: INTEGERi: INTEGER

    do

    from i := 1until i > nloop

    value :=random_gen.next

    store (buf, value)

    i := i + 1endend

    end -- class PRODUCER

    store (buffer: separate BUFFER [INTEGvalue: INTEGER) isrequire

    buffer_not_full: not buffer.is_fulvalue_provided: value /= Void

    dobuffer.put (value)

    end

  • 8/14/2019 Schall Scoop

    17/24

    Consumer

    consume_n (n: INTEGER) islocali: INTEGERdo

    from i := 1until i > n

    loopconsume_one (buf)

    i := i + 1endend

    consume_one (buffer:separateBUFFER [INTEGER]) isrequire

    buffer_specified: buffer /=Voidbuffer_not_empty: notbuffer.is_emptydo

    value := buffer.itembuffer.removeend

  • 8/14/2019 Schall Scoop

    18/24

    Producer/ConsumerExample

    ProduceAndConsume( p: separate PRODUCER, c: separateCONSUMER ) isdoc.consume_n(5);p.produce_n(5);

    endbuf: separate BUFFERconsumer: separate CONSUMERproducer: separate PRODUCER

    create c.make(buf)create p.make(buf)ProduceAndConsume(producer, consumer)

  • 8/14/2019 Schall Scoop

    19/24

    Reusing old software

    Support for inheritance allows forreuse of non-concurrent software

    May only require a simple wrapperclass

    separate class BUFFER

    inherit QUEUEend

  • 8/14/2019 Schall Scoop

    20/24

    Distributed Computing

    Processors can be Computers in thenetwork

    Concurrency Control File

    maps processors to physical addresses machines

    processes

    etc.

    Can take advantage of .NET Remotinglibrary

  • 8/14/2019 Schall Scoop

    21/24

    Distributed Computing

    Home Desktoppacific.cse.msu.edu

    arctic.cse.msu.eduProcessor 1

    Processor 3

    Processor 2

    Processor 4

    Processor 5

    o

    1

    o2

    o3

    o4

    o

    5

    o6

    LANInternet

  • 8/14/2019 Schall Scoop

    22/24

    Duels

    An attempt to grab a shared objectfrom the current holder

    Holder retain (default) yield

    Challenger wait_turn (default)

    demand insist

    Exceptions interrupt either the Holderor Challenger to settle the Duel

  • 8/14/2019 Schall Scoop

    23/24

    Future Work

    Real-time programming

    Priority mechanisms

    Timeout controls

    Deadlock Avoidance

  • 8/14/2019 Schall Scoop

    24/24

    Future Work

    RECOOP Reliable and EfficientConcurrent Object-OrientedPrograms

    Microsofts Safe and ScalableMulticore Computing RFP

    Continuation of SCOOP

    Developing a practical formalsemantics and proof mechanism