Abstract
StampedLock, proposed in JDK 1.8, provides many interesting features, such as optimistic read locks and upgrading/downgrading locks to improve the design of concurrent programs instead of employing pure read/write locks. Existing refactorings have proposed algorithms to convert locks, but there are a few refactorings that use these promising features of StampedLock. To illustrate a possible refactoring, this paper first shows three code transformations based on StampedLock. Then, this paper presents CLOCK, an automated refactoring tool that helps developers convert the synchronized lock into the StampedLock. An algorithm for reentrance analysis is proposed for the precondition validation. The write lock, read lock, optimistic read lock, and upgrading/downgrading lock are inferred and refactored. CLOCK is evaluated with the SPECjbb2005 benchmark and two real-world applications, Xalan and FOP. A total of 66 classes are modified by searching approximately 395KSLOC and applying the refactoring, achieving an average of 22 classes per benchmark. The experimental results show that CLOCK can help developers with refactoring for StampedLock and save developer effort.
Highlights
Lock, as one of the synchronization mechanisms, is used to ensure the correctness of shared resources access in concurrent programs
This paper focuses on refactoring support for the advanced locking operations, e.g., upgrading/downgrading locks and optimistic read locks provided by StampedLock
We propose an algorithm for reentrance analysis as the precondition validation and the regulation for inferring the write lock, read lock, optimistic read lock and the upgrading/downgrading lock
Summary
As one of the synchronization mechanisms, is used to ensure the correctness of shared resources access in concurrent programs. Lock contention often leads to poor scalability and low performance, which comprise as a main challenge in the multi-core era Various synchronization mechanisms, such as software transactional memory (STM) [1], [2] and the lock-free algorithm (LFA) [3], exist for concurrent programming. Similar to ReentrantReadWriteLock, StampedLock has read and write locks by the methods asReadLock() and asWriteLock(), but it does not seem to suffer from severe starvation Both academic and industrial sectors have proposed techniques and tools for refactoring among locks in the past few years. Automated refactoring tools need to know where and how to upgrade/ downgrade a lock To meet these challenges, this paper focuses on refactoring support for the advanced locking operations, e.g., upgrading/downgrading locks and optimistic read locks provided by StampedLock.
Talk to us
Join us for a 30 min session where you can share your feedback and ask us any queries you have
Disclaimer: All third-party content on this website/platform is and will remain the property of their respective owners and is provided on "as is" basis without any warranties, express or implied. Use of third-party content does not indicate any affiliation, sponsorship with or endorsement by them. Any references to third-party content is to identify the corresponding services and shall be considered fair use under The CopyrightLaw.