Tired of waiting in line at the store? Frustrated with the slow pace of the cashier? Producer-Consumer Problem is similar, except it happens in the world of computer programming.
1. Check if there are empty buffer slots. 2. If empty, acquire the lock to access the buffer. 3. Add data to the buffer. 4. Release the lock & signal that the slot is now filled.
1. Check if the buffer contains some item. 2. If yes, acquire the lock to access the buffer. 3. Removes the data from buffer. 4. Release the lock & signal that there is an empty slot in buffer.