Lecture 11: And More Linearizability and Progress

Overview

1. Counter, Revisited, Again
2. Progress Condiditions

A Counter

public class TwoCounter {
int[] counts = new int;

public void increment (int amt) {
int count = counts[i];
counts[i] = count + amt;
}

int count = counts;
count = count + counts;
return count;
}
}

Is TwoCounter Linearizable?

public class TwoCounter {
int[] counts = new int;

public void increment (int amt) {
int count = counts[i];
counts[i] = count + amt;
}

int count = counts;
count = count + counts;
return count;
}
}

Linearization Point?

int count = counts;
count = count + counts;
return count;
}

public class ThreeCounter {
int[] counts = new int;

public void increment (int amt) {
int i = ThreadID.get(); // thread IDs are 0, 1, and 2
int count = counts[i];
counts[i] = count + amt;
}

int count = counts;
count = count + counts;
count = count + counts;
return count;
}
}

Is ThreeCounter Linearizable?

Is ThreeCounter Linearizable?

int count = counts;
count = count + counts;
count = count + counts;
return count;
}

Conclusion

• Linearizability is…
• …a reasonable correctness condition
• …nonblocking
• …compositional

You will work through more problems on linearizability on Homework 3 and Quiz 3.

Progress Conditions

Is Nonblocking Property Practical?

Nonblocking property $\implies$ existence of consistent response to pending method calls

• Does not ensure that such a response can be found easily

Scheduler

Given a set of (concurrent) method calls a scheduler chooses sequence of methods that make steps

• in computers, OS is typically scheduler
• scheduler may be fair, may not be
• want progress guarantees independent of scheduler

Nonblocking Progress Conditions

Conditions for implementations:

• Wait-freedom: pending method invocation always completes in a finite number of steps
• Lock-freedom: among all pending method calls, some method completes in a finite number of steps

Question

Is TwoCounter lock-fee? Wait-free?

public class TwoCounter {
int[] counts = new int;

public void increment (int amt) {