architectural building blocks for plug-and-play system design · architectural building blocks for...

77
Architectural Building Blocks for Plug-and-Play System Design Shangzhu Wang, George S. Avrunin, Lori A. Clarke Department of Computer Science University of Massachusetts Amherst {shangzhu,avrunin,clarke}@cs.umass.edu

Upload: others

Post on 25-Jun-2020

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Architectural Building Blocks for Plug-and-Play System Design · Architectural Building Blocks for Plug-and-Play System Design Shangzhu Wang, George S. Avrunin, Lori A. Clarke Department

Architectural Building Blocks forPlug-and-Play System Design

Shangzhu Wang, George S. Avrunin,Lori A. Clarke

Department of Computer ScienceUniversity of Massachusetts Amherst

{shangzhu,avrunin,clarke}@cs.umass.edu

Page 2: Architectural Building Blocks for Plug-and-Play System Design · Architectural Building Blocks for Plug-and-Play System Design Shangzhu Wang, George S. Avrunin, Lori A. Clarke Department

The Problem

Developing concurrent and distributedsystems is difficult and costly Unpredictable behaviors due to

interleavings between parallel components

Page 3: Architectural Building Blocks for Plug-and-Play System Design · Architectural Building Blocks for Plug-and-Play System Design Shangzhu Wang, George S. Avrunin, Lori A. Clarke Department

Component Interactions Represent synchronizations and

communications between components

Large design space of alternative semantics A wide range of interaction mechanisms (e.g. RPC, MP,

EBN) and their variations Choosing appropriate interaction semantics for a system

can be challenging

Important yet hard to get right

Semantics of interactions intertwined withcomponents’ computations

Changes in the interaction semantics often requirechanges in the components, limiting the reusability ofcomponents

Page 4: Architectural Building Blocks for Plug-and-Play System Design · Architectural Building Blocks for Plug-and-Play System Design Shangzhu Wang, George S. Avrunin, Lori A. Clarke Department

State of the Practice/Art Connectors represent component interactions

Finite-state verification can be used to evaluatethe correctness of design Provides early feedback about the appropriateness of

the choices of interaction semantics

ADLs are often restricted in the kinds of interactionsemantics they support

Component designs tend to include some aspects ofthe semantics of interactions

But extremely costly when frequent changes are madeto the design

Page 5: Architectural Building Blocks for Plug-and-Play System Design · Architectural Building Blocks for Plug-and-Play System Design Shangzhu Wang, George S. Avrunin, Lori A. Clarke Department

An Illustrative Example

Page 6: Architectural Building Blocks for Plug-and-Play System Design · Architectural Building Blocks for Plug-and-Play System Design Shangzhu Wang, George S. Avrunin, Lori A. Clarke Department

The Single-lane Bridge Example

Controller Controller

EnterRequestExitRequest

Page 7: Architectural Building Blocks for Plug-and-Play System Design · Architectural Building Blocks for Plug-and-Play System Design Shangzhu Wang, George S. Avrunin, Lori A. Clarke Department

Design of the Single-lane Bridge Example– (exactly-N-cars-per-turn)

BlueController RedController

BlueCar RedCar

Component Connector

Blue_Enter Red_Exit Blue_Exit Red_Enter

Oops!

Page 8: Architectural Building Blocks for Plug-and-Play System Design · Architectural Building Blocks for Plug-and-Play System Design Shangzhu Wang, George S. Avrunin, Lori A. Clarke Department

Design of the Single-lane Bridge Example– (exactly-N-cars-per-turn)

RedController

BlueCar RedCar

Blue_Enter Red_Exit Blue_Exit Red_Enter

send enterRequest;enter the bridge;

BlueController Oops!

Page 9: Architectural Building Blocks for Plug-and-Play System Design · Architectural Building Blocks for Plug-and-Play System Design Shangzhu Wang, George S. Avrunin, Lori A. Clarke Department

Design of the Single-lane Bridge Example– (exactly-N-cars-per-turn)

RedController

BlueCar RedCar

Blue_Enter Red_Exit Blue_Exit Red_Enter

send enterRequest;receive ack;enter the bridge

BlueController Oops!

Page 10: Architectural Building Blocks for Plug-and-Play System Design · Architectural Building Blocks for Plug-and-Play System Design Shangzhu Wang, George S. Avrunin, Lori A. Clarke Department

Design of the Single-lane Bridge Example– (exactly-N-cars-per-turn)

RedController

BlueCar RedCar

Blue_Enter Red_Exit Blue_Exit Red_Enter

BlueControllerreceive enterRequest;if safe send ack;

Page 11: Architectural Building Blocks for Plug-and-Play System Design · Architectural Building Blocks for Plug-and-Play System Design Shangzhu Wang, George S. Avrunin, Lori A. Clarke Department

