|
|
|
|
|
by siddcoder
3376 days ago
|
|
The point is that overhead of locking is too much when the contention on the shared structure is fairly less. The cost of locking/unlocking/blocking/waiting or any other work done as part of enforcing synchronization is something that can be optimized away if the contention on the data structure is less. By contention, I imply -- contention or conflicts on the same portions/pieces of structure. If the data structure is subject to high concurrent access but in fairly disjoint regions of the data structure, we should try to implement fine grained locking scheme to increase the degree of parallelism and thus the scalability of data structure. This is where CAS comes into picture. The article doesn't compare CAS to another locking primitive. Instead, CAS is just used as a mechanism to implement fine grained locking scheme where the methods operating on the data structure don't take global or coarse locks. If the contention on the entire data structure is unreasonably high for some reason, then CAS based approaches or any flavors of it don't buy us much. |
|