单选题:The following algorithm is proposed to solve the critical sectio
The following algorithm is proposed to solve the critical section problem between two processes P1 and P2, where lock is a shared variable.@[B](1)
```
P1 P2
do { do {
while (lock) { NULL;} while(lock) { NULL;}
lock = TRUE; lock = TRUE;
critical section; critical section;
lock=FALSE; lock=FALSE;
reminder section; reminder section;
}while(1); }while(1);
```
Which of the following statements is true regarding the proposed algorithm?
A. Mutual exclusion to the critical section is guaranteed
B. Both processes can be in their critical section at the same time
C. lock should be initialized to TRUE
D. None of the above
A.Mutual exclusion to the critical section is guaranteed
B.Both processes can be in their critical section at the same time
C.lock should be initialized to TRUE
D.None of the above
答案:B
```
P1 P2
do { do {
while (lock) { NULL;} while(lock) { NULL;}
lock = TRUE; lock = TRUE;
critical section; critical section;
lock=FALSE; lock=FALSE;
reminder section; reminder section;
}while(1); }while(1);
```
Which of the following statements is true regarding the proposed algorithm?
A. Mutual exclusion to the critical section is guaranteed
B. Both processes can be in their critical section at the same time
C. lock should be initialized to TRUE
D. None of the above
A.Mutual exclusion to the critical section is guaranteed
B.Both processes can be in their critical section at the same time
C.lock should be initialized to TRUE
D.None of the above
答案:B