Design of the Single-lane Bridge Example– (exactly-N-cars-per-turn)

RedController

BlueCar RedCar

Blue_Enter Red_Exit Blue_Exit Red_Enter

BlueController

Page 12: Architectural Building Blocks for Plug-and-Play System Design · Architectural Building Blocks for Plug-and-Play System Design Shangzhu Wang, George S. Avrunin, Lori A. Clarke Department

Design of the Single-lane Bridge Example– (exactly-N-cars-per-turn)

RedController

BlueCar RedCar

Blue_Enter Red_Exit Blue_Exit Red_Enter

BlueController

Safe! But…

Page 13: Architectural Building Blocks for Plug-and-Play System Design · Architectural Building Blocks for Plug-and-Play System Design Shangzhu Wang, George S. Avrunin, Lori A. Clarke Department

Design of the Single-lane Bridge Example– (exactly-N-cars-per-turn)

RedController

BlueCar RedCar

Blue_Enter Red_Exit Blue_Exit Red_Enter

BlueController

Deadlock!!

insufficient buffering

Page 14: Architectural Building Blocks for Plug-and-Play System Design · Architectural Building Blocks for Plug-and-Play System Design Shangzhu Wang, George S. Avrunin, Lori A. Clarke Department

Design of the Single-lane Bridge Example– (exactly-N-cars-per-turn)

RedController

BlueCar RedCar

Blue_Enter Red_Exit Blue_Exit Red_Enter

BlueController

Deadlock!!

insufficient buffering

if buffer is not full send exitRequest

Page 15: Architectural Building Blocks for Plug-and-Play System Design · Architectural Building Blocks for Plug-and-Play System Design Shangzhu Wang, George S. Avrunin, Lori A. Clarke Department

Design of the Single-lane Bridge Example– (exactly-N-cars-per-turn)

RedController

BlueCar RedCar

Blue_Enter Red_Exit Blue_Exit Red_Enter

BlueController

if buffer is not full send exitRequest

insufficient buffering

Deadlock!!

Page 16: Architectural Building Blocks for Plug-and-Play System Design · Architectural Building Blocks for Plug-and-Play System Design Shangzhu Wang, George S. Avrunin, Lori A. Clarke Department

Design of the Single-lane Bridge Example– (exactly-N-cars-per-turn)

RedController

BlueCar RedCar

Blue_Enter Red_Exit Blue_Exit Red_Enter

BlueController

No crash !Deadlock free !

Page 17: Architectural Building Blocks for Plug-and-Play System Design · Architectural Building Blocks for Plug-and-Play System Design Shangzhu Wang, George S. Avrunin, Lori A. Clarke Department

What is Needed

Architectural support to Minimize the impact on the components when

connectors are changed Allow easy experimentation with alternative design

choices of interaction semantics Increase the reusability of both components and

connectors Reduce the cost of frequently re-computing models for

finite-state verification

Page 18: Architectural Building Blocks for Plug-and-Play System Design · Architectural Building Blocks for Plug-and-Play System Design Shangzhu Wang, George S. Avrunin, Lori A. Clarke Department

Outline of Our Approach Support plug-and-play system design

Define a small set of standard interfaces fordifferent component interactions

Define a library of building blocks for theconstruction of connectors with differentinteraction semantics

Facilitate design-time verification Increase reusability of component models Build connector models by composing reusable

models of building blocks

Page 19: Architectural Building Blocks for Plug-and-Play System Design · Architectural Building Blocks for Plug-and-Play System Design Shangzhu Wang, George S. Avrunin, Lori A. Clarke Department

Standard Interfaces forComponent Interactions

Only a small set of interfaces are needed Define the standard protocols between

components and connectors

The same interface can be used with manydifferent interaction semantics Connectors can be modified or replaced without

changing the components Components are more likely to be reused when

the design of interactions is changed

Page 20: Architectural Building Blocks for Plug-and-Play System Design · Architectural Building Blocks for Plug-and-Play System Design Shangzhu Wang, George S. Avrunin, Lori A. Clarke Department

A Library of Building Blocks

Connectors are decomposed into channelsand ports Composable and reusable Channels represent the communication media of

connectors Ports are mediators between components and

channels capture different synchronization semantics of

connectors important for supporting the standard component

interfaces

Page 21: Architectural Building Blocks for Plug-and-Play System Design · Architectural Building Blocks for Plug-and-Play System Design Shangzhu Wang, George S. Avrunin, Lori A. Clarke Department

Protocols Between Building Blocks A message passing example

Asynchronous Nonblocking Send

component channelsend port

m

m

BufferStatus = “inOk”/ “inFail”

RecvStatus= “sendOk”

“recvOk”

m

