I would like to perform and atomic read of 64b aligned 64b data on x86 platform (Pentium or above guaranteed).
Is there a way to do this? (And no, I do not want to use a critical section or a mutex for this, I want this to be lock-free).
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
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.
Use the Interlocked operations, here’s some sample code:
This does the compare exchange against zero and sets p to zero if it’s already equal to zero -ie, it’s a noop. InterlockedCompareExchange returns the original 64 bit value pointed to by p.