1

I would like to be able to force a transition as soon as a condition becomes true.

For example in this Example, I would like to force the transition from the system next from the state S0 to S1 as soon as the global variable a becomes 5. The guard is not enough because a can still be incremented once it reach 5 before the transition is fired. I really need the transition to be triggered and then continue to increment a.

Is there a simple way to do it? I tried by adding invariant in the state but it is creating deadlocks.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Mickaël
  • 38
  • 6

2 Answers2

1

Use channel synchronization. Several approaches:

  1. declare chan message; and add message! synchronization on the increment process, add message? on the next process transition, and use another transition with the guard to check the value of a and move to another location accordingly.

  2. declare urgent broadcast chan ASAP; and use ASAP! on the next edge, this will make this transition urgent as soon it becomes enabled (i.e. the guard is satisfied). Only the integer guards are supported on urgent transitions.

mariusm
  • 1,483
  • 1
  • 11
  • 26
0

You can simply add invariant a<=5 in the S0 state.

ondix
  • 1
  • 1
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Feb 07 '22 at 23:11
  • So when we add invariant to the states it is a forced update, but when we add a guard to the transitions it's not a forced update, right? – Fatih Ersoy Apr 03 '22 at 20:04