Page 22: Architectural Building Blocks for Plug-and-Play System Design · Architectural Building Blocks for Plug-and-Play System Design Shangzhu Wang, George S. Avrunin, Lori A. Clarke Department

RecvStatus= “sendOk”

component channelsend port

m

mBufferStatus = “inOk”

m

Protocols Between Building Blocks A message passing example

Synchronous Blocking Send

“recvOk”

Page 23: Architectural Building Blocks for Plug-and-Play System Design · Architectural Building Blocks for Plug-and-Play System Design Shangzhu Wang, George S. Avrunin, Lori A. Clarke Department

msc Asynchronous Nonblocking Send

component channelsend port

m

m

BufferStatus = “inOk”/ “inFail”

RecvStatus= “sendOk”

m

“recvOk”

msc Synchronous Blocking Send

component channelsend port

m

mBufferStatus = “inOk”

“recvOk”

m

RecvStatus= “sendOk”

Protocols Between Building Blocks A message passing example

Page 24: Architectural Building Blocks for Plug-and-Play System Design · Architectural Building Blocks for Plug-and-Play System Design Shangzhu Wang, George S. Avrunin, Lori A. Clarke Department

Examples of Message PassingBuilding Blocks

Priority queue

FIFO queueChannelsSingle-slot buffer

Nonblocking remove

Nonblocking copy

Blocking removeReceive Ports

Blocking copy

Synchronous checking

Synchronous blocking

Asynchronous checkingSend PortsAsynchronous blocking

Asynchronous nonblocking

Page 25: Architectural Building Blocks for Plug-and-Play System Design · Architectural Building Blocks for Plug-and-Play System Design Shangzhu Wang, George S. Avrunin, Lori A. Clarke Department

Sender Receiver

Plug and Play with Message Passing

MP

Synchronous blocking send & nonblocking receive

Nonblockingreceive port

FIFO queue

Synchronousblocking send port

Sendinterface

Receiveinterface

Library of Message Passing Building blocks

Page 26: Architectural Building Blocks for Plug-and-Play System Design · Architectural Building Blocks for Plug-and-Play System Design Shangzhu Wang, George S. Avrunin, Lori A. Clarke Department

The Single-lane Bridge Example – (exactly-N-cars-per-turn)

Controller Controller

Page 27: Architectural Building Blocks for Plug-and-Play System Design · Architectural Building Blocks for Plug-and-Play System Design Shangzhu Wang, George S. Avrunin, Lori A. Clarke Department

The Single-lane Bridge Example – (exactly-N-cars-per-turn)

RedController

RedCar

BlueController

BlueCar

Red_Exit

Single-slot

AsynNbSend

BlRecv

Blue_Exit

AsynNbSend

Single-slot BlRecv

Blue_Enter

FIFO

AsynBlSend

FIFO

AsynBlSend

Red_Enter

Oops!

Page 28: Architectural Building Blocks for Plug-and-Play System Design · Architectural Building Blocks for Plug-and-Play System Design Shangzhu Wang, George S. Avrunin, Lori A. Clarke Department

The Single-lane Bridge Example – (exactly-N-cars-per-turn)

RedController

RedCar

Blue_Enter Red_Exit Blue_Exit Red_Enter

BlueController

BlueCar

AsynNbSend

FIFO FIFOSingle-slot Single-slot

AsynNbSend

BlRecv BlRecv

AsynBlSendAsynBlSend

Oops!

Page 29: Architectural Building Blocks for Plug-and-Play System Design · Architectural Building Blocks for Plug-and-Play System Design Shangzhu Wang, George S. Avrunin, Lori A. Clarke Department

SynBlSendSynBlSend

The Single-lane Bridge Example – (exactly-N-cars-per-turn)

RedController

RedCar

Blue_Enter Red_Exit Blue_Exit Red_Enter

BlueController

BlueCar

AsynNbSend

FIFO FIFOSingle-slot Single-slot

AsynNbSend

BlRecv BlRecv

Oops!

Page 30: Architectural Building Blocks for Plug-and-Play System Design · Architectural Building Blocks for Plug-and-Play System Design Shangzhu Wang, George S. Avrunin, Lori A. Clarke Department

SynBlSendSynBlSend

The Single-lane Bridge Example – (exactly-N-cars-per-turn)

RedController

RedCar

Blue_Enter Red_Exit Blue_Exit Red_Enter

BlueController

BlueCar

AsynNbSend

FIFO FIFOSingle-slot Single-slot

AsynNbSend

BlRecv BlRecv

Deadlock!!

Page 31: Architectural Building Blocks for Plug-and-Play System Design · Architectural Building Blocks for Plug-and-Play System Design Shangzhu Wang, George S. Avrunin, Lori A. Clarke Department

SynBlSendSynBlSend

