Path: utzoo!attcan!uunet!husc6!bloom-beacon!bu-cs!purdue!decwrl!labrea!sri-unix!garth!smryan From: smryan@garth.UUCP (Steven Ryan) Newsgroups: comp.lang.c Subject: Re: implementing Dijkstra's guarded commands Summary: Cheating. Message-ID: <991@garth.UUCP> Date: 16 Jul 88 22:06:04 GMT References: <515@muffin.cme-durer.ARPA> <8044@alice.UUCP> Reply-To: smryan@garth.UUCP (Steven Ryan) Organization: INTERGRAPH (APD) -- Palo Alto, CA Lines: 29 Hero: Trots. Heroine: Bonnie. >> 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