The Bounded Buffer Problem
Hi, not even sure if this is the right section for this im new to the forums new to programming! Im an engineering student doing an operating systems module with about 6 weeks Java experience and a little bit of C/C++ from before that. We have been given this bounded buffer problem as an assignment and I am truly lost. I understand the concept but have no clue how to implement that into a java program. There are a lot of examples of sample code for this problem online however we have been told we were are not allowed to use semaphores. Below is a brief of what we have been asked to do, any help/input would be great, cheers!
We have a buffer of a fixed size. A Producer thread inserts integers into the buffer, a Consumer thread takes them out. There are obvious constraints:
* The Producer cannot insert into a full buffer
* The Consumer cannot take from an empty buffer
* Updates to the buffer must be mutually exclusive
When roomAvailable is false the buffer is full, when true there is at least one free slot available for the Producer. When dataAvailable is false the buffer is empty, when true there is at least one integer in the buffer for the Consumer to remove. The buffer operates in a FIFO manner, i.e. the first item to go in is the first to come out.