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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T01:57:14+00:00 2026-06-05T01:57:14+00:00

In the context of interfacing some QT GUI thread (a pthread thread) with some

  • 0

In the context of interfacing some QT GUI thread (a pthread thread) with some C code, I stumbled over the following problem: I launch the QT Gui thread and, before my C thread resuming its path, I need to make sure that all the graphical objects inside the QT Gui thread had been constructed and they are valid QObjects (since the C code will call QObject:connect() on those).

Introduction let aside, the waiting is made through a pthread_cond_wait() + a condition variable + an associated mutex in the C thread:

int isReady=0;
pthread_mutex_lock(&conditionReady_mutex);
while(isReady==0) {
    pthread_cond_wait(&conditionReady_cv, &conditionReady_mutex);
}
pthread_mutex_unlock(&conditionReady_mutex);

On the other hand, the QT Gui thread constructs its graphical objects and then signals it with:

pthread_mutex_lock(&conditionReady_mutex);
isReady=1;
pthread_cond_broadcast(&conditionReady_cv);
pthread_mutex_unlock(&conditionReady_mutex);

Basic stuff, as you see. But the question is: in the Qt Gui thread, I’ve been using the pthread_cond_broadcast(), in order to make sure that my C thread is woken up, for sure. Yes, in my current application, I only have a C thread and a Qt Gui thread, and pthread_cond_signal() should do the job of waking up the C thread (since it is guaranteed to wake up at least one thread, and the C thread is the only one).

But, in a more general context, let’s say I have three C threads, but I want one (or two) of them to be woken up. A (two) specific thread(s). How do I ensure that?

If I use pthread_cond_signal(), that could simply wake up only the third thread, which would completely miss the point, since the one thread of interest for me is not woken up. OTOH, waking up all the threads, even those which are unneeded, through pthread_cond_broadcast(), that would be overkill.

There is a way to tell pthread_cond_signal() which thread to wake up?

Or, should I introduce more condition variables in order to have a finer granularity over the groups of threads that are woken up with pthread_cond_broadcast()?

Thank you.

  • 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-06-05T01:57:15+00:00Added an answer on June 5, 2026 at 1:57 am

    Yes, if you require a specific thread to be woken up then you either need to broadcast the wakeup, or use a separate condition variable for that thread.

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

Sidebar

Related Questions

Context: I need to develop a monitoring server that monitors some of our applications
From some page I launch a GET request to some ASHX handler that streams
Context When iterating over a set of Rdata files (each containing a character vector
I realize fast is a bit subjective so I'll explain with some context. I'm
I'm using the follow jQuery code to style some inputs based on whether they
I am trying to integrate some new code I wrote for programmatically interacting with
I have some basic jquery code sitting in the header of the header file
Context: There's an application where you draw things on canvas. Where user clicks there's
Context: We are building a framework for rapid delivery of WPF applications. This framework
Context: HTML widgets generated using a Django ModelForm and template, jQuery 1.3.2, JavaScript on

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.