- #1
Peon666
- 108
- 0
I read this code in my OS book but I'm having trouble understanding it. Would someone explain to me what's happening in this code? This code is the first-known correct software solution to the critical-section problem for two processes and was developed by Dekker.
I'm totally clueless about what's going on in this code.
Code:
boolean flag[2];
int turn;
// Above two variables are shared by the two processes.
do {
flag[i]=TRUE;
while (flag[j]){
if (turn == j){
while (turn == j)
;// do nothing
flag[i]=FALSE;
}
}
// critical section
turn = j;
flag[i]=FALSE;
// remainder section.
}while (TRUE);
I'm totally clueless about what's going on in this code.