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 614059
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T18:04:16+00:00 2026-05-13T18:04:16+00:00

I have a number of data containers that can send a signal when there

  • 0

I have a number of data containers that can send a signal when there are updates in them. The structure looks similar like this:

typedef struct {
  int data;
  /*...*/
  pthread_cond_t *onHaveUpdate;
} Container;

The onHaveUpdate is a pointer to a global condition that is shared by all the containers

In my application, I have a number of these structures and they can concurrently be updated by different threads.

Now, is it possible for me to have a thread that listens to the condition and can perform something on the container that sends the notification?

I know that this can be solved by using one thread per container but it feel like a waste of resources, but I was wondering if this can be done using only one thread for all container?

  • 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-13T18:04:16+00:00Added an answer on May 13, 2026 at 6:04 pm

    The problem is that your condition is shared by all containers, so when you send the condition that something has changed, you have no idea what has changed. Since the architecture of your application is not a 100% clear from your context, why not implement a Queue which holds events (and pointers to containers are pushed onto that Queue) and a worker thread which takes events from that waitqueue and performs the work. That way your worker queue needs to wait on the condition that the queue is filled (or run in a non aggressive while-true-fashion), and that way you can remove the condition variable from your container altogether.

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

Sidebar

Related Questions

I have a defined number of servers that can locally process data in their
I understand that web containers like jboss have a parameter to mention the number
I have data that looks like this: token eps rank # first line names
We have a number of data objects that realize INotifyPropertyChanged to allow for WPF
I have a number of data files to process from a data warehouse that
I have a number of large data files that I included in projects attributed
I have a number of images and a CSV data file that I want
I have multiple number of divs that varies depending on the data it is
We have a number of plugin applications that can all run independently but also
I have a data field that contains large numbers in two formats: 553000.468...705.46.0000000 <-

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.