Review your favorite Linux distribution.
Go Back > Forums > Linux Forums > Linux - Software
User Name
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.


  Search this Thread
Old 03-07-2012, 06:31 AM   #1
LQ Newbie
Registered: Aug 2010
Posts: 18

Rep: Reputation: 0
Fast Producer, Slow Consumer

Hello all,

I have a Producer-Consumer situation, between threads. I have a working implementation of message queue that is internally implemented using Posix condition variables.
The problem is that the consumer is VERY slow compared to the producer, so while the consumer is processing the message (and hance don't "cond_waid") the producer keeps "cond_signal"ing.
My question is, does the signals queued/saved, so when the consumer finishes handling the message and return to the "wait" it would immediately return or do they get "lost"?
Do you propose any other scheme for this problem?

Producer {
//fast frequency

Consumer {
// very slow handling

Thank you and best regards,

Eviatar Khen
Old 03-08-2012, 11:57 AM   #2
Registered: Sep 2011
Posts: 96

Rep: Reputation: 15
Hi Eviatar

I think in Linux, signal is queued, not lost.

But anyway, in your scenario, I think you don't need to wake up consumer too often. Why not implement something like ring buffer, where the producer keep adding new stuffs at the head, and consumer simply "eat" anything at the tail? And it will stop when tail==head. When it does happen, it means no more new stuffs added and consumer may sleep for certain interval.

Hope it helps...


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Producer and Consumer problem teesha Linux - Kernel 1 02-26-2012 11:58 PM
Producer / Consumer Shared Data: semaphores, kernel threads? jhwilliams Linux - Kernel 1 12-04-2011 12:59 PM
script to sync producer consumer application. ufmale Programming 2 06-08-2010 09:55 AM
Producer & Consumer issue with php on mysql ufmale Programming 3 03-13-2008 02:08 AM > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 07:59 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration