Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Lock-Free concurrent algorithm for Linked lists: Verification CSE-COSC6490A : Concurrent Object-Oriented Languages York University - W09 Speaker: Alexandre.

Similar presentations


Presentation on theme: "1 Lock-Free concurrent algorithm for Linked lists: Verification CSE-COSC6490A : Concurrent Object-Oriented Languages York University - W09 Speaker: Alexandre."— Presentation transcript:

1 1 Lock-Free concurrent algorithm for Linked lists: Verification CSE-COSC6490A : Concurrent Object-Oriented Languages York University - W09 Speaker: Alexandre Walzberg Date: May, 14th 2009 Paper: MikhailFomitchev and Eric Ruppert, Lock-Free Linked Lists and Skip Lists.PODC'04, 2004.

2 2Plan 1.The algorithm - reminder 2.Verification of the list content 3.Verification of the lock-free property

3 3 1. The Algorithm - reminder A C Back-link allow a thread to not start research from head if it encounter a “in deletion” node. The mark logically delete the node and avoid 1) deletion of C 2) Insertion of B’ between B and C A flag prevent any operation on the node (except the deletion of the next node) B Reminder Mark Flag

4 4 AtomicStampedReference Own: A reference to an object of class T A Stamp (integer) Getters and Setters for the reference and the stamp Atomic CAS operation which change both the reference and the stamp atomically Reading and writing on both the reference and the stamp are Volatile public boolean compareAndSet( V expectedReference, V newReference, int expectedStamp, int newStamp) 1. The Algorithm - reminder

5 5 The class Node AtomicStampedReference next 31012 Node backlink 31012 int key 31012 int value 31012 Node … … … … 31012 … Node int 1. The Algorithm - reminder

6 6 2. Verification of the list content Test done Concurrent insertion/deletion of nodes 1) with same key 2) with different key 3) with both 4) With key in reverse order Main problem test Insertion of all even keys Insertion of odd keys | Deletion of even keys For each Thread Random delay between operation Random operation (search / insert / delete) Random key values

7 7 Verification method 2. Verification of the list content Insertion of random keys 0 < k < 10 000 Array verif of 10 000 elements. Exist and Checked are Atomic Booleans Index01…9 999 ExistTrueFalse Checked Insertion : set verif [ inserted key ].exist at true Deletion : set verif [ inserted key ].exist at false Verification : 1) Verify that all elements of the list are indeed record as existing and set checked as true. 2) Verify that each element recorded has been checked.

8 8 Verification method : limitation 2. Verification of the list content We can not make insertion and deletion at the same time hence actual deletion/insertion can not be atomically with recording in the array. Instead : Insertion | insertion | insertion Rendez-Vous of all threads Deletion | Deletion | Deletion For the main problem test : Insertion of all even keys Insertion of odd keys | Deletion of even keys We can just control at the end that all even keys are absent and all odd keys are present

9 9 Pre-emption 3. Verification of the lock-free property Insertion of sleep( “random time”) into delete-group functions to force pre-emption by the scheduler in the middle of a deletion (between each step) => Test of the lock-free property and distribution of the algorithm Distribution of the algorithm Comment of all lines calling the helper in other function than Deletion functions => performance decrease a lot In additions, stopping a thread in the middle of a deletion make live-locks in other threads.

10 10 Contention 3. Verification of the lock-free property Live-lock indicator: Counting number of loop iteration in the algorithm using an Atomic Long (that we can Atomically increase). => Contention is negligible (less than 0.01 loop iteration / operation)

11 11 Live-Lock problem 3. Verification of the lock-free property In assignment 2, I had a live-lock problem. I add a CAS operation to fix the problem. However this operation was normally not required and not part of the described algorithm. During verification, I found the problem, coming from a miss-use of the Compare And Set operation. Then I could delete this extra CAS operation.

12 12 Conclusion JPF No error detected for short test program with a small amount of thread Execution too long for a big amount of thread or long test Could not find the use of JPF. Could not find any property to check using asserts (could not find easy to check invariant) Verification of the list content The verification system can handle concurrent insertion and concurrent deletion but not concurrent insertion and deletion. Verification of the lock-free property The lock-free property is respected. The algorithm distribute task amongst threads.

13 13 Any questions ?? Thank you for your attention!


Download ppt "1 Lock-Free concurrent algorithm for Linked lists: Verification CSE-COSC6490A : Concurrent Object-Oriented Languages York University - W09 Speaker: Alexandre."

Similar presentations


Ads by Google