Advertisement
Guest User

Untitled

a guest
Apr 27th, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.40 KB | None | 0 0
  1. chan ch[3] = [2] of {byte};
  2.  
  3. byte critical = 0;
  4. #define mutex (critical <=1)
  5.  
  6. proctype P(byte inch; byte outch)
  7. {
  8. byte msg;
  9. do
  10. :: /* Waiting for token */
  11. ch[inch] ? msg;
  12. /*in critical region */
  13. critical++;
  14. /* Leaving critical region */
  15. critical--;
  16. ch[outch] ! msg;
  17. od;
  18. }
  19.  
  20. init {
  21. ch[0] ! 0;
  22. atomic {
  23. run P(0,1);
  24. run P(1,2);
  25. run P(2,0);
  26. }
  27. }
  28.  
  29. ltl{[]mutex}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement