Created
January 10, 2017 11:00
-
-
Save hedgesky/616b62f7bd0b1fe9b12dc664d6109ec1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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