Thanks to visit codestin.com
Credit goes to github.com

Skip to content

ZiyouZhang/Producer-Consumer-Demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Bounded-Buffer-Demo

A C++ implementation demonstrating the bounded-buffer problem (also known as producer-consumer problem) using semaphore.

Background

The problem describes several processes, the producers and the consumers, who share a common, fixed-size buffer used as a queue. The producer's job is to generate data, put it into the buffer, and start again. At the same time, the consumer 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. For more info check the wikipedia page here: Producer–consumer problem.

Getting Started

Clone this repository and compile the code using the makefile supplied. Run the command like following (replace arguments with numbers):

./main <QUEUE_SIZE> <NUMBER_OF_ITEMS_PER_PRODUCER> <NUMBER_OF_PRODUCERS> <NUMBER_OF_CONSUMERS>

Author

  • Ziyou Zhang - Algo design and coding stuff - LinkedIn

About

A C++ implementation of the Producer-Consumer problem.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published