how does the interface for registers look?
publicinterface Register<T>{
T read();
void write(T v);
}</T>
What are the types of registers usually?
either boolead or m-bit nteger
When is implementation wait-free
if every method call completes in a finite number of steps
no mutual exlusion
What are the degrees of consistency
Safe,regular,atomic
When is a register safe
Read that doesnt overlap write return last value
if overlap return any value within the registers range
when is a register regular?
if no overlap return last value
else return either new/old value
(may flicker between old + new value until done)
Regular = linearizable?
No
When is a register atomic?
when each read returns last written value
safeBoolMRSWRegister class
public class SafeBoolMRSWRegister
implements Register<Boolean> {
public boolean read() { … }
public void write(boolean x) { … }
}
(naming should be in that order)</Boolean>
A safe boolean MRSW register can be created from safe boolean SRSW register how?
Make an array of SRSW registers
Whats the difference between Safe and Regular BooleanMRSW?
only difference when new value is same as old value(safe can return either Boolean value, Regular can only return x since they are the same)
How can we use SafeBoolMRSW to build Regular BoolMRSW?
(in the RegBoolMRSW class)
private SafeBoolMRSWRegister value;
public void write(boolean x) {
if (old != x) {
value.write(x);
old = x;
}}
and then the read is just return value.read() and old is just a bool value
How does the read and write work for Regular M-Valued MRSW Register
read: read locations from lower to higher values until it reaches a value that is true
write: writes true to location x which is a regular Bool MRSW register
Read and write for RegularMRSWRegister
public class RegMRSWRegister implements Register{
RegBoolMRSWRegister[M] bit;
public void write(int x) {
this.bit[x].write(true);
for (int i=x-1; i>=0; i–)
this.bit[i].write(false);
}
public int read() {
for (int i=0; i < M; i++)
if (this.bit[i].read())
return i;
}}
What are some further conditions for a register to be regular?
no read should return a value from distant past/future. only most recent written non-overlapping value
How should the stamped value class look like?
public class StampedValue<T> {
public long stamp;
public T value;
public StampedValue (T init) {
stamp = 0;
value = init;
}
public StampedValue max (StampedValue x,StampedValue y)
{
if (x.stamp > y.stamp)
return x;
else return y;
}
}</T>
how should read + write look for Atomic SRSW register?
public T read() {
StampedValue<T> result = StampedValue.max(value,
lastRead);
lastRead = result;
return result.value;
}
public void write(T v) {
long stamp = lastStamp + 1;
value = new StampedValue(stamp, v);
lastStamp = stamp;
}</T>
What type of array does a AtomicMRSWRegister use and why
2d of stamped values. to check if any of the other registers has written to the array while the read is taking place
how does the write +read look for MRSW Atomic
public void write(T v) {
long stamp = lastStamp + 1;
lastStamp = stamp;
StampedValue<T> value = new StampedValue<T>(stamp,
v);
for (int i = 0; i < n; i++)
a_table[i][i] = value;
}</T></T>
Can you construct a wait-free MRMW atomic register from SRSW safe boolean registers?
yes