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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T19:50:10+00:00 2026-06-05T19:50:10+00:00

Say the broadcasting thread broadcasts while only 3 threads are waiting and the 4th

  • 0

Say the broadcasting thread broadcasts while only 3 threads are waiting and the 4th thread call pthread_cond_wait after the broadcasting thread is done with broadcast, will the 4th thread ever get out of the waiting condition. And how is the condition variable reset, so that the broadcasting thread can rebroadcast sometimes later to the waiting threads.

  • 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-05T19:50:12+00:00Added an answer on June 5, 2026 at 7:50 pm

    will the 4th thread ever get out of the waiting condition

    No, not until there’s another broadcast or signal.

    And how is the condition variable reset, so that the broadcasting
    thread can rebroadcast sometimes later to the waiting threads.

    It’s simplest to imagine that everything that a condition variable does, is synchronized under the mutex associated with the condition variable. So at the time you broadcast, everything waiting is (somehow) put into a state where it is trying to wake up and take the mutex. Then, the broadcasting thread releases the mutex. So it’s not really the condition variable that’s “reset” when you broadcast, it’s the first three threads that are moved from waiting on the condition variable, to waiting on the mutex.

    In order to wait on the condvar, your 4th thread must first acquire the mutex. This might happen before or after the first three threads manage to wake up and take the mutex, but it clearly happens after the broadcast, and so your 4th thread is not in “trying to wake up” state, it’s in “waiting for a signal or broadcast” state.

    Actually it’s more complicated than that — you don’t actually have to hold the mutex in order to broadcast a condition variable. So condition variables must include some additional internal synchronization (I don’t know the specific details on linux), to make sure that all threads waiting before the broadcast get their state changed as a single operation.

    Normally you might as well hold the mutex to broadcast, though, because you broadcast when you’ve just changed something that waiters want to see, and whatever that thing is that’s looked at from lots of threads, is synchronized using the mutex. And there are a couple of awkward situations that you can avoid by always doing it that way.

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

Sidebar

Related Questions

Say I want to test this module: import osutils def check_ip6(xml): ib_output = osutils.call('iconfig
I have a thread that is Broadcasting UDP packets. I have another thread that
Say I need to retrieve 20 thumbnail images from Azure BLOB after a button
Say, if I don't call super.onPause in a override method from superclass Activity ,
Say my web server receives two simultaneous requests. It will handle each request in
Say I have a couple of basic objects like so: [Serializable] public class Base
Say, an application properties page with lots of JCheckboxes, JTextfields, JLists and other JComponents.
say i have a nvarchar field in my database that looks like this 1,
Say I write this: from subprocessing import Popen, STDOUT, PIPE p = Popen([myproc], stderr=STDOUT,
Say I have a class definition: class CustomClass { int member; }; Why is

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.