The Single-lane Bridge Example – (exactly-N-cars-per-turn)

RedController

RedCar

Blue_Enter Red_Exit Blue_Exit Red_Enter

BlueController

BlueCar

AsynBlSend

FIFO FIFOSingle-slot Single-slot

AsynBlSend

BlRecv BlRecv

Deadlock!!

Page 32: Architectural Building Blocks for Plug-and-Play System Design · Architectural Building Blocks for Plug-and-Play System Design Shangzhu Wang, George S. Avrunin, Lori A. Clarke Department

A More Efficient Single-lane Bridge– (at-most-N-cars-per-turn)

Page 33: Architectural Building Blocks for Plug-and-Play System Design · Architectural Building Blocks for Plug-and-Play System Design Shangzhu Wang, George S. Avrunin, Lori A. Clarke Department

Red_Blue

Blue_Red

A More Efficient Single-lane Bridge

RedController

RedCar

Blue_Enter Red_Exit Blue_Exit Red_Enter

BlueController

BlueCar

SynBlSendAsynBlSend

FIFO FIFOSingle-slot Single-slot

SynBlSend AsynBlSend

BlRecv BlRecv

– (at-most-N-cars-per-turn)

NbRecv NbRecv

Page 34: Architectural Building Blocks for Plug-and-Play System Design · Architectural Building Blocks for Plug-and-Play System Design Shangzhu Wang, George S. Avrunin, Lori A. Clarke Department

Summary Support plug-and-play design of component-

based systems A small set of standard component interfaces that

minimize the impact of changes to connectors oncomponents

A library of pre-defined building blocks for theconstruction of a variety of different connectors

Allows easy experimentation with alternative designchoices of interaction semantics

Facilitate design-time verification Increase the reusability of both components and

connectors Save model-construction time when verification needs

to be repeated

Page 35: Architectural Building Blocks for Plug-and-Play System Design · Architectural Building Blocks for Plug-and-Play System Design Shangzhu Wang, George S. Avrunin, Lori A. Clarke Department

Summary (cont’d) Applied to message passing

Interfaces and protocols designed Building blocks defined and models constructed in

Promela Example systems evaluated using SPIN

Not tied to particular modeling languages or verification tools

Developing more building blocks to supportother interaction mechanisms RPC, Publish/Subscribe Can reuse many of the message passing building

blocks

Page 36: Architectural Building Blocks for Plug-and-Play System Design · Architectural Building Blocks for Plug-and-Play System Design Shangzhu Wang, George S. Avrunin, Lori A. Clarke Department

Related Work Modeling connectors for verification, e.g.,

Wright (Allen et al. ’97) AIDS (Ray et al. ’03) Constraint Automata (Arbab et al. ’04) Model checking pub-sub systems (Garlan et al. ’03) Compositional approach (Caporuscio et al. ’04)

Architecture evolution, e.g., Medvidovic et al. ’99, van der Hoek et al. ’01

Ports, e.g., ACME (Garlan et al. ’97), ArchJava (Aldrich et al. ’02)

Mediators, wrappers, adaptable components, e.g., Sullivan et al. ’92, Spitznagel et al. ’03, , Heineman ’98

Page 37: Architectural Building Blocks for Plug-and-Play System Design · Architectural Building Blocks for Plug-and-Play System Design Shangzhu Wang, George S. Avrunin, Lori A. Clarke Department

Ongoing & Future Work Support for additional interaction semantics

Provide a shared library of building blocks for different interactionmechanisms

Define a systematic way to create and define arbitrary buildingblocks

Tools to support our approach Implementing extensions to AcmeStudio (Garlan, et al.) Hierarchical building blocks, pre-built connectors Integrating design-time verification, provides guidance for fixing

problems More substantial case studies

To evaluate applicability, scalability, etc. Optimizations for finite-state verification

To reduce composed models

Page 38: Architectural Building Blocks for Plug-and-Play System Design · Architectural Building Blocks for Plug-and-Play System Design Shangzhu Wang, George S. Avrunin, Lori A. Clarke Department

Thank you!

Questions?

Page 39: Architectural Building Blocks for Plug-and-Play System Design · Architectural Building Blocks for Plug-and-Play System Design Shangzhu Wang, George S. Avrunin, Lori A. Clarke Department
Page 40: Architectural Building Blocks for Plug-and-Play System Design · Architectural Building Blocks for Plug-and-Play System Design Shangzhu Wang, George S. Avrunin, Lori A. Clarke Department

The Single-lane Bridge Example

Controller Controller

Page 41: Architectural Building Blocks for Plug-and-Play System Design · Architectural Building Blocks for Plug-and-Play System Design Shangzhu Wang, George S. Avrunin, Lori A. Clarke Department

The Single-lane Bridge Example Plug-and-play design using the pre-defined message

