Re: How does atomic operation work on smp

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Nov 8, 2012 at 9:01 AM, Jimmy Pan <dspjmt@xxxxxxxxx> wrote:
> I understand how atomic operation work on unary core processors, I think it just disables the interrupt and dominate the cpu until it finished.
> While, how do we implement this on multi processor computers?
> Suppose cpu A is performing an atomic operation on variable a. At the same time, cpu B is also performing the operation on a. In such the result may be overwritten.
> Of course we can use spinlocks, but on the atomic operation's behalf, how does it gurantee to prevent such case?
> Can anyone explain the crux of it? Thanks.

Basically you make use of machine specific instructions that will  do
that for you.
In other words, get the datasheets of the specific system you intent
to code on/for (I assume here you are refering to assembler level
codes, as higher up you make use of the relevant libraries that does
that for you).

However, if you refer to the general case: You make use of critical
areas bounded by the necessary lock(s), like semaphores, mutex locks,
doors, message queues etc. that is described in details in several
text books on the subject of concurrency/parallelism/distributed
computing/etc.
--
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Assembler]     [Git]     [Kernel List]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [C Programming]     [Yosemite Campsites]     [Yosemite News]     [GCC Help]

  Powered by Linux