Presentation is loading. Please wait.

Presentation is loading. Please wait.

An algorithm of Lock-free extensible hash table Yi Feng.

Similar presentations


Presentation on theme: "An algorithm of Lock-free extensible hash table Yi Feng."— Presentation transcript:

1 An algorithm of Lock-free extensible hash table Yi Feng

2 Extensible hash table 0 1 2 3 5 6 7 4 0 17 11 10 9 7 14 488 4 Let L= 2. Maximum items = L* size. So when we insert 8.

3 Lock-free extensible hash table Why is hard to implement lock-free extensible hash table ? In single CAS operation, it seems impossible move the items from one linked list and insert it into new bucket. Items may lost.

4 Solution for Lock-free extensible hash table We will NOT move items among the buckets Move buckets among items.

5 Split-ordered list: Lock-free extensible hash table We keep all the items in one lock- free linked list. We reverse the bits of the hash key and order the keys by their bit-reversed value. And each bucket gradually has a dummy node that just reverse the bucket number.

6 How Recursive Split-ordering works 0 1 2 3 913 8 0 213 2 7 0000..0 0010..1 0100..0 1001..10100..1 1000..01100..0 1011..0 1110..0 We now have a sorted list in which the order is determined by the key’s bit-reversed value.

7 When extending 0 1 2 3 913 8 0 213 2 0000..0 0010..1 0100..0 1001..10100..1 1000..01100..0 1011..1 5 6 7 4 7 We want to insert 5. 1010..1 is the bit-reserved value. 1110..1 0000..0 0010..1 0100..0 1001..10100..1 1000..01100..0 1011..11110..1 5 1010..0 5 1010..1

8 Data type and private variables

9 CAS operation CAS(Compare&Swap) is an ATOMIC operation. Input: it takes three arguments: the address of a memory location, an expected value a new value. If the memory location holds the expected value, it is assigned the new value atomically. Output: Boolean return value indicates whether the replacement occurred.

10 Insert function

11 Find function

12 Delete function

13 Initialization Bucket

14 Linearizability A history is linearizable if: 1. its invocations and responses can be reordered to yield a sequential history. 2. that sequential history is correct according to the sequential definition of the object. 3. if a response preceded an invoke in the original history, it must still precede it in the sequential reordering. A history is a sequence of invokes and responses made of an object by a set of threads. A sequential history is one in which all invocations have immediate responses.

15 Linearizability An object is linearizable if all valid histories of its use can be linearized. IT IS HARD TO PROVE. All function calls have a linearization point at some instant between their invoke and response. All functions appear to occur instantly at their linearization point, behaving as specified by the sequential definition. We have an equivalent definition:

16 Linearizability For insert operation, the linearization point is in line I5, at list_insert operation. That means, if key is in H in line I5, then insert will fails, otherwise it will be inserted and join to set H. For find operation, the linearization point is in line S4, at list_find operation. That means, if key is in H in line S4, then find will return true and otherwise it will return false. For delete operation, the linearization point is in line D4, at list_delete operation. That means, if key in the H in line D4, it will removed and otherwise deletion will fails. Let H be the set of keys beginning with the pointer T[0]

17 Michael’s lock-free linked list

18 Insertion function A3 is the linearization point.

19 Delete function B2 is the linearization point.

20 Find function Find function guarentees there is a moment *prev is part of list, *prev = and if cur is not null and cur^. = and cur^.Key was the lowest the key value that is greater than or equal to the input key. The linearization point is the lasting reading of cur^ at line D3 by the current thread.

21 Questions?


Download ppt "An algorithm of Lock-free extensible hash table Yi Feng."

Similar presentations


Ads by Google