A Java Implementation of a Lock Free Concurrent
- Slides: 16
A Java Implementation of a Lock. Free Concurrent Priority Queue Bart Verzijlenberg November 15, 2007
Agenda n n n Algorithm Review Implementation Java Package used Testing Conclusion Questions November 15, 2007 1
Algorithm Review n n n Priority Queue Lock-free Relies on atomic Compare and Swap operations November 15, 2007 2
Algorithm Review n The algorithm uses the Skip-List data structure n n n Extends the Skip-List for concurrent use The Skip-List is sorted on the priority of the nodes The algorithm is lock-free n n No blocking Prevent dead locks Always progress by at least one operation Risk of starvation November 15, 2007 3
Algorithm Review Skip-List n n n Multi-layer linked list Probabilistic alternative to balanced trees H forward pointer for a node of height h Each pointer i points to the next node with a height of at least i Probabilistic time complexity log(N) for N nodes November 15, 2007 4
Inserting in a Skip-List Inserting 17 in the list November 15, 2007 5
Implementation n Two classes n Node n n Represents an entry in the queue Skip. Queue n Contains the algorithm logic November 15, 2007 6
Node Class November 15, 2007 7
Skip. Queue Class November 15, 2007 8
Java Package Used n Atomic. Markable. Reference n n Stores n n n In Java. util. concurrent. atomic A reference to an object A boolean flag Provides ability to n n Atomically set both the flag and reference Compare and Swap (CAS) the flag and reference November 15, 2007 9
Testing n Multi-threaded n 10 insert threads n n Each inserting 100, 000 objects with random integer keys 10 delete threads Each deleting while the queue is not empty n If the queue is empty, sleep for a bit and try again n November 15, 2007 10
Testing n Maintain a counter n n Stores the number of nodes dequeued When 1, 000 nodes removed Stop the delete threads n Check that n the queue is empty n removed exactly 1, 000 nodes n November 15, 2007 11
Testing n 10 insert threads n n Each inserting 100, 000 random integer numbers When all numbers have been inserted Remove them one at a time. n Making sure the nodes come out sorted n November 15, 2007 12
Removing Atomicity n Do atomic references make a difference n n Replace each Atomic. Markable. Reference with a similar class n n n i. e. does concurrency come into play, or are we just lucky Same functions But they are not atomic The queue becomes locked after a small number of concurrent deletes. November 15, 2007 13
Conclusion n Further testing is needed to verify the correctness of the implementation Tests so far are positive But cannot be certain there are no problems November 15, 2007 14
Questions November 15, 2007
- Java lock free
- Locks in dbms
- Lock_do_i_hold
- Lock free synchronization
- Lock free ring buffer
- Lock free linked list
- Lock free doubly linked list
- Rsa algorithm in java
- Gibbs free energy equation
- Negative free energy change
- How to calculate delta g
- A free map determines which blocks are free, allocated.
- Helmholtz free energy
- Free hearts free foreheads you and i are
- The story of an hour summary
- Free free absorption
- Java se development kit free