passing building blocks Connectors are described by composing a selective subset of

the message passing building blocks Allows easy experimentation with alternative choices of

message passing semantics Evaluate the system design using SPIN/Promela

Check properties: Is the system deadlock free? Is the bridge “safe”?

Our approach increases the reuse of the formal modelswhen designs need to be changed due to property violationsor major functional requirements changes

Page 42: Architectural Building Blocks for Plug-and-Play System Design · Architectural Building Blocks for Plug-and-Play System Design Shangzhu Wang, George S. Avrunin, Lori A. Clarke Department

msc Blocking receive

component channelreceive port

RecvRequest

“outOk”

m

RecvStatus = “recvSucc”

RecvRequest

m

msc Nonblocking receive

component channelreceive port

RecvRequest

“outOk”RecvStatus = “recvSucc”

RecvRequest

m

“outFail”RecvStatus = “recvFail”

Null

Protocols Between Building Blocks A message passing example

Page 43: Architectural Building Blocks for Plug-and-Play System Design · Architectural Building Blocks for Plug-and-Play System Design Shangzhu Wang, George S. Avrunin, Lori A. Clarke Department

Design-time Verification Finite-state verification

Check important specification properties of a system Based on searching the state space of a finite-state model of

a system for paths leading to the violation of the property E.g. SPIN, SMV, FLAVERS

Predefined and reusable formal models are createdfor the library of building blocks Connector models are composed from the predefined

building block models Not tied to any particular verification tools or modeling

languages Reduce the need of re-constructing component

models when only connectors are changed

Page 44: Architectural Building Blocks for Plug-and-Play System Design · Architectural Building Blocks for Plug-and-Play System Design Shangzhu Wang, George S. Avrunin, Lori A. Clarke Department

The Single-lane Bridge Problem(with emergency vehicles)

RedController

RedCar

Blue_Enter Red_Exit Blue_Exit Red_Enter

BlueController

BlueCar

connector

component

sendPorts

recvPorts

Red_Blue

Blue_RedFIFO FIFO

RedEmergencyBlueEmergency

AsynBlSend

NbRecv

SynBlSend

NbRecv

AsynBlSend SynBlSend

Page 45: Architectural Building Blocks for Plug-and-Play System Design · Architectural Building Blocks for Plug-and-Play System Design Shangzhu Wang, George S. Avrunin, Lori A. Clarke Department

The Single-lane Bridge Example(with emergency vehicles)

RedController

RedCar

Red_Exit Blue_Exit

BlueController

BlueCar

connector

component

sendPorts

recvPorts

Red_Blue

Blue_Red

Priority Priority

RedEmergencyBlueEmergency

AsynBlSend

NbRecv

SynBlSend

NbRecv

AsynBlSend SynBlSend

Red_Blue_Em

Blue_Red_Em

Red_EnterBlue_Enter

NbCopy NbCopy

Page 46: Architectural Building Blocks for Plug-and-Play System Design · Architectural Building Blocks for Plug-and-Play System Design Shangzhu Wang, George S. Avrunin, Lori A. Clarke Department
Page 47: Architectural Building Blocks for Plug-and-Play System Design · Architectural Building Blocks for Plug-and-Play System Design Shangzhu Wang, George S. Avrunin, Lori A. Clarke Department

Notes

Refer details to the paper in the talk Refer verification-specific details to the

tech report

Page 48: Architectural Building Blocks for Plug-and-Play System Design · Architectural Building Blocks for Plug-and-Play System Design Shangzhu Wang, George S. Avrunin, Lori A. Clarke Department

Related workInteraction Paradigms Paradigms for process interaction in distributed programs

[’91 Andrews] Paradigms for multithreaded, parallel, and distributed

programming, e.g. [’00 Andrews] Message Passing Interface (MPI) Etc.

Middleware Polylith [’94 Purtillo, et al.] CORBA COM Enterprise Java Beans Mediators [’94 Sullivan] etc.

Page 49: Architectural Building Blocks for Plug-and-Play System Design · Architectural Building Blocks for Plug-and-Play System Design Shangzhu Wang, George S. Avrunin, Lori A. Clarke Department

Related workComponent-based ADLs Darwin [’97 Magee,et al.]

UniCon [’96 Shaw, et al.]

Wright [’97 Allen and Garlan]

ACME [’97 Garlan, et al.] A comparison framework for ADLs

[’00 Medvidovic, et al] etc.

Page 50: Architectural Building Blocks for Plug-and-Play System Design · Architectural Building Blocks for Plug-and-Play System Design Shangzhu Wang, George S. Avrunin, Lori A. Clarke Department

Related work

Formalizing interactions and connections A formal basis for architectural connection

