3
對於那些不熟悉,下面是用於處理協調Peterson算法:併發處理 - Peterson算法
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
}
我的問題是,可以在此算法產生死鎖?
該死的,我找到了一個蠢貨,但它被關閉了一個不是真正的問題(什麼?),並且配方很差。所以我不會投票結束。 – 2011-05-15 13:21:32