An algorithm of Lock-free extensible hash table Yi Feng
Extensible hash table Let L= 2. Maximum items = L* size. So when we insert 8.
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.
Solution for Lock-free extensible hash table We will NOT move items among the buckets Move buckets among items.
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.
How Recursive Split-ordering works We now have a sorted list in which the order is determined by the key’s bit-reversed value.
When extending We want to insert is the bit-reserved value
Data type and private variables
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.
Insert function
Find function
Delete function
Initialization Bucket
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.
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:
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]
Michael’s lock-free linked list
Insertion function A3 is the linearization point.
Delete function B2 is the linearization point.
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.
Questions?