[’97 Allen and Garlan] Composable semantics [’02 Niu, et al.] Compositional connector wrappers

[’03 Spitznagel and Garlan] etc.

Page 51: Architectural Building Blocks for Plug-and-Play System Design · Architectural Building Blocks for Plug-and-Play System Design Shangzhu Wang, George S. Avrunin, Lori A. Clarke Department

Related workApply finite state verification to component

interactions Model checking pub-sub system [’03 Garlan, et al.] Invariant-based verification of synchronization

[’02 Deng, et al.] Deadlock detection in distributed object systems

[’01 Kaveh and Emmerich] Modeling, specifying and verifying message passing

systems [’01 Bollig, et al.] Applying Static Analysis to Software Architectures [’97

Naumovich, et al.] etc.

Page 52: Architectural Building Blocks for Plug-and-Play System Design · Architectural Building Blocks for Plug-and-Play System Design Shangzhu Wang, George S. Avrunin, Lori A. Clarke Department
Page 53: Architectural Building Blocks for Plug-and-Play System Design · Architectural Building Blocks for Plug-and-Play System Design Shangzhu Wang, George S. Avrunin, Lori A. Clarke Department

The Promela Model of Ports

proctype AsynNbSendPort(SynChan component; SynChan

connector){

MsgBody data;end: do :: connector.c?_,eval(_pid) :: atomic{ component.d?data; component.c!sendOk,_pid; data.sendPort_pid = _pid; connector.d!data } od}

proctype AsynBlSendPort(SynChan component; SynChan connector){MsgBody data;end: do :: connector.c?_,eval(_pid); :: atomic{ component.d?data; data.sendPort_pid = _pid; do :: connector.d!data; if :: connector.c?connInOk,eval(_pid); break :: connector.c?connInFail,eval(_pid) fi od; component.c!sendOk,_pid } od}

Page 54: Architectural Building Blocks for Plug-and-Play System Design · Architectural Building Blocks for Plug-and-Play System Design Shangzhu Wang, George S. Avrunin, Lori A. Clarke Department

The Promela Model of Ports

proctype SynBlSendPort(SynChan component; SynChan

connector){MsgBody data;end: do :: atomic{ component.d?data;

data.sendPort_pid = _pid; do :: connector.d!data; if ::

connector.c?connInOk,eval(_pid); break ::

connector.c?connInFail,eval(_pid) fi od; connector.c?recvOk,eval(_pid); component.c!sendOk,_pid } od }

proctype SynNbSendPort(SynChan component; SynChan connector){

end: do :: atomic{ component.d?data; data.sendPort_pid = _pid; connector.d!data; if :: connector.c?connInOk,eval(_pid); connector.c?recvOk,eval(_pid) :: connector.c?connInFail,eval(_pid) fi; component.c!sendOk,_pid } od}

Page 55: Architectural Building Blocks for Plug-and-Play System Design · Architectural Building Blocks for Plug-and-Play System Design Shangzhu Wang, George S. Avrunin, Lori A. Clarke Department

The Promela Model of Ports

proctype NsBlRecvPort(SynChan component; SynChan

connector){

MsgBody data;end: do :: component.c?recvRequest,_; do :: connector.c!outRequest,_; if :: connector.d?data -> component.c!recvSucc ,_pid; component.d!data; break :: connector.c?connOutFail,0 fi od od}

proctype NsNbRecvPort(SynChan component; SynChan connector){

MsgBody data;end: do :: component.c?recvRequest,_; connector.c!outRequest,_; if :: connector.c?connOutFail,0 -> component.c!recvFail,_pid; component.d!data :: connector.d?data -> component.c!recvSucc; component.d!data fi od}

Page 56: Architectural Building Blocks for Plug-and-Play System Design · Architectural Building Blocks for Plug-and-Play System Design Shangzhu Wang, George S. Avrunin, Lori A. Clarke Department

FIFO Queue in Promelaproctype FIFO_queue(SynChan sender; SynChan

receiver){ chan buffer = [BUFFER_SIZE] of {MsgBody}; xs buffer; MsgBody data;

do :: atomic{ sender.d?data; if :: full(buffer) -> sender.c!connInFail,data.sendPort_pid :: nfull(buffer) -> buffer!data; sender.c!connInOk,data.sendPort_pid fi }

:: atomic{ receiver.c?outRequest; if :: empty(buffer) -> receiver.c!connOutFail :: nempty(buffer) -> buffer?data; receiver.d!data; sender.c!recvOk,data.sendPort_pid } :: atomic{ receiver.c?outRequest; if :: empty(buffer) -> receiver.c!connOutFail :: nempty(buffer) -> buffer?<data>; receiver.d!data} od }

Page 57: Architectural Building Blocks for Plug-and-Play System Design · Architectural Building Blocks for Plug-and-Play System Design Shangzhu Wang, George S. Avrunin, Lori A. Clarke Department

