Advertisement
Guest User

Untitled

a guest
Jul 19th, 2017
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. main() {
  2. Lock All Mutex;
  3.  
  4. For(Threads T IN Gasthaus)
  5.     ThreadMain(T);
  6. }
  7.  
  8.  
  9. Thread Main(Thread T) {
  10.  
  11. IF(T == EV_SIT)
  12.     sit();
  13.     UNLOCK mutex_ev_sit;
  14. END IF
  15. ELSE IF( T == ED_SIT)
  16.     sit();
  17.     UNLOCK mutex_ed_sit;
  18. END IF
  19. ELSE IF(T == V_SIT)
  20.     LOCK mutex_ev_sit;
  21.     sit();
  22. END IF
  23. ELSE IF(T == D_SIT)
  24.     LOCK mutex_ed_sit;
  25.     sit();
  26. END IF
  27. ELSE IF(T == V_EAT)
  28.     LOCK mutex_d_sit;
  29.     eat();
  30.     UNLOCK mutex_v_eat_0;
  31.     UNLOCK mutex_v_eat_1;
  32.     UNLOCK mutex_v_eat_2;
  33.     UNLOCK mutex_v_eat_3;
  34. END IF
  35. ELSE IF(T == EV_EAT)
  36.     LOCK mutex_v_eat_0;
  37.     eat();
  38. END IF
  39. ELSE IF(T == ED_EAT)
  40.     LOCK mutex_v_eat_1;
  41.     eat();
  42. END IF
  43. ELSE IF(T == D_EAT)
  44.     LOCK mutex_v_eat_2;
  45.     eat();
  46. END IF
  47. ELSE IF(T == GUEST_EAT)
  48.     LOCK mutex_v_eat_3;
  49.     eat();
  50. END IF
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement