Questions tagged [producer-consumer]
The Producer-Consumer Problem (also known as the bounded-buffer problem) is a classical example of a multi-process synchronization problem. The problem describes two processes, the producer and the consumer, who share a common, fixed-size buffer used as a queue.
14
questions
5
votes
3answers
2k views
A multi-thread Producer Consumer, where a Consumer has multiple Producers (C++17)
EDID: Thank you very much for your feedback. I updated the code and opened a new post for the updated version. See here.
This post is loosely based on A multi-threaded Producer Consumer with C++11.
...
2
votes
1answer
938 views
Producer-Consumer in C++ - follow-up
To expand from the changes supplied by the answer of my previous question:
...
32
votes
2answers
64k views
A multi-threaded Producer Consumer with C++11
I am trying to learn concurrent programming in C++11. I tried to write code for a classic producer consumer concurrency problem. Would you please review and make any comments about it?
...
16
votes
1answer
6k views
Lock-free multiple-consumer multiple-producer queue
The code below implements an intrusive lock-free queue that supports multiple concurrent producers and consumers.
Some features:
Producers and consumers work on separate ends of the queue most of ...
3
votes
4answers
18k views
Reader-writers problem using semaphores in Java
I have written my own solution to the Reader-Writers problems using semaphores based on the psuedocode from Wikipedia. I would like to gauge the correctness and quality of the code.
...
18
votes
3answers
4k views
Producer/Consumer programs
I am studying mutual exclusion in college, and we just covered the producer/consumer problem. The class does not involve writing code, but I decided to implement a bounded buffer version of this ...
7
votes
2answers
636 views
Concurrent stack in C
(See also the follow-up question.)
I was in the mood for pthread.h and decided to write a concurrent stack data structure. My requirements:
the stack has maximum ...
7
votes
1answer
922 views
Optimizing producer consumer using monitors
I am trying to review concurrency concepts, i.e monitor, semaphores, etc. I've learned that Semaphores are natively not available in C++11 (presumably because it is very error prone) - which is why I ...
6
votes
2answers
5k views
Producer-Consumer in C++
This is my first experimentation with the producer-consumer problem (and thread manipulation in general), so any feedback on taboos and fixes is greatly appreciated!
...
6
votes
1answer
2k views
Simulation of Multiple Producer Consumer
I am trying to implement the Multiple Producer-Consumer problem. I have made the buffer as the lock to maintain consistency of the system. Does this system actually implement multithreading? How can I ...
5
votes
1answer
136 views
Concurrent stack in C - follow-up
This is a follow-up question to Concurrent stack in C
The pop function not just removes the top element from the stack, but also returns it.
If a pthreads call ...
2
votes
0answers
578 views
Many-readers-one-writer with semaphores and multithreading
I've been looking for a solution to the may readers one writer in Java.
I was intrigued by this question posted here and I read the Wikipedia entry about it.
So far, I've reached a fine solution, or ...
1
vote
1answer
1k views
Producer/Consumer implementation using condition_variable
Trying to implement producer/consumer problem in C++. I have one question: should I use nofify_all or notify_one method here? ...
1
vote
1answer
218 views
A multi-thread Producer Consumer, where a Consumer has multiple Producers (C++17) - Part 2
This post is based on A multi-thread Producer Consumer, where a Consumer has multiple Producers (C++17). I am trying to build a Consumer that consumes data from ...