SLIDE 22 Distributed Computing Group Roger Wattenhofer 85
public abstract class public abstract class RMW { RMW { private int private int value; value; public void public void read() { read() { int int prior = prior = this. this.value; value; this. this.value = value = this. this.value; value; return return prior; prior; } }
Example: Read
identity function
Distributed Computing Group Roger Wattenhofer 86
public abstract class public abstract class RMW { RMW { private int private int value; value; public void public void TAS() { TAS() { int int prior = prior = this. this.value; value; this. this.value = value = 1; return return prior; prior; } }
Example: test&set
constant function
Distributed Computing Group Roger Wattenhofer 87
public abstract class public abstract class RMW { RMW { private int private int value; value; public void public void fai() { fai() { int int prior = prior = this. this.value; value; this. this.value = value = this. this.value+ value+1; return return prior; prior; } }
Example: fetch&inc
increment function
Distributed Computing Group Roger Wattenhofer 88
public abstract class public abstract class RMW { RMW { private int private int value; value; public void public void faa(int faa(int x) { ) { int int prior = prior = this. this.value; value; this. this.value = value = this. this.value+ value+x; return return prior; prior; } }
Example: fetch&add
addition function