Presentation is loading. Please wait.

Presentation is loading. Please wait.

Internal Talk, Oct 1 2002 Executable Specifications using Message Sequence Charts Abhik Roychoudhury School of Computing National University of Singapore.

Similar presentations


Presentation on theme: "Internal Talk, Oct 1 2002 Executable Specifications using Message Sequence Charts Abhik Roychoudhury School of Computing National University of Singapore."— Presentation transcript:

1 Internal Talk, Oct 1 2002 Executable Specifications using Message Sequence Charts Abhik Roychoudhury School of Computing National University of Singapore

2 Internal Talk, Oct 1 2002 MSCs – What Depict scenarios in system exection. Used to specify requirements in early stages of system design. A MSC depicts only a possible scenario of system behavior.

3 Internal Talk, Oct 1 2002 MSC - Visually req acknack addr val CPUmem CPU Mem MSC 1 MSC 2

4 Internal Talk, Oct 1 2002 Concurrency modeling Depicts concurrently executing processes (the vertical lines). Processes communicate via a explicit message passing (instead of shared variables). Realistic MSCs will also contain data attributes as part of the exchanged msg

5 Internal Talk, Oct 1 2002 Message Attributes req ack Addr(a) v := lookup(a) val(v) CPUMem

6 Internal Talk, Oct 1 2002 Internal Computations req ack Addr(a) v := lookup(a) val(v) CPUMem Internal Action

7 Internal Talk, Oct 1 2002 MSC – (Very) Basics Time flows from top to bottom in each process. Message exchange shown by horizontal lines. Each process in the MSC is assumed to contain message queues to store incoming messages. The message queues contribute to the global state of the system. If the data in messages come from a finite domain, then we identify a finite set of messages exchanged, called M.

8 Internal Talk, Oct 1 2002 MSC -formally P : set of processes M: set of messages A : set of internal actions E : set of events. Mapped to  P  P  M  P  A <, a partial order on events. We will consider the “Visual Order” for these purposes …

9 Internal Talk, Oct 1 2002 MSC order Intuitively, a “happens-before” relation between events. e < e’ if the MSC requires e to happen before e’ If e, e’ occur in the same process and e occurs above e’ then e < e’ If e, e’ are the send and receive of the same message then e < e’ These orderings constitute the visual order. Think of our partial order as the transitive closure of the visual order.

10 Internal Talk, Oct 1 2002 Combining MSCs Models a single scenario and states its possible execution in the system implementation. How could we use MSCs to model the behavior of a concurrent system ? One attempt is to describe the system behavior as a graph of MSCs. Each node of this graph is a MSC. We call such graphs as Message Sequence Graphs (MSG).

11 Internal Talk, Oct 1 2002 MSG - Visually req ack addr val nack M1 M2 M3

12 Internal Talk, Oct 1 2002 Choice and Concatenation Choice of scenarios at a certain point in system execution modeled by several outgoing branches M1  M2 and M1  M3 Concatenation of MSCs (by following the edges in the MSG) produces infinite execution traces. Client Server

13 Internal Talk, Oct 1 2002 More on concatenation Synchronous concatenation All processes synchronize at the end of each MSC (a node of the MSG) For any edge M1  M2 All events in M1 happen before all events in M2 Costly to implement since the natural control flow in a process is disrupted by the termination of a MSC (requiring handshake with other processes).

14 Internal Talk, Oct 1 2002 Synchronous concatenation s1 r1 s2 r2 s1 < r1 < s2 < r2

15 Internal Talk, Oct 1 2002 An alternative concentation Asynchronous concatenation If M1  M2 is an edge in the MSG, then concatenate M1 and M2 process by process If a process finishes its role in M1 ahead of others, it can start executing M2 Amenable to efficient distributed implementation.

16 Internal Talk, Oct 1 2002 Asynchronous concatenation s1 r1 s2 r2 s1 < r1 s2 < r2 s1 < s2 Is r1 < s2 ??

17 Internal Talk, Oct 1 2002 Unboundedness of queues p q Message queue of q can grow unboundedly. Model Checking will be applicable to only “Bounded MSGs”.

18 Internal Talk, Oct 1 2002 Hierarchical MSC (HMSC) Improves MSGs by incorporating hierarchy. A graph, each node of which is: a Message Sequence Chart, or a HMSC Clearly a MSG can appear as a node of HMSC. Different nodes in the graph can be labeled by the same HMSC The HMSC is like a subprogram which is invoked in various contexts.

19 Internal Talk, Oct 1 2002 HMSC example Th1CPU Th2 CPU-Mem MSG data Th1 CPU CPU-Mem MSG can be invoked in another context involving thread Th2.

20 Internal Talk, Oct 1 2002 MSG - Recap req ack addr val nack M1 M2 M3

