Skip to content

Instantly share code, notes, and snippets.

@hedgesky
Created January 10, 2017 11:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hedgesky/616b62f7bd0b1fe9b12dc664d6109ec1 to your computer and use it in GitHub Desktop.
Save hedgesky/616b62f7bd0b1fe9b12dc664d6109ec1 to your computer and use it in GitHub Desktop.
channel in1 = [4] of { int };
channel in2 = [4] of { int };
channel out = [8] of { int };
int turn;
int t1, t2;
proctype read() {
do
::
if
:: turn == 1 ->
if
:: !empty(in1) ->
atomic {
in1?t1
out!!t1
}
fi
turn = 2
:: else ->
if
:: !empty(in2) ->
atomic {
in1?t2
out!!t1
}
fi
turn = 1
fi
od;
}
init {
atomic {
turn = 1;
in1!!1;
in1!!2;
in1!!3;
in1!!4;
in2!!5;
in2!!6;
in2!!7;
in2!!8;
run read();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment