Biased Locking && Bulk Rebiasing
也是老东西了…以前没有整理记录的习惯,哎。
- Early research utilized property that mostsynchronization in Java language is uncontended.
- not only uncontended,but unshared
- Most objects locked / unlocked by exactly one thread inthe object’s lifetime
- Avoid creation of mutex/condvar per Java object. ——不是完全免费的
- Compare-and-swap / compare and exchange
- “Inflate” to full heavyweight monitor if contention detected
- Previous:
- First thread locking the object reserves the lock with an atomic operation
- Subsequent locks / unlocks by that thread use no atomic operations
- Recursion count in object header detects IllegalMonitorStateException
- Using non-atomic stores
- If another thread locks the object, relativelyexpensive unreservation required
- Involves sending signal to reservation owner thread
- Ensures reservation owner thread not performing concurrent non-atomic stores
- First thread locking the object reserves the lock with an atomic operation
- New
- Store-Free Biased Locking
- Bulk rebiasing and bulk revocation
- Epoch-based bulk rebiasing