Registers Flashcards

(20 cards)

1
Q

how does the interface for registers look?

A

publicinterface Register<T>{
T read();
void write(T v);
}</T>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What are the types of registers usually?

A

either boolead or m-bit nteger

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

When is implementation wait-free

A

if every method call completes in a finite number of steps
no mutual exlusion

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What are the degrees of consistency

A

Safe,regular,atomic

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

When is a register safe

A

Read that doesnt overlap write return last value
if overlap return any value within the registers range

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

when is a register regular?

A

if no overlap return last value
else return either new/old value
(may flicker between old + new value until done)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Regular = linearizable?

A

No

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

When is a register atomic?

A

when each read returns last written value

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

safeBoolMRSWRegister class

A

public class SafeBoolMRSWRegister
implements Register<Boolean> {
public boolean read() { … }
public void write(boolean x) { … }
}
(naming should be in that order)</Boolean>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

A safe boolean MRSW register can be created from safe boolean SRSW register how?

A

Make an array of SRSW registers

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Whats the difference between Safe and Regular BooleanMRSW?

A

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 well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

How can we use SafeBoolMRSW to build Regular BoolMRSW?

A

(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 well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

How does the read and write work for Regular M-Valued MRSW Register

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Read and write for RegularMRSWRegister

A

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;
}}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What are some further conditions for a register to be regular?

A

no read should return a value from distant past/future. only most recent written non-overlapping value

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

How should the stamped value class look like?

A

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>

17
Q

how should read + write look for Atomic SRSW register?

A

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>

18
Q

What type of array does a AtomicMRSWRegister use and why

A

2d of stamped values. to check if any of the other registers has written to the array while the read is taking place

19
Q

how does the write +read look for MRSW Atomic

A

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>

20
Q

Can you construct a wait-free MRMW atomic register from SRSW safe boolean registers?