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

单选题:The following is a piece of code to solve the producer-consumer

Luz5年前 (2021-05-10)题库709
The following is a piece of code to solve the producer-consumer problem:@[B](1)
```
Producer process:
item nextProduced;
while (1) {
while (counter == BUFFER_SIZE)
; /* do nothing */
buffer[in] = nextProduced;
in = (in + 1) % BUFFER_SIZE;
counter++;
}

Consumer process:
item nextConsumed;
while (1) {
while (counter == 0)
; /* do nothing */
nextConsumed = buffer[out];
out = (out + 1) % BUFFER_SIZE;
counter--;
}

```
A. is the while statement
B. is the statement “counter++”
C. is the variable “counter”
D. does not exist



A.is the while statement
B.is the statement “counter++”
C.is the variable “counter”
D.does not exist


答案:B