Advertisement
Guest User

Untitled

a guest
Nov 17th, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. int n = 0; // global variable n
  2.  
  3. //process p
  4. active proctype p(){
  5.  
  6. int counter = 0; // local counting variable for process p
  7.  
  8. do
  9. :: counter < 10 -> // untill the local counter does not reach ten
  10. int temp;
  11. temp = n; // use auxiliary variable
  12. n = temp + 1; // to increment global variable n
  13. counter ++; // increase counter after incrementing n
  14. :: counter >= 10 -> break; // when the local counter reaches 10, terminate process
  15. od
  16. }
  17.  
  18. //process q
  19. active proctype q(){
  20.  
  21. int counter = 0; // local counting variable for process p
  22.  
  23. do
  24. :: counter < 10 -> // untill the local counter does not reach ten
  25. int temp;
  26. temp = n; // use auxiliary variable
  27. n = temp + 1; // to increment global variable n
  28. counter ++; // increase counter after incrementing n
  29. :: counter >= 10 -> break // when the local counter reaches 10, terminate process
  30. od
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement