@nrailgun
2015-09-29T07:22:48.000000Z
字数 1141
阅读 2550
强力软件
Promela / spin 是实现正规化方法进行模型检查的工具。
active proctype P() {printf("hello, world\n");}
Sorry, there is no such thing as float point number for promela.
if:: a < b ->printf("<");:: a > b ->printf(">");:: else ->printf("==");fi
If multiple guards are true, spin will choose one randomly ! If none of the guards are true, then the process will be blocked.
do:: a > b -> a = a - b:: b > a -> b = b - a:: a == b -> breakod
Em, this looks more tidy than do pair.
int i;int sum = 0;for (i : 1 .. 5 ) {sum = sum + i;}
You can use for-each syntax like Java.
byte a[5];int sum = 0;for (i in a) {sum = sum + a [i]}
Here comes the famous goto.
active proctype P() {do:: i > 5 ->goto exitloop;:: else ->sum = sum + i;i++;od;exitloop:printf ("end")}
Promela has no methods or procedure calls. You have to use inline code.
inline foo(bar) {printf(bar);}active proctype P() {foo("!");}
Looks like Java synchronized keyword, which protects critical areas from being executed by multiple processes at the same time.
atomic {if:: a != 0 ->c = b / a:: else ->c = bfi}
Like atomic but has strong atomicity.
d_step {tmp = b;b = tmp + 1;}
They are doomed to abandoned. Anonymous variable _ ignore assignments.
chan c;c ? _;