Notes

Page 58: Architectural Building Blocks for Plug-and-Play System Design · Architectural Building Blocks for Plug-and-Play System Design Shangzhu Wang, George S. Avrunin, Lori A. Clarke Department

Basic Assumptions for Connectors Sends connInOk when the message is successfully

buffered; sends connInFail when it fails to buffer themessage (e.g. when the buffer is full) leaves to the sendPort to decide what to do with these

feedbacks

Sends connOutFail when the requested message is notavailable; otherwise directly delivers the message to therecvPort

Always sends recvOk to the corresponding sendPort whena message is delivered to a recvPort Although the sendPort may not care

Page 59: Architectural Building Blocks for Plug-and-Play System Design · Architectural Building Blocks for Plug-and-Play System Design Shangzhu Wang, George S. Avrunin, Lori A. Clarke Department

Subtlety of the semantics of connectors(notes)

When my buffer is full,

Do not accept the sending of messages to me

Works with blocking send, but not nonblocking send

Accept the sending of messages, but hold the newly receivedmessage which will be eventually put into the buffer (retry by theconnector)

has a cache that holds up to 1 message, what happens if there aremore waiting

The blocking semantics could also be implemented using “retry by thesend port”

Accept the sending but just drops the message (lossy), in this case,do I send connInfail?

Does not work with blocking send

Page 60: Architectural Building Blocks for Plug-and-Play System Design · Architectural Building Blocks for Plug-and-Play System Design Shangzhu Wang, George S. Avrunin, Lori A. Clarke Department

Example Variations ofMessage Passing Semantics

Synchronous ~ Asynchronous A synchronous sender sends a message and waits until it is

told that the message has been received An asynchronous sender sends a message and returns right

away regardless whether the message has been received

Blocking ~ Nonblocking ~ Checking Selective ~ Nonselective Copy ~ Remove Buffer type

Page 61: Architectural Building Blocks for Plug-and-Play System Design · Architectural Building Blocks for Plug-and-Play System Design Shangzhu Wang, George S. Avrunin, Lori A. Clarke Department

Example Variations ofMessage Passing Semantics

Synchronous ~ Asynchronous Blocking ~ Nonblocking ~ Checking

Blocking receive / nonblocking receive Blocking send / nonblocking send / checking send

Selective ~ Nonselective Copy ~ Remove Buffer type

Page 62: Architectural Building Blocks for Plug-and-Play System Design · Architectural Building Blocks for Plug-and-Play System Design Shangzhu Wang, George S. Avrunin, Lori A. Clarke Department

Example Variations ofMessage Passing Semantics

Synchronous ~ Asynchronous Blocking ~ Nonblocking Selective ~ Nonselective

A selective receiver could specify certain matching criteriafor retrieving messages

A nonselective receiver accepts any message it gets

Copy ~ Remove Buffer type

Page 63: Architectural Building Blocks for Plug-and-Play System Design · Architectural Building Blocks for Plug-and-Play System Design Shangzhu Wang, George S. Avrunin, Lori A. Clarke Department

Example Variations ofMessage Passing Semantics

Synchronous ~ Asynchronous Blocking ~ Nonblocking Selective ~ Nonselective Copy ~ Remove

A receiver may choose to copy a message or remove amessage from a buffer when it does a receive

Buffer type

Page 64: Architectural Building Blocks for Plug-and-Play System Design · Architectural Building Blocks for Plug-and-Play System Design Shangzhu Wang, George S. Avrunin, Lori A. Clarke Department

Example Variations ofMessage Passing Semantics

Synchronous ~ Asynchronous Blocking ~ Nonblocking ~ Checking Selective ~ Nonselective Copy ~ Remove Buffer type

Size, ordering (e.g. FIFO queue, priority queue) Reliable or lossy

Page 65: Architectural Building Blocks for Plug-and-Play System Design · Architectural Building Blocks for Plug-and-Play System Design Shangzhu Wang, George S. Avrunin, Lori A. Clarke Department

Connection Rules Components cannot interact with each other without

going though ports and channels A component can have more than one send or receive ports

Each port mediates between one component and onechannel

Each channel can have connections to more than oneport A channel cannot interact with a component directly

Currently assuming a static model

Page 66: Architectural Building Blocks for Plug-and-Play System Design · Architectural Building Blocks for Plug-and-Play System Design Shangzhu Wang, George S. Avrunin, Lori A. Clarke Department

Asynchronous Nonblocking Send msc Asynchronous Nonblocking Send

component channelsend port

m

m

“inOk” / “inFail”

RecvStatus= “sendOk”

m

“recvOk”

