Advertisement
WladcaTejKrainy

Untitled

Dec 5th, 2017
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. binarysem semafor1;
  2. binarysem semafor2;
  3. binarysem semafor3;
  4.  
  5. void proc1 ()
  6. {
  7.     wait(semafor1);
  8.         cout << "proces nr.1 " << endl;
  9.         signal(semafor2);
  10. }
  11. void proc2 ()
  12. {
  13.         wait(semafor2);
  14.         cout << "proces nr.2 " << endl;
  15.         signal(semafor3);
  16. }
  17. void proc3 ()
  18. {
  19.         wait(semafor3);
  20.         cout << "proces nr.3 " << endl;
  21.     signal(semafor3);
  22. }
  23.  
  24. main()
  25. {
  26.         cobegin  {
  27. initialsem(semafor1,1);
  28. initialsem(semafor2,0);
  29. initialsem(semafor3,0);
  30. proc1();
  31. proc2();
  32. proc3();
  33.         }  
  34.    
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement