Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
If processor A were clocked slightly earlier than processor B (assuming both have the same clock rate) then A could set a flag which B would have to check.How will one wait for the other, i mean, it firstly needs to know it should wait.
That's why I suggested a double check using different delays for A and B. On the second check, the processor with the longer delay would find it unavailable.if both Read the Value at the same time, or one slightly after another, then they will both read it's available.
The first thing you need is shared memory that is coherent across all processors (not cached) then you need the equivalent atomic compare-and-swap instruction on both processors to create a token.
https://en.wikipedia.org/wiki/Compare-and-swap
int compare_and_swap(int* reg, int oldval, int newval)
{
ATOMIC();
int old_reg_val = *reg;
if (old_reg_val == oldval)
*reg = newval;
END_ATOMIC();
return old_reg_val;
}
Hi nsapook.
Thank you very much.
I read about the Compare-and-Swap operation,
However, it deals with different processes running on the same processor.
It's not the same as different processes on different processor.
As of 2013, most multiprocessor architectures support CAS in hardware. As of 2013, the compare-and-swap operation is the most popular synchronization primitive for implementing both lock-based and non-blocking concurrent data structures.[1]
Hi,
Could you please suggest on such mechanism for arbitration?
alec_t
yes, they both have the same priority.
How will one wait for the other, i mean, it firstly needs to know it should wait.