Enhancements to Simple Lock
Reduce frequency of issuing test&sets while waiting
- Test&set lock with backoff
- Don’t back off too much or will be backed off when lock becomes free
- Exponential backoff works quite well empirically: ith time = k*ci
Busy-wait with read operations rather than test&set
- Test-and-test&set lock
- Keep testing with ordinary load
- cached lock variable will be invalidated when release occurs
- When value changes (to 0), try to obtain lock with test&set
- only one attemptor will succeed; others will fail and start testing again