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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T16:13:28+00:00 2026-05-28T16:13:28+00:00

I remember that at some point, I saw a programming challenge where people were

  • 0

I remember that at some point, I saw a programming challenge where people were asked to atomically read a double word with single-word operations.

Now, before we go on, a few clarifications:

  • A single word is a unit that has the natural number of bits that can be processed by some processor (for instance, 32 bits for 32-bit processors);
  • A double word is a unit that is twice the size of a single word (and therefore can’t be treated at once by processor instructions);
  • By atomic, I mean that the result data should be consistent with what the value was at some point, and we can assume that no implementation or hardware detail will get in the way.

As I recall it, the solution was to read the highest word, then read the lowest word. Then read again the highest word, and if it hasn’t changed, then the value can be deemed consistent.

However, I’m not sure anymore. Suppose that we have the two digits 01.

  1. The algorithm would then read the high part (and get 0).
  2. Now, another actor changes the value to 22 before our algorithm reads the next part.
  3. We then read the low digit, 2;
  4. but then, the pesky troublemaker changes the value again, and makes it 03.
  5. We read the high part, and it’s 0. We read 02, and the algorithm deems the value consistent; but in fact, it never was 02.

Is my recollection of the conundrum correct? Is it the solution that I don’t recall correctly?

  • 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-28T16:13:29+00:00Added an answer on May 28, 2026 at 4:13 pm

    That solution sounds like it was meant for a system where the value was constantly incrementing or decrementing, rather than arbitrarily changing.

    By reading high/low/high in a system where the value is incrementing, you can be sure that the value hasn’t wrapped, such as (for a one-digit word) 0,9 becoming 1,0. The code would be something like:

    read high into reg2                 # Get high value.
    set reg0 to reg2 minus 1            # Force entry in to loop.
    while reg0 is not equal to reg2:    # Repeat until consecutive highs are same.
        set reg0 to reg2                    # Transfer high.
        read low into reg1                  # Read low.
        read high into reg2                 # Read next high.
    
    # Now reg0/reg1 contains high/low.
    

    In any other situation where the value can arbitrarily change, you need some sort of test-and-set operation on a separate word, effectively implementing a low-level mutex to protect the double-word.

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

Sidebar

Related Questions

At some point in the past, I read something that gave me the idea
I can remember that some time ago when I created a UserControl in Visual
I remember someone telling me that gzipped content is not cached on some browsers?
I remember that at one point, it was said that Python is less object
At some point in the past, in my VB6 days, I remember being able
I remember that in previous installations of Visual Studio that I had, when I
i remember that previous versions of visual studio contained a converter, that automatically attempt
I distinctly remember that, at one time, the guideline pushed by Microsoft was to
I seem to remember that Regular Expressions in DotNet have a special mechanism that
I slightly remember that there is an class which is capable of stretching an

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.