spinlock model: Simplify state-space
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Mon, 8 Oct 2012 21:30:57 +0000 (17:30 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Mon, 8 Oct 2012 21:30:57 +0000 (17:30 -0400)
Remove useless busy-looping, useless in Promela. Same semantic as the
new code:

Quoting Michel Dagenais <michel.dagenais@polymtl.ca>:

> http://spinroot.com/spin/Man/condition.html
> In Promela , a standalone expression is a valid statement. Execution
> of a condition statement is blocked until the expression evaluates to
> a non-zero value (or, equivalently, to the boolean value true ).
>
> http://spinroot.com/spin/Man/separators.html
> The semicolon and the arrow are equivalent statement separators in
> Promela. The convention is to reserve the use of the arrow separator
> to follow condition statements. The arrow symbol can thus be used to
> visually identify those points in the code where execution could
> block.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
spinlock/mem.spin

index 9e87809ea64998947cb27f6b6c88745019f0e2e8..072d4d22c9610b52e91e98085f7794c4d3f2883b 100644 (file)
@@ -21,17 +21,7 @@ byte refcount = 0;
 
 inline spin_lock(lock)
 {
-       do
-       :: 1 -> atomic {
-                       if
-                       :: (lock) ->
-                               skip;
-                       :: else ->
-                               lock = 1;
-                               break;
-                       fi;
-               }
-       od;
+       atomic{ !lock -> lock = 1}
 }
 
 inline spin_unlock(lock)
@@ -42,8 +32,7 @@ inline spin_unlock(lock)
 proctype proc_X()
 {
        do
-       :: 1 ->
-               spin_lock(lock);
+       ::      spin_lock(lock);
                refcount = refcount + 1;
                refcount = refcount - 1;
                spin_unlock(lock);
This page took 0.028577 seconds and 4 git commands to generate.