implementing Dijkstra's guarded commands

Steven Ryan smryan at garth.UUCP
Sun Jul 17 08:06:04 AEST 1988


>>                               I am wondering if there is a nice way of
>> writing the C so that the algorithm preserves the possibility for
>> parallel execution
>
>	if C1 -> S1
>	 | C2 -> S2
>	 | C3 -> S3
>	fi
>
>then exactly one of S1, S2, and S3 will be executed (or the
>program will abort).  Where's the parallelism?

Underconstraining strikes again. The three guards C1, C2, and C3 are
evaluated nondeterministically. They can be evaluated in order, in reverse
order, in any other permutation. The individual instructions can be
intermingled, in parallel on a segmented cpu. Also, all three guards can
be sent to three parallel processors. If at least one guard is true, then
any one true guard can be selected.

The parallelism is neither required nor forbidden. The programmer must
avoid interfering side effects and let the compiler make what it thinks
is best.

In answer to the original question, you can't avoid overconstraining the
guard evaluations in statements: C only supports a deterministic statement
order. [You decide if that's good or bad.] I don't know about declarations:
I don't know if initialisers are serialised or collateral.

                                      sm ryan



More information about the Comp.lang.c mailing list