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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T03:54:33+00:00 2026-06-04T03:54:33+00:00

On SMP machines is there a performance benefit to #2 vs #1: 1) x

  • 0

On SMP machines is there a performance benefit to #2 vs #1:

1) x = 0;

or

2) if (x) x = 0;

I was thinking that the behind the scenes overhead to manage cache coherency between the CPUs might have some cost. Am I nuts?

  • 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-04T03:54:35+00:00Added an answer on June 4, 2026 at 3:54 am

    Even with single-threaded code, the latter can have an advantage if the object lies in copy-on-write memory (for example, a private mapping of a file, or almost any writable memory after a fork). I suspect the advantage you’re asking about is real too, at least on systems like x86 where memory consistency is handled automatically. On such machines, writing to memory that might be in another cpu’s cache will invalidate the cached copy (actually the entire cache line). Just reading won’t do any harm. Of course, if this is memory that’s potentially being modified and shared by multiple threads, it needs to be protected by synchronization mechanisms anyway, and then you probably lose most or all of the advantage.

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

Sidebar

Related Questions

How are interrupts handled on SMP (Symmeteric multiprocessor/multicore) machines? Is there only one memory
Is there smth like pthread_barrier in SMP Linux kernel? When kernel works simultaneously on
On x86 machines, instructions like inc, addl are not atomic and under SMP environment
I have the following situation: There is a windows folder that has been mounted
What's differenct between 'catch 1=0' and '(catch 1=0)'? Erlang R14B03 (erts-5.8.4) [source] [64-bit] [smp:2:2]
The Linux Kernel is said to be SMP. It is said that processes and
running Linux ubuntu 3.0.0-15-generic #26-Ubuntu SMP Fri Jan 20 17:23:00 UTC 2012 x86_64 x86_64
i want to install phusion passenger together with ruby enterprise edition on x86_64 SMP
Context: Ubuntu 11.10 and libfuse 2.8.4-1.4ubuntu1 Linux 3.0.0-14-generic #23-Ubuntu SMP Mon Nov 21 20:28:43
Very strange for me: # uname -a Linux localhost.localdomain 2.6.18-194.3.1.el5 #1 SMP Thu May

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.