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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T04:18:33+00:00 2026-06-02T04:18:33+00:00

I’ve been asked the following question and I’m not sure what the correct answer

  • 0

I’ve been asked the following question and I’m not sure what the correct answer is to it:

If monitors are implemented by replacing condition variables with semaphores 
(counters set to 0) with down() and up() as wait and signal, respectively,
would the monitors work correctly?

I’d be tempted to say it is a correct implementation because semaphores and condition variables can replace each other, correct? Is there a better explanation?

  • 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-02T04:18:34+00:00Added an answer on June 2, 2026 at 4:18 am

    You are asking about a semaphore initialized to 1, which is also called a binary semaphore.

    The answer depends on a particular implementation (or definition) of these primitives, however a typical difference is that monitors have thread ownership and semaphores do not. This impacts a variety of scenarios.

    • For a semaphore, it is completely normal that one thread does all the ups and another one does all the downs. This should not be allowed by monitors.
    • Suppose you have a class with private state and multiple public methods, all of which lock a common monitor upon entry and unlock upon exit in order to protect that state. Suppose also that public method A internally calls public method B. Then a recursive monitor will correctly allow calling method A (which involves a sequence lock-lock-unlock-unlock) whereas the same with a semaphore-implemented monitor would result in a deadlock upon the second attempt to lock, using the same thread.
    • Suppose that a thread acquires a named system wide monitor and crashes. Because of thread ownership, it is possible to automatically unlock the monitor and allow any waiting threads to acquire it. With a binary semaphore this is not possible, and such a situation will typically never resolve satisfactorily until a reboot. [Edit: Note that even in case of a mutex, the described recovery mechanism may not be desirable or enabled by default, as the state of the protected resources or data structures is basically undefined after a crash midway. The decision whether to re-acquire or to recover differently is typically left to application code.]

    So, a binary semaphore is similar to a monitor, but do not expect it to behave identically.

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

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I need a function that will clean a strings' special characters. I do NOT
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
Is it possible to replace javascript w/ HTML if JavaScript is not enabled on
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and

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.