Parallel Processing - Peterson Algorithm

For unfamiliar users, the Peterson algorithm is used to coordinate processes:

int No_Of_Processes; // Number of processes
int turn; // Whose turn is it?
int interested[No_Of_Processes]; // All values initially FALSE

void enter_region(int process) {
int other; // number of the other process

other = 1 - process; // the opposite process
interested[process] = TRUE; // this process is interested
turn = process; // set flag
while(turn == process && interested[other] == TRUE); // wait
}

void leave_region(int process) {
interested[process] = FALSE; // process leaves critical region
}

My question is: can this algorithm cause a dead end?

+3
source share
1 answer

, . , , - while. process , , turn . , true turn == process . , , No_Of_Processes, . N .

+1

All Articles