Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define FALSE 0
- #define TRUE 1
- #define N 2 /* number of processes */
- int turn; /* whose turn is it? */
- int interested[N]; /* all values initially 0 (FALSE) */
- void enter region(int process); /* process is 0 or 1 */
- {
- int other; /* number of the other process */
- other = 1 −process; /* the opposite of process */
- interested[process] = TRUE; /* show that you are interested */
- tur n =process; /* set flag */
- while (turn == process && interested[other] == TRUE) /* null statement */ ;
- }
- void leave region(int process) /* process: who is leaving */
- {
- interested[process] = FALSE; /* indicate departure from critical region */
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement