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:
712 bytes
|
| Line | |
|---|
| 1 |
|
|---|
| 2 | #include <stdlib.h>
|
|---|
| 3 |
|
|---|
| 4 | typedef struct node {
|
|---|
| 5 | int x;
|
|---|
| 6 | struct node * nxt;
|
|---|
| 7 | } * node_t;
|
|---|
| 8 |
|
|---|
| 9 | typedef struct list {
|
|---|
| 10 | node_t first;
|
|---|
| 11 | } * list_t;
|
|---|
| 12 |
|
|---|
| 13 | list_t list_create() {
|
|---|
| 14 | return (list_t)malloc(sizeof(struct list));
|
|---|
| 15 | }
|
|---|
| 16 |
|
|---|
| 17 | node_t node_create(int x) {
|
|---|
| 18 | node_t u = malloc(sizeof(struct node));
|
|---|
| 19 | u->x = x;
|
|---|
| 20 | u->nxt = NULL;
|
|---|
| 21 | return u;
|
|---|
| 22 | }
|
|---|
| 23 |
|
|---|
| 24 | void f(list_t l) {
|
|---|
| 25 | node_t z = l->first;
|
|---|
| 26 | z->x = 3;
|
|---|
| 27 | }
|
|---|
| 28 |
|
|---|
| 29 | void g(list_t l) {
|
|---|
| 30 | node_t y = l->first;
|
|---|
| 31 | y->x = 7;
|
|---|
| 32 | // f should intervene here but doesn't because...
|
|---|
| 33 | y->x *= 2;
|
|---|
| 34 | }
|
|---|
| 35 |
|
|---|
| 36 | int main() {
|
|---|
| 37 | list_t lst = list_create();
|
|---|
| 38 | lst->first = node_create(1);
|
|---|
| 39 | $parfor (int i:1..2) {
|
|---|
| 40 | if (i==1) {
|
|---|
| 41 | $atomic {f(lst);}
|
|---|
| 42 | } else {
|
|---|
| 43 | g(lst);
|
|---|
| 44 | }
|
|---|
| 45 | }
|
|---|
| 46 | $assert(lst->first->x != 6);
|
|---|
| 47 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.