Page 67: Architectural Building Blocks for Plug-and-Play System Design · Architectural Building Blocks for Plug-and-Play System Design Shangzhu Wang, George S. Avrunin, Lori A. Clarke Department

Asynchronous Blocking Send msc Asynchronous Blocking Send

sender channelsend port

m

m

“inOk”

m

“recvOk”

RecvStatus= “sendOk”

Page 68: Architectural Building Blocks for Plug-and-Play System Design · Architectural Building Blocks for Plug-and-Play System Design Shangzhu Wang, George S. Avrunin, Lori A. Clarke Department

Synchronous Blocking Send msc Synchronous Blocking Send

sender channelsend port

m

m “inOk”

“sendOk”

“recvOk”

m

Page 69: Architectural Building Blocks for Plug-and-Play System Design · Architectural Building Blocks for Plug-and-Play System Design Shangzhu Wang, George S. Avrunin, Lori A. Clarke Department

Synchronous Nonblocking Send msc Synchronous Nonblocking Send

sender channelsend port

m

m “inOk” /“inFail”

m“recvOk”

SendStatus = “sendFail”

(if “inFail”)

(if “inOk”)

SendStatus = “sendOk”

Page 70: Architectural Building Blocks for Plug-and-Play System Design · Architectural Building Blocks for Plug-and-Play System Design Shangzhu Wang, George S. Avrunin, Lori A. Clarke Department

Blocking Receive

msc Blocking receive

receiver channelreceive port

RecvRequest

“outOk”

m

RecvStatus = “recvSucc”

RecvRequest

m

Page 71: Architectural Building Blocks for Plug-and-Play System Design · Architectural Building Blocks for Plug-and-Play System Design Shangzhu Wang, George S. Avrunin, Lori A. Clarke Department

Nonblocking Receive

msc Nonblocking receive

receiver channelreceive port

RecvRequest

“outOk”RecvStatus = “recvSucc”

RecvRequest

m

“outFail”RecvStatus = “recvFail”

Null

Page 72: Architectural Building Blocks for Plug-and-Play System Design · Architectural Building Blocks for Plug-and-Play System Design Shangzhu Wang, George S. Avrunin, Lori A. Clarke Department

The Single-lane Bridge Example Version 3: Emergency vehicles may enter the bridge

from either side Emergency vehicles have higher priorities to enter the bridge

Change Blue_Enter and Red_Enter to priority queues

When there is an emergency vehicle waiting , anEmergency_Stop message is sent so that the controller atthe other side can stop accepting cars onto the bridge andyields turns sooner

Introducing new connectors between two controllers fromemergency_stop signal

Using copy receive ports (instead of remove receive ports) tocheck if there is an emergency vehicle waiting

Page 73: Architectural Building Blocks for Plug-and-Play System Design · Architectural Building Blocks for Plug-and-Play System Design Shangzhu Wang, George S. Avrunin, Lori A. Clarke Department

The Single-lane Bridge Example Version 1: At each turn, exactly N cars from the

current direction can enter the bridge No communication is needed between two controllers

Version 2: At each turn, up to N cars from thecurrent direction can enter the bridge Turns can be yielded immediately if no more cars are

waiting before the total number reaches N Controllers need to use nonblocking receive instead of blocking

receive A controller has to notify the other controller of the actual

number of cars that have entered the bridge Introducing new connectors between two controllers Introducing new ports for controllers

Page 74: Architectural Building Blocks for Plug-and-Play System Design · Architectural Building Blocks for Plug-and-Play System Design Shangzhu Wang, George S. Avrunin, Lori A. Clarke Department

C1

C2

C5 C4

C3

Standard Component Interfaces – The first step to “plug-and-play”

Publish/subscribeRPC

Componentinterfaces

Page 75: Architectural Building Blocks for Plug-and-Play System Design · Architectural Building Blocks for Plug-and-Play System Design Shangzhu Wang, George S. Avrunin, Lori A. Clarke Department

C1

C2

C5 C4

C3

Standard Component Interfaces – The first step to “plug-and-play”

Message passingRPC

A different interaction mechanism

Componentinterfaces

Page 76: Architectural Building Blocks for Plug-and-Play System Design · Architectural Building Blocks for Plug-and-Play System Design Shangzhu Wang, George S. Avrunin, Lori A. Clarke Department

C1

C2

C5 C4

C3

Standard Component Interfaces – The first step to “plug-and-play”

RPC

A variation of themessage passinginteraction mechanism

Message Passing

Componentinterfaces

Page 77: Architectural Building Blocks for Plug-and-Play System Design · Architectural Building Blocks for Plug-and-Play System Design Shangzhu Wang, George S. Avrunin, Lori A. Clarke Department

Ports and Channels

C1

C2

C5 C4

C3

RPC

MP

Componentinterfaces

Ports

Channel