Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4044752
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T13:19:50+00:00 2026-05-20T13:19:50+00:00

I want to implement a one-producer, multiple-consumer model with shared memory in Unix Producer:

  • 0

I want to implement a one-producer, multiple-consumer model with shared memory in Unix
Producer: put the data frame(~char[1024]) in a memory segment
Consumers: memcpy the data into its own private memory and do some processing

Some relevant info:

  1. It is okay for consumer to miss some data frame
  2. Consumers are independent, eg. It’s okay if one consumer only gets data 1,2,4, and another gets 2,3,5
  3. About 10 consumers will be running at the same time
  4. Producer can generate data faster than consumers can process
  5. Slow/zombie consumer should not slow down the whole system
  6. Consumer will skip the memcpy if it sees the same data

I have setup the shared memory stuff, and use the pthread read-write lock, but it seems slower than using a tcp model

My question: what synchronization is best suited for this kind of model?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T13:19:51+00:00Added an answer on May 20, 2026 at 1:19 pm

    Are you sure the problem is in the synchronization model used?

    I am thinking about something else: Maybe the producer “keep the token” too long. For instance, the produced should produce the 1024 bytes in a private memory and keep the shared memory just for writing down the new data?

    Be sure the critical section is as small as possible.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a nice interface, and I want to implement one member of it
I want to implement this view But I have one question: The text which
I want to implement singleten design pattern in iphone code I have one array.
I have a class that instantiates two classes which implement interfaces. I want one
given this class definition: public class Frame { IFrameStream CapturedFrom; } I want implement
I want to implement a Producer - Consumers pattern using a ThreadPool for the
I am working on WinForms. Now I want to implement one thing: when I
I want to implement some kind of message bus in one of my Scala
I want to implement a regex matching function in javascript that matches one or
I want to implement layering of screens when transitioning from one screen to another.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.