21 Internal Talk, Oct 1 2002 Need for Universal Charts req ack addr val nack M1 M2 M3 Mem.busy  Mem.busy Mem CPU MemCPU Mem

22 Internal Talk, Oct 1 2002 A Universal chart CPU Mem nack 1. Mem.busy is the activation condition (AC) 2. If the AC holds, then this chart must be executed. 3. But the AC need not be true in every execution. Mem.busy

23 Internal Talk, Oct 1 2002 Semantics of universal charts A chart only constrains events and variables appearing in the chart. A system execution trace  = s 0  s 1  … satisfies a universal chart M iff  positions I s I l= AC(M)   I |= M, that is  I = s I s I+1 …. contains a linearization of the events in M Events not in M may appear in  I A system satisfies a universal chart M if all its execution traces satisfy M.

24 Internal Talk, Oct 1 2002 Pre-charts The trigger of a universal chart need simply be an activation condition. Can be an activation message: when it is received the chart is required to be activated. Can even be another full blown chart (a pre-chart). This chart can contain msg send/recv, conditions. Once the pre-chart is executed, the universal chart is required to follow.

25 Internal Talk, Oct 1 2002 Example of Pre-chart Mem.busy = true req CPU Mem nack Pre-chart Univ. chart Concatenation CPUMem

26 Internal Talk, Oct 1 2002 What kind of Concatenation ? Live Sequence Charts (LSC) [Damm and Harel] Synchronous concatenation The pre-chart/activation condition must be completely executed before the universal chart can initiate. Still allows for several active copies of pre(M).M e.g. pre(M) may be activated while M is still executing.

27 Internal Talk, Oct 1 2002 What kind of Concatenation ? Cyclic Transaction Processes (CTP) Universal charts triggered by activation conditions. Activation condition may involve variables of diff. processes. A process can initiate its role in the chart once the condition on its variables is evaluated to true. Other important differences with LSC formalism …

28 Internal Talk, Oct 1 2002 Distributed Activation Cond. pqr Reset(r.b) m1 m2 AC(M) = p.a  r.b r can start even when p has not started. …

29 Internal Talk, Oct 1 2002 Requirements or Exec. spec ? A universal chart denotes a safety property that the actual system must satisfy. Can be seen as a requirement with “must” flavor. Possible to enforce it on system executions by monitoring for the occurrence of its pre-chart. LSC spec. used for monitoring/testing/simulating an executable model early in the design cycle. How do we obtain a high-level executable specification directly based on MSCs ?

30 Internal Talk, Oct 1 2002 LSC-like executable specifications A collection of universal charts {M 1, …, M k } Each chart has activation condition AC( M i ) M i becomes active when AC(M i ) becomes true. Several charts may be active simultaneously. At any point in execution, no event occurs unless it is required to occur by the. Can use this executable model to check for inconsistencies in the LSC spec. itself !

31 Internal Talk, Oct 1 2002 Checking for inconsistencies m1 Pre-chart The two universal charts are inconsistent. a b b a

32 Internal Talk, Oct 1 2002 Control flow in LSC Intra-process control flow is completely implicit in an LSC based executable specification. Raises efficiency issues in implementation, since: Processes need to handshake at the end of a pre- chart. Need a global watchdog which always monitors for pre-charts of any Univ. chart being initiated. Can we make these decisions (initiation/termination of pre-charts) local to a process ?

33 Internal Talk, Oct 1 2002 Adding Per-process Control flow Describe the control flow in each process by giving the sequence of univ. charts it participates in Can start with a simple cyclic control flow (CTP) A process initiates a chart when its activation condition is true. A process leaves a chart when its role is finished. A transition in local control state s p  s p ’ in process p takes place by executing a universal chart.

34 Internal Talk, Oct 1 2002 Transaction scheme A transition s p  s p ’ in process p involves a non- trivial interaction of p with other processes q,r… Depending on the local variable values in p,q,r… the interaction may be different. Captured by a choice of universal charts G p  G q  Univ. Chart 1 G p ’  G q ’  Univ. Chart 2 This choice is not non-deterministic. Resolved at run- time by either of the guards being true.

35 Internal Talk, Oct 1 2002 References LSCs: Breathing Life into Message Sequence Charts Damm and Harel, Formal Methods in System Design, Vol. 19, pages 45-80, 2001. Model Checking of Message Sequence Charts Alur and Yannakakis, Proceedings of CONCUR, 1999. Communicating Transaction Processes, Roychoudhury and Thiagarajan, International Conf. on Applications of Concurrency in System Design (ACSD) 2003.


Download ppt "Internal Talk, Oct 1 2002 Executable Specifications using Message Sequence Charts Abhik Roychoudhury School of Computing National University of Singapore."

Similar presentations


Ads by Google