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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T02:33:32+00:00 2026-06-17T02:33:32+00:00

I need CAS functions to use in a context of multiple threads running on

  • 0

I need CAS functions to use in a context of multiple threads running on the same CPU (assume that all threads are statically glued to selected CPU, via SetThreadAffinityMask).

InterlockedCompareExchange generates LOCK CMPXCHG. The LOCK part comes with side effects such as a cache miss, a bus lock and a potential for contention with other CPU, all of which are nice, but feel like an extravagant excess given the circuimstances. Since the competing threads run on the same CPU, I assume the LOCK can be dropped, and I further assume it should result in improved performance.

So this is my first question – do I assume correctly?

—

I know how to generate CMPXCHG with inline assembly for 32-bit version. Also, as per this SO thread I know how to do for 64-bit version too, but as a function call.

What I don’t understand, and this is my second question, is how to generate an inlined version of it.

—

Thanks.

  • 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-17T02:33:33+00:00Added an answer on June 17, 2026 at 2:33 am

    Not to answer my own question, but to describe a workaround, of sorts.

    For CAS on boolean variables, it’s possible to fall back to _bittestandset, which is slower than CMPXCHG, but has an intrinsic form in VS2010.

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

Sidebar

Related Questions

I need to deploy .NET framework 4 to all the domain User computers that
Need help with a query that I wrote: I have three tables Company id
I intend to write a function in TI-BASIC on my CAS calculator that takes
I use threads in C as follows: pthread_t thread; if (pthread_create (& thread, NULL,
I already have an grails web application, And our project need CAS, however I
How would I mimic Google's multiple sign-in in my Rails app? Essentially, I need
I need a little utility function that generates a checksum from an array of
I'm trying to implement an octree, and for that, I need a fast AABB-ray
I need to find a way that the target of a header() redirect can
I am making a program where one of the problems is that I need

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.