Mesmo
Mesmo

Reputation: 2000

Semantics of Fork and Join in UML State machines

Can anyone tell me if the two models below (top one taken from the UML Superstructure Specification) are semantically equivalent? Fork & Join versus entering parent state

I'm looking to add Fork and Join pseudo state kinds to my state machine library and this appears to be a useful way for me to implement.

Upvotes: 6

Views: 3909

Answers (3)

dotnetzen
dotnetzen

Reputation: 186

I think from your implementation point of view, they are the same. The other answers here are just arguing about the semantics but that is what you asked in the question. As far as output is concerned, they are the same. The Initial pseudostate cannot have triggers or guards, and the Final state cannot have outgoing transitions. And the Process composite cannot exit unless both regions have finalized. So, your Process composite is basically taking over the roles of the Fork and Join pseudostates.

Upvotes: 1

gefei
gefei

Reputation: 19776

These two diagrams are not equivalent.

Replacing the fork by two initials is no problem: in the upper state machine, A1 and B1 get active simultaneously, so do the in the lower one.

However, replacing the Join by two final states is problematic. In the upper case, (Process, A2, B2) is the last state configuration before Cleanup gets active. In every run, before Cleanup is active, Process, A2 and B2 are active. In the lower case, it is (Process, final, final) that has to be active.

In other words, (Process, A2, B2) and (Cleanup) are "neighbor" state configurations in the upper case, but they are not in the lower case. There is (Process, final, final) in between.

"Semantically equivalent" depends on what you define as semantically relevant. For me, it is makes a difference whether Cleanup is the next step after (Process, A2, B2) or it is the next next step.

MOREOVER

in the upper case A2 and B2 have to be simultaneously active, before Process is left. In the lower case, there is no such need. A trace may be ... (Process, final, B1), (Process, final B2), (Process, final, final), then Process is left.

Upvotes: 2

Bruce
Bruce

Reputation: 2310

The initial and final states in the lower diagram don't exist in the upper. They imply additional behavior before the A1/B1 states and after the A2/B2 states that the upper diagram doesn't have, so no, they are not equivalent diagrams. The top diagram implies that the SETUP state or the transition event is responsible for the fork and the creation of 2 processes, A and B. The bottom diagram implies that the PROCESS is responsible for creating the 2 processes.

Upvotes: 1

Related Questions