Presentation is loading. Please wait.

Presentation is loading. Please wait.

Lock Free Linked List and Skip List

Similar presentations


Presentation on theme: "Lock Free Linked List and Skip List"— Presentation transcript:

1 Lock Free Linked List and Skip List
Eric Ruppert Mikhail Fomitchev

2 Concurrent Algorithm Why this Algorithm is significant :
Building blocks for many other Data structures. Better performance than earlier algorithms Problems with Mutual Exclusion: 1. delay of one process can cause performance degradation and priority inversion When halting failures occur entire system fails.

3 General Problem in lock free system
When a process is deleting node X by performing a C&S on X’s predecessor,and a concurrent operation changes X’s Right pointer results in incorrect executions Harris’s Solution Introduced Mark bits and 2-step Deletion process but still problem persists.

4 Problem with Deletion Process P1 wants to insert a node after node X
Process P2 attempts to delete node X. When P1 and P2 performs concurrent operations and suppose that,just before P1 is about to execute C&S,P2 marks node X,then P1 will fail. Then P1 has to restart from the beginning of the list which leads to poor performance.

5 Harri’s Two Step Deletion
B C A B C A B C Initial configuration 1.Marking 2.Physical Deletion Three Step Deletion in This Algorithm B A C A B C Initial configuration Step 1.Marking A B C A B C Step 2:Setting the backlink and marking Step 3:Physical Deletion

6 Key Techniques Back link pointers which points to previous node
Mark bit which is used as a toggle to indicate whether a node’s right pointer can be changed. Flag bit to indicate deletion of node is on the way and its successor is fixed. Thus when P1 finds a node marked,it traverses to its predecessor by using back link pointer and traverses until it finds an unmarked node U.Then it adds the node after U.This gives a better performance than restarting from beginning of list.

7 Algorithm Pre-requisites : The linked list is ordered by their keys
Duplicates are not allowed in the list Each node has : Key , Element , Backlink and Successor Successor has : Right pointer,Mark bit and Flag bit Insertion : 1.Calls the sub-routine SearchFrom to identify where to insert the new key. SearchFrom returns two nodes n1 and n2 such that n1.right = n2 and n1.key ≤ k < n2.key. 2.Check for duplicates and create and insert new node

8 Scenarios: prev_node may be flagged - calls HelpFlagged routine,which helps to complete the deletion and removes the flag. prev_ node got marked- Insert traverses the backlinks until it finds an unmarked node and then sets prev node to point to it (lines 17-18). In any case, in line 19 Insert invokes SearchFrom starting from prev node to find the correct location for the insertion in the updated list,and updates its prev node and next node pointers. Then Insert enters the next iteration of the loop. Deletion : 1. Calls SearchFrom, and then calls TryFlag to perform the first deletion step (flagging the predecessor). TryFlag – repeatedly attempts to flag del node’s predecessor, until the flag is placed or del node gets deleted. TryFlag returns two values: a node pointer prev node and a boolean result value.

9 Scenarios : 1.If already flagged,returns pre_node and result = false 2.If del_node already deleted,returns null and false. If prev node returned is not null,it performs second and third steps of deletion by calling try mark and help marked. Amortised cost : T(s) € O(n(s) + c(s)) S – operation , n – no of elements in list and c(s) – concurrent overhead during the opeartion S.

10 Thank You


Download ppt "Lock Free Linked List and Skip List"

Similar presentations


Ads by Google