Peterson's Algorithm - Note

Note

When working at the hardware level, Peterson's algorithm is typically not needed to achieve atomic access. Some processors have special instructions, like test-and-set or compare-and-swap, that, by locking the memory bus, can be used to provide mutual exclusion in SMP systems.

Most modern CPUs reorder memory accesses to improve execution efficiency (see memory ordering for types of reordering allowed). Such processors invariably give some way to force ordering in a stream of memory accesses, typically through a memory barrier instruction. Implementation of Peterson's and related algorithms on processors which reorder memory accesses generally requires use of such operations to work correctly to keep sequential operations from happening in an incorrect order. Note that reordering of memory accesses can happen even on processors that don't reorder instructions (such as the PowerPC processor in the Xbox 360).

Most such CPUs also have some sort of guaranteed atomic operation, such as XCHG on x86 processors and Load-Link/Store-Conditional on Alpha, MIPS, PowerPC, and other architectures. These instructions are intended to provide a way to build synchronization primitives more efficiently than can be done with pure shared memory approaches.

Read more about this topic:  Peterson's Algorithm

Famous quotes containing the word note:

    The note of the white-throated sparrow, a very inspiriting but almost wiry sound, was first heard in the morning, and with this all the woods rang. This was the prevailing bird in the northern part of Maine. The forest generally was alive with them at this season, and they were proportionally numerous and musical about Bangor. They evidently breed in that State.
    Henry David Thoreau (1817–1862)

    In his very rejection of art Walt Whitman is an artist. He tried to produce a certain effect by certain means and he succeeded.... He stands apart, and the chief value of his work is in its prophecy, not in its performance. He has begun a prelude to larger themes. He is the herald to a new era. As a man he is the precursor of a fresh type. He is a factor in the heroic and spiritual evolution of the human being. If Poetry has passed him by, Philosophy will take note of him.
    Oscar Wilde (1854–1900)

    My note to you I certainly did not expect to see in print; yet I have not been much shocked by the newspaper comments upon it. Those comments constitute a fair specimen of what has occurred to me through life. I have endured a great deal of ridicule without much malice; and have received a great deal of kindness, not quite free from ridicule. I am used to it.
    Abraham Lincoln (1809–1865)