Advertisement
Guest User

Untitled

a guest
Feb 20th, 2020
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.85 KB | None | 0 0
  1.  
  2. void T1(void)
  3. {
  4.     cout << "T1 STARTED" << endl;
  5.     Sleep(1000);
  6.     ReleaseSemaphore(sm[0], 3, NULL);
  7.     //WaitForMultipleObjects(3, sm, TRUE, INFINITE);
  8.     WaitForSingleObject(sm[1], INFINITE);
  9.     WaitForSingleObject(sm[2], INFINITE);
  10.     cout << "T1 FINISHED" << endl;
  11. }
  12.  
  13. void T2(void)
  14. {
  15.     cout << "T2 STARTED" << endl;
  16.     Sleep(2000);
  17.     ReleaseSemaphore(sm[1], 3, NULL);
  18.     //WaitForMultipleObjects(3, sm, TRUE, INFINITE);
  19.     WaitForSingleObject(sm[0], INFINITE);
  20.     WaitForSingleObject(sm[2], INFINITE);
  21.     cout << "T2 FINISHED" << endl;
  22. }
  23.  
  24. void T3(void)
  25. {
  26.     cout << "T3 STARTED" << endl;
  27.     Sleep(3000);
  28.     ReleaseSemaphore(sm[2], 3, NULL);
  29.     //WaitForMultipleObjects(3, sm, TRUE, INFINITE);
  30.     WaitForSingleObject(sm[0], INFINITE);
  31.     WaitForSingleObject(sm[1], INFINITE);
  32.     cout << "T3 FINISHED" << endl;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement