Advertisement
pavelandreev443

Untitled

Apr 20th, 2018
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. #define FALSE 0
  2. #define TRUE 1
  3. #define N 2 /* number of processes */
  4. int turn; /* whose turn is it? */
  5. int interested[N]; /* all values initially 0 (FALSE) */
  6. void enter region(int process); /* process is 0 or 1 */
  7. {
  8. int other; /* number of the other process */
  9. other = 1 −process; /* the opposite of process */
  10. interested[process] = TRUE; /* show that you are interested */
  11. tur n =process; /* set flag */
  12. while (turn == process && interested[other] == TRUE) /* null statement */ ;
  13. }
  14. void leave region(int process) /* process: who is leaving */
  15. {
  16. interested[process] = FALSE; /* indicate departure from critical region */
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement