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

  • Home
  • SEARCH
  • 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 8995301
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T23:36:06+00:00 2026-06-15T23:36:06+00:00

Scenario 1: release mutex then wait Scenario 2: wait and then release mutex Trying

  • 0

Scenario 1: release mutex then wait
Scenario 2: wait and then release mutex

Trying to understand conceptually what it does.

  • 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-15T23:36:07+00:00Added an answer on June 15, 2026 at 11:36 pm

    If the mutex were released before the calling thread is considered “blocked” on the condition variable, then another thread could lock the mutex, change the state that the predicate is based on, and call pthread_cond_signal without the waiting thread ever waking up (since it’s not yet blocked). That’s the problem.

    Scenario 2, waiting then releasing the mutex, is internally how any real-world implementation has to work, since there’s no such thing as an atomic implementation of the necessary behavior. But from the application’s perspective, there’s no way to observe the thread being part of the blocked set without the mutex also being released, so in the sense of the “abstract machine”, it’s atomic.

    Edit: To go into more detail, the real-world implementation of a condition variable wait generally looks like:

    1. Modify some internal state of the condition variable object such that the caller is considered to be part of the blocked set for it.
    2. Unlock the mutex.
    3. Perform a blocking wait operation, with the special property that it will return immediately if the state of the condition variable object from step 1 has changed due to a signal from any other thread.

    Thus, the act of “blocking” is split between two steps, one of which happens before the mutex is unlocked (gaining membership in the blocked set) and the other of which happens after the mutex is unlocked (possibly sleeping and yielding control to other threads). It’s this split that’s able to make the “condition wait” operation “atomic” in the abstract machine.

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

Sidebar

Related Questions

I'm trying to understand media.release and have a specific scenario which I'm unsure if
Here's my question: Does calling free or delete ever release memory back to the
I have read http://logging.apache.org/log4net/release/config-examples.html and understand that we can store logs in SQL Server
Scenario I want to release an app for Mac OS X, but not on
I have the following scenario: class1 methodA NSMutableArray *myArray=[[NSMutableArray alloc]init]; [class2 methodB:myArray]; [myArray release];
Scenario : I'll try to put an analogy with the loan broker example from
Scenario first :- I'm using Entity Framework to do some queries, to build my
Scenario: There is a website with 700-900 concurrent unique visitors at any given time.
Scenario: On the github exists the user guru and his primamy repository for the
Scenario While using the Maven Ant Task artifact:deploy , I'm encountering the error java.lang.OutOfMemoryError:

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.