37 |
Diderot_World_t *wrld = Diderot_Initially (); |
Diderot_World_t *wrld = Diderot_Initially (); |
38 |
|
|
39 |
// iterate until all strands are stable |
// iterate until all strands are stable |
40 |
printf("run ...\n"); |
printf("run with %d strands ...\n", wrld->numStrands); |
41 |
int nSteps = 0, nUpdates = 0; |
int nSteps = 0, nUpdates = 0; |
42 |
int nActive = wrld->numStrands; |
int nActive = wrld->numStrands; |
43 |
while (nActive > 0) { |
while (nActive > 0) { |
50 |
if (sts == DIDEROT_STABILIZE) { |
if (sts == DIDEROT_STABILIZE) { |
51 |
// copy out to in so that both copies are the stable state |
// copy out to in so that both copies are the stable state |
52 |
// FIXME: there is a race condition here, since other strands might query this strand |
// FIXME: there is a race condition here, since other strands might query this strand |
53 |
memcpy (wrld->outState[i], wrld->inState[i], Diderot_Strands[0]->stateSzb); |
memcpy (wrld->inState[i], wrld->outState[i], Diderot_Strands[0]->stateSzb); |
54 |
wrld->isActive[i] = false; |
wrld->isActive[i] = false; |
55 |
nActive--; |
nActive--; |
56 |
} |
} |
112 |
wrld->size[i] = size[i]; |
wrld->size[i] = size[i]; |
113 |
} |
} |
114 |
|
|
115 |
|
printf("AllocInitially: %d", size[0]); |
116 |
|
for (int i = 1; i < nDims; i++) printf(" x %d", size[i]); |
117 |
|
printf("\n"); |
118 |
|
|
119 |
// allocate the strand state pointers |
// allocate the strand state pointers |
120 |
wrld->numStrands = numStrands; |
wrld->numStrands = numStrands; |
121 |
wrld->inState = (void **) malloc (numStrands * sizeof(void *)); |
wrld->inState = (void **) malloc (numStrands * sizeof(void *)); |