source: CIVL/mods/dev.civl.com/doc/manual/dining/diningBad.cvl@ cb4d4f4

main test-branch
Last change on this file since cb4d4f4 was aad342c, checked in by Stephen Siegel <siegel@…>, 3 years ago

Performing huge refactor to incorporate ABC, GMC, and SARL into CIVL repo and use Java modules.

git-svn-id: svn://vsl.cis.udel.edu/civl/trunk@5664 fb995dde-84ed-4084-dfe6-e5aef3e2452c

  • Property mode set to 100644
File size: 530 bytes
Line 
1$input int B = 4; // upper bound on number of philosophers
2$input int n; // number of philosophers
3$assume(2<=n && n<=B);
4
5_Bool forks[n]; // Each fork will be on the table ($true) or in a hand ($false).
6
7void dine(int id) {
8 int left = id;
9 int right = (id + 1) % n;
10 while (1) {
11 $when (forks[left]) forks[left] = $false;
12 $when (forks[right]) forks[right] = $false;
13 forks[right] = $true;
14 forks[left] = $true;
15 }
16}
17
18void main() {
19 $for(int i: 0..n-1) forks[i] = $true;
20 $parfor(int i: 0..n-1) dine(i);
21}
Note: See TracBrowser for help on using the repository browser.