BackOff Alg functionality Flashcards
1
Q
What does a higher number of unsuccessful tries mean in a lock? what should it do incase of a backoff?
A
There is high contention
backoff longer
2
Q
Lock-step
A
When all threads backs off the same amount of time
3
Q
How should lock-step be avoided
A
threads should back off for a random amount of time
4
Q
What should a thread do if i tries and fails to get a lock?
A
double back-off time, up to a fixed max
5
Q
how does the lock look of the Backoff lock?
A
public void lock() {
int delay = MIN_DELAY;
while (true) {
while (state.get()) {}
if (!lock.getAndSet(true))
return;
sleep(random() % delay);
if (delay < MAX_DELAY)
delay = 2 * delay;
}}
6
Q
A