Operating Systems Homework 3.pdf - Assignment III Please submit this homework to Canvas by Feb 24 Saturday 1 Here are the codes for producer and

Operating Systems Homework 3.pdf - Assignment III Please...

This preview shows page 1 - 3 out of 4 pages.

Assignment III Please submit this homework to Canvas by Feb 24, Saturday 1.Here are the codes for producer and consumer problems Producer: while (true) { /* produce an item in next produced */ while (counter == BUFFER_SIZE) ; /* do nothing */ buffer[in] = next_produced; in = (in + 1) % BUFFER_SIZE; counter++; } Consumer: while (true) { while (counter == 0) ; /* do nothing */ next_consumed = buffer[out]; out = (out + 1) % BUFFER_SIZE; counter--; /* consume the item in next consumed */ } counter++ could be implemented by Producer as register1 = counter register1 = register1 + 1 counter = register1 counter-- could be implemented by Consumer as register2 = counter register2 = register2 - 1 counter = register2 If we set the current value of “counteras 7, when Producer and Consumer concurrently execute one time, what are the possible values of ‘’counter”,please give an example for each values.