单选题:Here is a description of the producer and the consumer in the Pr
Here is a description of the producer and the consumer in 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 --;
}
```
The critical section of the Producer is ______
A. the statement “counter --”
B. the statement “counter ++”
C. the variable “counter”
D. .not exist
A.the statement “counter --”
B.the statement “counter ++”
C.the variable “counter”
D..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 --;
}
```
The critical section of the Producer is ______
A. the statement “counter --”
B. the statement “counter ++”
C. the variable “counter”
D. .not exist
A.the statement “counter --”
B.the statement “counter ++”
C.the variable “counter”
D..not exist
答案:B