locked
64 Bit access on 32 bit Windows RRS feed

  • Question

  • From MSDN : Reads and writes to 64-bit values are not guaranteed to be atomic on 32-bit Windows.

    So every 64 bit variable has to be protected using Interlocked operation, so that the program will run perfectly on 32 bit Windows Machine?

    Monday, June 1, 2015 9:36 PM

Answers

  • true, but that only matters if you have two threads competing with reads and writes simultaneously.

    d -- This posting is provided "AS IS" with no warranties, and confers no rights.

    • Marked as answer by Boomi.s Tuesday, June 2, 2015 12:08 AM
    Monday, June 1, 2015 11:59 PM
  • For single-threaded applications, you can count on 64-bit words being modified atomically. For multi-threaded applications, you may need to synchronize access of multiple threads are trying to access/modify the word simultaneously. But that applies to 32-bit words, or buffers, or any other type of data.

    You seem to be confused by what you read. Perhaps if you provided a link where you read this we could provide some context.

    • Marked as answer by Boomi.s Tuesday, June 2, 2015 12:08 AM
    Tuesday, June 2, 2015 12:00 AM

All replies

  • Why would you think this.  All the statement is indicating is that a 64-bit value maybe accessed as two 32-bit reads or writes.  For almost everything this has no impact.  It can represent a challenge for some poorly designed hardware.  Of course you still to worry about access of shared data, but that is the case no matter how it is read or written.


    Don Burn Windows Driver Consulting Website: http://www.windrvr.com

    Monday, June 1, 2015 9:44 PM
  • I agree it can be accessed as two 32 bit reads/writes on 32 bit machine, but the whole 64 bit will be updated atomically? I mean to say between these two operation anything can happen, that prevents one portion of the variable holding old value.
    Monday, June 1, 2015 11:17 PM
  • true, but that only matters if you have two threads competing with reads and writes simultaneously.

    d -- This posting is provided "AS IS" with no warranties, and confers no rights.

    • Marked as answer by Boomi.s Tuesday, June 2, 2015 12:08 AM
    Monday, June 1, 2015 11:59 PM
  • For single-threaded applications, you can count on 64-bit words being modified atomically. For multi-threaded applications, you may need to synchronize access of multiple threads are trying to access/modify the word simultaneously. But that applies to 32-bit words, or buffers, or any other type of data.

    You seem to be confused by what you read. Perhaps if you provided a link where you read this we could provide some context.

    • Marked as answer by Boomi.s Tuesday, June 2, 2015 12:08 AM
    Tuesday, June 2, 2015 12:00 AM
  • Got it. 

    Thanks.

    Tuesday, June 2, 2015 12:11 AM