Synthesis of Message Sequence Charts from Communicating Finite-State Machines
Synthesizing a message sequence chart (MSC) from a communicating finite-state machine (CFSM), by transforming the CFSM to a Petri net model, generating a labeled finite digraph with each path representing a linearization of an occurrence net segment of the Petri net, decomposing the diagraph into segments, and mapping where each segment to a compositional MSC.
Latest Fujitsu Limited Patents:
- Ising machine data input apparatus and method of inputting data into an Ising machine
- Signal transmission method and apparatus, signal reception method and apparatus and communication system
- Ethics-based multi-modal user post monitoring
- Data transmission method and apparatus
- System information indication method and apparatus and communication system
1. Field
An example aspect of the invention relates to transformation of a state machine to a message sequence chart.
2. Description of the Related Art
The SPIN model checker specifies counter examples that it generates from model checking as a message sequence chart, however, this is restricted to only one possible behavior, and not a set of behaviors. Further, any message sequence chart that SPIN generates is not as a result of a behavior-preserving transformation from a finite state machine model. Further, reverse engineering tools, such as SUN ENTERPRISE STUDIO, only generate sequence diagrams from Java source and not controlled in number of processes.
SUMMARYMessage Sequence Charts (MSCs) and Communicating Finite-State Machines (CFSMs) are two popular formalisms used in the design of software, for example, telecommunications software systems. MSC focuses on the interactions between communicating entities, while CFSMs focus on the local state evolvement of each entity as a result of interactions. According to an aspect of an embodiment, a high-level compositional message sequence chart (HCMSC) is constructed to explicitly represent the interactions among CFSMs. HCMSC allows unmatched communication events in a basic compositional MSC. The synthesis starts with a transformation of CFSMs to a Petri net model. Then a labeled finite digraph is constructed, where each path represents a linearization of an occurrence net segment of the Petri net. According to an aspect of an embodiment, for example, exactly one such linearization (a single such linearization) from among many alternatives is explored and generated. In order to generate a compact representation, a linearization that could quickly lead to a cycle is favored. This allows infinitely repeated communication sequences to be folded into a finite and compact diagraph. Finally, the diagraph is decomposed into segments, where each segment is mapped to a compositional MSC.
These together with other aspects and advantages which will be subsequently apparent, reside in the details of construction and operation as more fully hereinafter described and claimed, reference being had to the accompanying drawings forming a part hereof, wherein like numerals refer to like parts throughout.
There are two general, complementary views of the dynamic behaviors of a distributed communicating system. One is based on scenarios, which focuses on the flows of message exchanges between communicating entities. The other is based on states, which focuses on the local state evolvement of each entity as a consequence of the communications. Message Sequence Charts (MSCs) and Communicating finite-state Machines (CFSMs) are two popular formalism representing the two views, respectively.
The embodiments relate to the synthesis of MSCs from CFSMs.
In
Sections 1, 2, and 3 generally describe Communicating Finite-State Machines (CFSMs), Message Sequence Chart (MSC) and Petri Net. In Section 4 the synthesis method, apparatus, and computer-readable medium thereof is described. Section 5 discusses applying the synthesis to some case studies.
1. Communicating Finite-State Machines (CFSMs). A network of communicating finite-state machines is a 4-tuple (Si=1, si0i=1N, Miji,j=1N, δ). N is a positive integer, representing the number of communicating machines. Si=1N are N disjoint finite sets, where Si represents the set of states of machine i. si0εSi represents the initial state of machine i. Miji,j=1N are N2 disjoint finite sets with Mii=0 for all i. Mij represents the set of messages can be sent from machine i to machine j, δ is a partial mapping for each process i and j, (δ: (Si×Mij)∪(Si×Mji)→Si. δ (s, m) represents the state entered after a machine transmits or receives message m in state s. It is a transmission if m is from Mi,j. It is a reception if m is from Mj,i.
CFSMs can be represented by a labeled directed graph, where nodes denote states, edges denote transitions. Transitions representing transmission of message m are labeled by −m. Transitions representing reception of message m are labeled by +m.
For example,
The finite-state machines communicate asynchronously via unbounded FIFO channels. According to an aspect of an embodiment, one channel might be required to be exclusively assigned to each type of message passed between a pair of finite-state machines, or any other combinations of channel-to-message assignment(s). Such a requirement makes the communication mechanism different from the communication mechanism discussed in D. Brand and P. Zafiropulo, “On communicating finite-state machines,” J. ACM, 30(2):323-342, 1983, where only one full-duplex channel is assigned to each pair of finite-state machines.
For example, consider the CFSMs in
The CFSMs modification according to the embodiments makes the communication semantics of CFSMs consistent with that of message sequence charts. In other words, according to an aspect of an embodiment communication semantics of the CFSM are harmonized with the MSC by specifying a plurality of First-In-First-Out (FIFO) message channels among a plurality of CFSMs according to a message type. Messages of the same type that are exchanged between two entities should comply to FIFO order. The modification, on one hand, makes message overtaking, as a modeling feature of MSC, possible. On the other hand, it makes each message have a unique source and destination. This can have important implications or benefits as discussed later.
According to an aspect of an embodiment, there might not by any assumption on the amount of time that a machine spends in a state before sending a message, and a message spends in a channel before arriving at its destination.
2. Message Sequence Chart (MSC). A basic message sequence chart (bMSC) includes a set of concurrent processes, called instances, that communicate via messages whose temporal ordering is a partial order. Formally, define I to be a finite set of instances denoting the communicating entities. Let E be a set of events, partitioned into two sets S and R, where S is a set of sending events and R is a set of receiving events. There is a labeling function L: E→I that associates events to instances. Define M: S→R to be a bijection mapping that associates each sending event with a unique receiving event. Finally, let <i be a chain of events associated to an instance i in I. It corresponds to the visual order from top to bottom in which the events are displayed along the instance axis. A bMSC is then defined by the 5-tuple (I, E, L, M, <i).
The transitive closure of <i together with the ordering induced from the send-receive bijection M, i.e. a sending event precedes the corresponding receiving event, defines a partial order of the events set E. An important consequence of asynchronous communication is that messages overtaking is allowed. In other words, it is possible that instance A first sends message m then message n to instance B, but instance B first receives n then m.
A bMSC can be graphically represented by a frame containing a collection of instances.
A compositional MSC (CMSC) differs from a bMSC in the following way. In a bMSC each sending event is paired with a receiving event in the bMSC and vice versa. In a CMSC, however, sending or receiving events could have no corresponding receiving or sending events, respectively.
A high-level compositional MSC (HCMSC), which is discussed in E. L. Gunter, A. Muscholl, and D. Peled, “Compositional message sequence charts,” In TACAS 2001: Proceedings of the 7th International Conference on Tools and Algorithms for the Construction and Analysis of Systems, pages 496-511, London, UK, 2001, Springer-Verlag, is a diagraph, where each node represents a CMSC and edges connecting nodes represent asynchronous compositions. The HCMSC can be introduced to deal with certain scenarios that can not be finitely represented by a bMSC or hMSC.
Herein, an MSC refers to the general notion of message sequence charts, including bMSC, hMSC, CMSC, or HCMSC, or any combinations thereof.
3. Petri Net, A Petri net is a 4-tuple (P, T7 F, M0). P is a finite set of places. T is a finite set of transitions. F: (P×T)∪(T×P)→N is the flow relation. M0: P→N is the initial marking. In general, M: P→N is a marking, which represents a state of a Petri net. N denotes the set of nonnegative integers. Let vεP∪T. Its preset and postset are given by:
*v={uεP∪T|F(u,v)>0},v*={uεP∪T|F(v,u)>0}
A Petri net is finitely preceded if for every vεP∪T, v is finite.
A transition t is enabled at a given marking M, if M(p)≧F(p,t) for all place pεP. When a transition is enabled it can fire. The new marking M′ reached after the firing of t is defined as: M′(p)=M(p)−F(p,t)+F(t,p) for all place pεP.
The incidence matrix A=|aij| is a |T|×|P| matrix, where aij=F(ti, pj)−F(pj, ti). If a marking M′ is reachable from M through a firing sequence a then M=M+AT
Two distinct transitions t and t′ are in a conflict relation, if *t∪*t≈0. Two distinct transitions t and t′ are in a free choice relation, if for each place pε*t∪*t and for each transition t″εp*,F(p,t)=F(p,t′)=F(p,t″). An occurrence net is a acyclic, finitely preceded Petri net such that for all places pεP, |*p|≦1 and |p*|≦1. Intuitively, occurrence nets are cycle-free and conflict-free Petri nets. Occurrence nets naturally represent a partial ordering of the events associated with Petri net transitions.
4. Synthesis of MSC from CFSM. According to an aspect of an embodiment, a partial ordering of events is represented by MSCs and occurrence nets. Given one representation, the other may be derived directly from the structure. A structural transformation from bMSCs to occurrence nets has been studied in P. Graubmann, E. Rudolph, and J. Grabowski, “Towards a Petri Net Based Semantics Definition for Message,” In SDL '93—Using Objects (Editors: O. Faergemand, A. Sarma), North-Holland, October 1993, October 1993. However, the embodiments do not explicitly generate an occurrence net and then transform it to a MSC. Instead, according to an aspect of an embodiment, after a set of chains of events are obtained as a linearization in 142, at 144, each chain of events (linearization) is mapped to a process line in a MSC. An embodiment also transforms CFSMs to a Petri net by explicitly representing the communication channels with places. Although Petri net places might not preserve the FIFO ordering, the execution semantics is not affected as tokens are not distinguished. The FIFO ordering can be reconstructed when events are matched in the finial MSC generation.
According to an aspect of an embodiment, for example, it might not be assumed the CFSMs have a finite number of states. In other words, the communication channels could have unbounded capacity. Unboundedness can be a desired abstraction of high-level models of telecommunication systems. In fact, MSCs can model infinite-state systems. According to an aspect of an embodiment, the channel capacity might be constrained only when a finite HCMSC representation can not be obtained otherwise.
Transformation of CFSMs to a Petri Net at 140 will be described according to Pseudo Code 1:
For example,
It is possible that there exist more than one output transition of a place modeling a channel. However, this will not introduce conflict, as at any given state only one of the output transitions is enabled. For example, in
It could be difficult to structurally distinguish the transitions that model alternatives and choices from the output transitions of a channel place. For example, theoretically, they are all transitions in structural conflict. After a Petri net directly mapped from CFSMs is obtained, at 212, silent transitions are inserted to model alternative state transitions as non-deterministic free choices. These transitions are called silent, because they are not associated with communication events in the original CFSM, enabling free choice relationships when there are alternative transitions to be fired. For example, in
The free choice modeling allows a finite-state machine to commit to a transition triggered by a receiving event even when the message has not arrived yet. This implies that the modeled finite-state machine can not test for the arrival of a message before deciding whether to take a transition. This implies that the CFSMs communicate using blocking read, non-blocking write semantics. Given that messages have a single source and single destination, the Petri net derived from these CFSMs by the Pseudo Code 1, can meet a Kahn Process Network (KPN) discussed in G. Kahn, “The semantics of a simple language for parallel programming,” In Information processing, pages 471-475, August 1974; and in G. Kahn and D. B. MacQueen, “Coroutines and networks of parallel processes,” In Information processing, pages 993-998, August 1977. Based on the KPN theory, the sequence of messages exchanged between FSMs will not change with different execution orders of the CFSMs. This theoretical result ensures the correctness of the next synthesis by the Pseudo Code 2 based upon the Petri net derived by the Pseudo Code 1.
According to an aspect of an embodiment, at 142, a particular execution of the Petri Net that has a compact representation (also referred to as an occurrence net) is selected, and this will lead to a compact HCMSC. The sequence of messages appearing in channels will not be affected by which execution order is chosen. In other words, all executions can yield equivalent HCMSCs. Therefore, the embodiments can generate a compact HCMSC. Directly synthesizing occurrence nets from a Petri net can often be a difficult task, but it is not necessary, because the embodiments use linearizations of partially-ordered events to obtain a compact representation, and allow a post-processing to recover the partial-ordering (occurrence net).
A set of partially ordered events could have a large number of possible linearizations. However, the embodiments in
In
The embodiments take advantage of the knowledge of underlying CFSMs. Each message has a unique sender and receiver. This implies that the system behavior diverges only when a finite-state machine makes a transition among alternatives. These alternatives are modeled by free choices. Thus, for example, all transitions in a free choice set are explored, and the complete set of scenarios can be obtained. It is worth noticing that at a state any enabled transition can be chosen to fire. Compared with partial-ordered reduction techniques, this adds more flexibility during a state space search. If the transition chosen to fire belongs to a free-choice set, then all other transitions in the set have to be explored. This guarantees that the completeness of the generated scenarios, It also guarantees that any two branches in the labeled digraph will not correspond to different interleavings of the same MSC. So each branch (that creates a path) in the labeled digraph corresponds to a different interleaving, such that instead of looking at “all possible” interleavings, according to an aspect of an embodiment only one (single) interleaving is crated for one subset of events. This is because transitions in a free choice set model decisions to choose different alternative transitions of a FSM. In other words, any two subsequent scenarios differ by their top event. More particularly, at 142 (
As illustrated in Pseudo Code 2, the partial ordered-execution of a Petri net transformed from CFSMs is a cycle-guided depth-first search. Practically, it creates a diagraph with each node representing a state that was previously visited. At a state one enabled free choice set is chosen to fire. Note that a non-conflicting transition can be viewed as a special case of a free choice set (with one element). Among enabled transitions, one is chosen based on the heuristic to search for minimal cycles. Terminating a branch with a cycle may not be always successful. Certain branches could lead to deadlock or infinite accumulation of tokens. According to an aspect of an embodiment, once either case is identified, the corresponding branch search is terminated and labeled with an exit. The labeled digraph actually comprises the interleavings of partial ordered events, which is referred to as a representative graph of occurrence nets of the Petri net obtained at 140.
After, at 142, a representative graph is obtained, at 144, the graph is segmented into sequences such that each segment could be mapped to a CMSC and a HCMSC could be constructed by a composition of the CMSCs. The segmentation is done through one traversal of the representative graph. Sequence of transitions are broken at nodes which have more than one incoming edges or outgoing edges. The former represents an iteration, and the latter represents a choice. Then, at 146, for each segment of sequence, the communication events modeled by the transitions are projected onto corresponding instance axes of a CMSC.
For example, at 146, the representative graph in
Note that if there exists unmatched events in a CMSC, special attention is paid to matching events in the subsequent CMSC. This is because it is possible that a receiving event in a CMSC actually matches with a sending event in a previous CMSC, instead of a sending event within the same CMSC. This is because the two sending events must comply with the FIFO ordering. For example, in
According to an aspect of an embodiment, synthesizer can be implemented in computing hardware and/or software, for example (without limitation) in C programming language as an extension of a synthesis package QSS discussed in J. Cortadella, A. Kondratyev, L. Lavagno, C. Passerone, and Y Watanabe, “Quasi-static scheduling of independent tasks for reactive systems,” IEEE Transactions on Computer-Aided Design, 24(10):1492-1514, 2005. The inventive synthesizer takes as input a set of communicating sequential programs describing the CFSMs. Each sequential program describes the state transitions of a finite-state machine as a result of certain communication events. The program could contain conditional branches, which model the local decisions. The inventive synthesizer generates a HCMSC in any format, for example, a format that is recognized by Scenery discussed in R Murthy, S. Rajan, and K. Takayama, “High level hardware validation using hierarchical message sequence charts,” In IEEE High-Level Design, Validation and Test Workshop, pages 167-172, 2004, which has a graphical user interface (GUI). Further, the inventive synthesizer can report abnormal terminations, such as deadlock or unboundedness, and gives the traces in form of a HCMSC that lead to them.
Table 1 presents the statistics of example experiments performed on a 3.06 GHz Intel Xeon CPU with 512 KB cache and 3.5 GB memory.
The first example models a protocol specification (a communication protocol specifying rules by which two systems communicate) described in A. Ito, H. Saito, F Nitta, and Y. Kakuda, “Transformation technique between specification in sd1 and specification in message sequence charts for designing protocol specifications,” In ICC '92 IEEE International Conference on Communications, pages 442-447, 1992. The second example models a boiler control system described in S. Uchitel, J. Kramer, and J. Magee, “Incremental elaboration of scenario-based specifications and behavior models using implied scenarios,” ACM Trans. Softw. Eng. Methodol., 13(1):37-85, 2004. The last example models a library access control system described in D. Brand and P. Zafiropulo, “On communicating finite-state machines,” J. ACM, 30(2):323-342, 1983. Note that the number of CMSC counts all instantiations. The relatively large number of CMSC nodes and edges are due to the fact that there exist a large number of conditional transitions in the CFSMs.
The transformation from CFSMs to Petri nets is simply a structural transformation, thus can be done in linear time of the number of edges and states in the CFSMs. However, the partial ordered execution may take time exponential of the number of branches in CFSMs. This might be due to fact all transitions in a free choice set might be explored. Recall that this might be necessary, because different transitions in a free choice set correspond to different top events in the subsequent scenarios.
The described inventive synthesis generates a HCMSC from a network of communicating finite-state machines. The method is based on a synthesis of Petri net representation of CFSMs. According to an aspect of an embodiment; the inventive concept is use of Petri net structural theory and knowledge of underlying CFSM semantics to efficiently construct a succinct representation of the occurrence nets. An occurrent net basically represents a partial ordering which can be easily transformed into a MSC. The modeling of alternative transitions at a state of a FSM by non-deterministic free choices could introduce subtle semantics difference between the original CFSMs and the Petri net. It could cause artificial deadlocks of the Petri net. However, this should not add significant computation efforts. For example, typically an artificial deadlock is reached immediately after a non-deterministic choice.
The existence of unmatched events in a CMSC can make the HCMSC more difficult to read and understand than HMSC. However, many unmatched events could be eliminated. According to an aspect of an embodiment, the inventive concept is application of the concept of retiming in logic synthesis, in which unmatched events could be moved from the incoming edges of a node to its outgoing edges, or vice versa. This movement of unmatched events may render most CMSCs as bMSCs, and reduce the number of CMSCs (having unmatched events) considerably.
An aspect of the invention provides synthesizing a message sequence chart (MSC) (one or more MSCs) from a communicating finite-state machine (CFSM) (one or more CFSMs as a network of CFSMs), comprising transforming the CFSM to a Petri net model; generating a labeled finite digraph with each path representing a linearization of an occurrence net segment of the Petri net; decomposing the diagraph into segments; mapping each segment to a compositional MSC; and outputting the compositional MSC. According to an aspect of the invention, the embodiments can be used in any design or programming environment that uses visual notation for specifying design using MSCs (sequence diagrams) and FSMs (CFSMs, state charts, . . . ), or whenever there is a need for transforming the FSM model to an MSC model. According to an aspect of the invention, a programming environment can represent design using FSMs and MSCs in an iterative behavior preserving manner.
Any combinations of the described features, functions and/or operations can be provided. The embodiments can be implemented in computing hardware (computing apparatus) and/or software, such as (in an unlimiting example) any computer that can store, retrieve, process and/or output data and/or communicate with other computers.
The many features and advantages of the embodiments are apparent from the detailed specification and, thus, it is intended by the appended claims to cover all such features and advantages of the embodiments that fall within the true spirit and scope thereof. Further, since numerous modifications and changes will readily occur to those skilled in the art, it is not desired to limit the invention to the exact construction and operation illustrated and described, and accordingly all suitable modifications and equivalents may be resorted to, falling within the scope thereof.
Claims
1. A method of synthesizing a message sequence chart (MSC) from a communicating finite-state machine (CFSM), comprising:
- transforming the CFSM to a Petri net model;
- generating a labeled finite digraph with each path representing a linearization of an occurrence net segment of the Petri net;
- decomposing the diagraph into segments;
- mapping each segment to a compositional MSC; and
- outputting the compositional MSC.
2. The method according to claim 1, further comprising harmonizing communication semantics of the CFSM with the MSC by specifying a plurality of First-In-First-Out (FIFO) message channels among a plurality of CFSMs according to a message type.
3. The method according to claim 1, wherein the transforming of the CFSM to the Petri net model comprises:
- mapping each state of the CFSM states to a place of the Petri net;
- marking each place corresponding to initial states from among the CFSM states;
- modeling the message channels as places of the Petri net; and
- modeling alternative state transitions as non-deterministic choices by inserting a silent transition,
- wherein the generating the labeled finite digraph comprises searching states of the Petri net according to a firing of a transition in a free choice set of transitions, as a linearization of the Petri net states.
4. The method according to claim 1, wherein the generating of the labeled finite digraph comprises searching states of the Petri net according to a firing of a transition in a free choice set of transitions, as a linearization of the Petri net states.
5. The method according to claim 4, wherein the searching comprises repeatedly selecting a single transition in the free choice set of transitions as a single linearization from among alternative linearizations according to the minimum linearization time specified by a minimal T-invariant.
6. The method according to claim 5, wherein all possible transitions in the selected free choice set are searched.
7. The method according to claim 1, wherein the minimum linearization time is according to a T-invariant of the Petri net.
8. The method according to claim 1, wherein communication channels of the CFSMs have unbounded capacity.
9. An apparatus synthesizing a message sequence chart (MSC) from a communicating finite-state machine (CFSM), comprising:
- a controller transforming the CFSM to a Petri net model, generating a labeled finite digraph with each path representing a linearization of an occurrence net segment of the Petri net, decomposing the diagraph into segments, mapping each segment to a compositional MSC, and outputting the compositional MSC.
10. The apparatus according to claim 9, wherein the controller further harmonizes communication semantics of the CFSM with the MSC by specifying a plurality of First-In-First-Out (FIFO) message channels among a plurality of CFSMs according to a message type.
11. The apparatus according to claim 9, wherein the transforming of the CFSM to the Petri net model comprises:
- mapping each state of the CFSM states to a place of the Petri net;
- marking each place corresponding to initial states from among the CFSM states;
- modeling the message channels as places of the Petri net; and
- modeling alternative state transitions as non-deterministic choices by inserting a silent transition,
- wherein the generating the labeled finite digraph comprises searching states of the Petri net according to a firing of a transition in a free choice set of transitions, as a linearization of the Petri net states.
12. The apparatus according claim 9, wherein the generating of the labeled finite digraph comprises searching states of the Petri net according to a firing of a transition in a free choice set of transitions, as a linearization of the Petri net states.
13. The apparatus according to claim 12, wherein the searching comprises repeatedly selecting a single transition in the free choice set of transitions as a single linearization from among alternative linearizations according to the minimum linearization time specified by a minimal T-invariant.
14. The apparatus according to claim 13, wherein all possible transitions in the selected free choice set are searched.
15. The apparatus according to claim 9, wherein the minimum linearization time is according to a T-invariant of the Petri net.
16. The apparatus according to claim 9, wherein communication channels of the CFSMs have unbounded capacity.
Type: Application
Filed: Mar 14, 2008
Publication Date: Sep 17, 2009
Patent Grant number: 8577665
Applicant: Fujitsu Limited (Kawasaki)
Inventors: Praveen K. MURTHY (Fremont, CA), Cong Liu (Richmond, CA)
Application Number: 12/048,648