-->
当前位置:首页 > 题库

单选题:Consider the following software solution algorithm for two-proce

Luz5年前 (2021-05-10)题库805
Consider the following software solution algorithm for two-process CS problem (turn is a shared variable initialized as 1, i refers to 0 or 1). This algorithm @[A](1)
```
Pi:
while(1) {
flag[ i ] = true;
while (flag[1-i]) {
if (turn==(1-i)) {
flag[ i ] = false;
while ( turn == (1-i) );
flag[ i ] = true;
}
}
Critical Section
turn = 1-i;
flag[ i ] = false;
Remainder Section
}

```
A. meets the mutual exclusion condition, but may cause starvation
B. meets the mutual exclusion condition, and may not cause starvation
C. does not meet the mutual exclusion condition, and may cause starvation
D. does not meet the mutual exclusion condition, and may not cause starvation





A.meets the mutual exclusion condition, but may cause starvation
B.meets the mutual exclusion condition, and may not cause starvation
C.does not meet the mutual exclusion condition, and may cause starvation
D.does not meet the mutual exclusion condition, and may not cause starvation


答案:A