main
|
Last change
on this file was ea777aa, checked in by Alex Wilton <awilton@…>, 3 years ago |
|
Moved examples, include, build_default.properties, common.xml, and README out from dev.civl.com into the root of the repo.
git-svn-id: svn://vsl.cis.udel.edu/civl/trunk@5704 fb995dde-84ed-4084-dfe6-e5aef3e2452c
|
-
Property mode
set to
100644
|
|
File size:
657 bytes
|
| Line | |
|---|
| 1 | #include <stdlib.h>
|
|---|
| 2 |
|
|---|
| 3 | typedef struct node {
|
|---|
| 4 | int x;
|
|---|
| 5 | struct node * nxt;
|
|---|
| 6 | } * node_t;
|
|---|
| 7 |
|
|---|
| 8 | node_t head_create() {
|
|---|
| 9 | return (node_t)malloc(sizeof(struct node));
|
|---|
| 10 | }
|
|---|
| 11 |
|
|---|
| 12 | node_t node_create() {
|
|---|
| 13 | return (node_t)malloc(sizeof(struct node));
|
|---|
| 14 | }
|
|---|
| 15 |
|
|---|
| 16 | void f(node_t l) {
|
|---|
| 17 | node_t z = l->nxt;
|
|---|
| 18 | z->x = 1;
|
|---|
| 19 | }
|
|---|
| 20 |
|
|---|
| 21 | void g(node_t l) {
|
|---|
| 22 | node_t y = l->nxt;
|
|---|
| 23 | y->x = 0;
|
|---|
| 24 | // f should intervene here but doesn't because...
|
|---|
| 25 | y->x *= 2;
|
|---|
| 26 | }
|
|---|
| 27 |
|
|---|
| 28 | int main() {
|
|---|
| 29 | node_t head = node_create(); // head_create violates, node_create not
|
|---|
| 30 | head->nxt = node_create();
|
|---|
| 31 | $parfor (int i:1..2) {
|
|---|
| 32 | if (i==1) {
|
|---|
| 33 | $atomic {f(head);}
|
|---|
| 34 | } else {
|
|---|
| 35 | g(head);
|
|---|
| 36 | }
|
|---|
| 37 | }
|
|---|
| 38 | $assert(head->nxt->x != 2);
|
|---|
| 39 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.