Parallel Programming - Producer Consumer problem (Bounded-buffer problem)

Data System Architecture

About

The producer–consumer problem (also known as the bounded-buffer problem) is a classic example of a multi-process synchronization problem in a producer consumer mode.

The problem describes two processes who share a common, fixed-size a queue used as buffer.

  • the producer
  • and the consumer

where:

  • The producer's job is to generate a piece of data, put it into the buffer and start again.
  • The consumer (at the same time) is consuming the data (i.e., removing it from the buffer) one piece at a time.

The problem is to make sure that the producer won't try to add data into the buffer if it's full and that the consumer won't try to remove data from an empty buffer.

The solution can be reached by means of inter-process communication.

Example

Lock

See gerardnico/java-demo/blob/master/src/Concurrency/ProducerConsumerWithBlockingQueue.java that use a Java Concurrency - (Queue|Stack)

An inadequate solution could result in a deadlock where both processes are waiting to be awakened.

Semaphore

The producer / consumer problem with a semaphore. See wiki/Semaphore_(programming)

Documentation / Reference





Discover More
Data System Architecture
Data Concurrency - Producer Consumer Thread

Producer / Consumer is concurrency model (ie two threads/process communication) where: one thread called a Producer sends data and the other thread called the Consumer receive data. The data send...
Card Puncher Data Processing
Process - (System) Simulation

process simulation. The basic model components are queues, (Queue theory to model finite resources) stochastic distributions (based on random number streams) to model the time Each collect...



Share this page:
Follow us:
Task Runner