单选题:The following is a piece of code to solve the producer-consumer
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
```
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