concurrent singly-linked lists - york university · singly-linked lists insertion deletion...

53
CSE6490A Presentation Amgad Rady Introduction Singly-Linked Lists Insertion Deletion Concurrent SLL’s Concurrency Primitives Naïve Implementation of Concurrent SLL’s Harris’s algorithm F&R’s Algorithm Conclusion Concurrent Singly-Linked Lists Amgad Rady DisCoVeri Group Department of Electrical Engineering and Computer Science York University November 5, 2015

Upload: others

Post on 25-Jul-2020

9 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Concurrent Singly-Linked Lists - York University · Singly-Linked Lists Insertion Deletion Concurrent SLL’s Concurrency Primitives Naïve Implementation of Concurrent SLL’s Harris’s

CSE6490APresentation

Amgad Rady

IntroductionSingly-Linked Lists

Insertion

Deletion

ConcurrentSLL’sConcurrencyPrimitives

NaïveImplementation ofConcurrent SLL’s

Harris’salgorithm

F&R’sAlgorithm

Conclusion

Concurrent Singly-Linked Lists

Amgad Rady

DisCoVeri GroupDepartment of Electrical Engineering and Computer Science

York University

November 5, 2015

Page 2: Concurrent Singly-Linked Lists - York University · Singly-Linked Lists Insertion Deletion Concurrent SLL’s Concurrency Primitives Naïve Implementation of Concurrent SLL’s Harris’s

CSE6490APresentation

Amgad Rady

IntroductionSingly-Linked Lists

Insertion

Deletion

ConcurrentSLL’sConcurrencyPrimitives

NaïveImplementation ofConcurrent SLL’s

Harris’salgorithm

F&R’sAlgorithm

Conclusion

Outline

1 IntroductionSingly-Linked ListsInsertionDeletion

2 Concurrent SLL’sConcurrency PrimitivesNaïve Implementation of Concurrent SLL’s

3 Harris’s algorithm

4 F&R’s Algorithm

5 Conclusion

Page 3: Concurrent Singly-Linked Lists - York University · Singly-Linked Lists Insertion Deletion Concurrent SLL’s Concurrency Primitives Naïve Implementation of Concurrent SLL’s Harris’s

CSE6490APresentation

Amgad Rady

IntroductionSingly-Linked Lists

Insertion

Deletion

ConcurrentSLL’sConcurrencyPrimitives

NaïveImplementation ofConcurrent SLL’s

Harris’salgorithm

F&R’sAlgorithm

Conclusion

Introduction to Singly-Linked Lists

Why implement concurrent singly-linked lists?SLL’s are used to implement many abstract data types(LIFO and FIFO queues, disjoint sets.)SLL’s are themselves part of larger data structures(hash tables, skip lists.)SLL’s are simple.

Page 4: Concurrent Singly-Linked Lists - York University · Singly-Linked Lists Insertion Deletion Concurrent SLL’s Concurrency Primitives Naïve Implementation of Concurrent SLL’s Harris’s

CSE6490APresentation

Amgad Rady

IntroductionSingly-Linked Lists

Insertion

Deletion

ConcurrentSLL’sConcurrencyPrimitives

NaïveImplementation ofConcurrent SLL’s

Harris’salgorithm

F&R’sAlgorithm

Conclusion

Introduction to Singly-Linked Lists

Why implement concurrent singly-linked lists?SLL’s are used to implement many abstract data types(LIFO and FIFO queues, disjoint sets.)SLL’s are themselves part of larger data structures(hash tables, skip lists.)SLL’s are simple.

Page 5: Concurrent Singly-Linked Lists - York University · Singly-Linked Lists Insertion Deletion Concurrent SLL’s Concurrency Primitives Naïve Implementation of Concurrent SLL’s Harris’s

CSE6490APresentation

Amgad Rady

IntroductionSingly-Linked Lists

Insertion

Deletion

ConcurrentSLL’sConcurrencyPrimitives

NaïveImplementation ofConcurrent SLL’s

Harris’salgorithm

F&R’sAlgorithm

Conclusion

Introduction to Singly-Linked Lists

Why implement concurrent singly-linked lists?SLL’s are used to implement many abstract data types(LIFO and FIFO queues, disjoint sets.)SLL’s are themselves part of larger data structures(hash tables, skip lists.)SLL’s are simple.

Page 6: Concurrent Singly-Linked Lists - York University · Singly-Linked Lists Insertion Deletion Concurrent SLL’s Concurrency Primitives Naïve Implementation of Concurrent SLL’s Harris’s

CSE6490APresentation

Amgad Rady

IntroductionSingly-Linked Lists

Insertion

Deletion

ConcurrentSLL’sConcurrencyPrimitives

NaïveImplementation ofConcurrent SLL’s

Harris’salgorithm

F&R’sAlgorithm

Conclusion

Introduction to Singly-Linked Lists

Why implement concurrent singly-linked lists?SLL’s are used to implement many abstract data types(LIFO and FIFO queues, disjoint sets.)SLL’s are themselves part of larger data structures(hash tables, skip lists.)SLL’s are simple.

Page 7: Concurrent Singly-Linked Lists - York University · Singly-Linked Lists Insertion Deletion Concurrent SLL’s Concurrency Primitives Naïve Implementation of Concurrent SLL’s Harris’s

CSE6490APresentation

Amgad Rady

IntroductionSingly-Linked Lists

Insertion

Deletion

ConcurrentSLL’sConcurrencyPrimitives

NaïveImplementation ofConcurrent SLL’s

Harris’salgorithm

F&R’sAlgorithm

Conclusion

SLL Operations: INSERT

Inserting the node containing 2 into the list 1,3,4. First,find the appropriate successor for 2 by searching the listfrom the head.

1

2

3 4

Page 8: Concurrent Singly-Linked Lists - York University · Singly-Linked Lists Insertion Deletion Concurrent SLL’s Concurrency Primitives Naïve Implementation of Concurrent SLL’s Harris’s

CSE6490APresentation

Amgad Rady

IntroductionSingly-Linked Lists

Insertion

Deletion

ConcurrentSLL’sConcurrencyPrimitives

NaïveImplementation ofConcurrent SLL’s

Harris’salgorithm

F&R’sAlgorithm

Conclusion

SLL Operations: INSERT

Inserting the node containing 2 into the list 1,3,4. Next,swing the pointer from the predecessor (1) to the node (2).

1

2

3 4

Page 9: Concurrent Singly-Linked Lists - York University · Singly-Linked Lists Insertion Deletion Concurrent SLL’s Concurrency Primitives Naïve Implementation of Concurrent SLL’s Harris’s

CSE6490APresentation

Amgad Rady

IntroductionSingly-Linked Lists

Insertion

Deletion

ConcurrentSLL’sConcurrencyPrimitives

NaïveImplementation ofConcurrent SLL’s

Harris’salgorithm

F&R’sAlgorithm

Conclusion

SLL Operations: DELETE

Deleting the node containing 2 from the list 1,2,3,4. First,find the node’s predecessor by searching the list from thehead.

1 2 3 4

Page 10: Concurrent Singly-Linked Lists - York University · Singly-Linked Lists Insertion Deletion Concurrent SLL’s Concurrency Primitives Naïve Implementation of Concurrent SLL’s Harris’s

CSE6490APresentation

Amgad Rady

IntroductionSingly-Linked Lists

Insertion

Deletion

ConcurrentSLL’sConcurrencyPrimitives

NaïveImplementation ofConcurrent SLL’s

Harris’salgorithm

F&R’sAlgorithm

Conclusion

SLL Operations: DELETE

Deleting the node containing 2 from the list 1,2,3,4.Next, swing (2)’s predecessor’s pointer to (2)’s successor.

1 2 3 4

Page 11: Concurrent Singly-Linked Lists - York University · Singly-Linked Lists Insertion Deletion Concurrent SLL’s Concurrency Primitives Naïve Implementation of Concurrent SLL’s Harris’s

CSE6490APresentation

Amgad Rady

IntroductionSingly-Linked Lists

Insertion

Deletion

ConcurrentSLL’sConcurrencyPrimitives

NaïveImplementation ofConcurrent SLL’s

Harris’salgorithm

F&R’sAlgorithm

Conclusion

Concurrent SLL’s

Sequential singly-linked lists are a very simple datastructure.We would like to be able to “lift” SLL’s into a concurrentsetting without using expensive abstractions like locks,semaphores, monitors, etc.In addition to being costly, these abstractions do nothave the property of lock-freedom.

Page 12: Concurrent Singly-Linked Lists - York University · Singly-Linked Lists Insertion Deletion Concurrent SLL’s Concurrency Primitives Naïve Implementation of Concurrent SLL’s Harris’s

CSE6490APresentation

Amgad Rady

IntroductionSingly-Linked Lists

Insertion

Deletion

ConcurrentSLL’sConcurrencyPrimitives

NaïveImplementation ofConcurrent SLL’s

Harris’salgorithm

F&R’sAlgorithm

Conclusion

Concurrent SLL’s

Sequential singly-linked lists are a very simple datastructure.We would like to be able to “lift” SLL’s into a concurrentsetting without using expensive abstractions like locks,semaphores, monitors, etc.In addition to being costly, these abstractions do nothave the property of lock-freedom.

Page 13: Concurrent Singly-Linked Lists - York University · Singly-Linked Lists Insertion Deletion Concurrent SLL’s Concurrency Primitives Naïve Implementation of Concurrent SLL’s Harris’s

CSE6490APresentation

Amgad Rady

IntroductionSingly-Linked Lists

Insertion

Deletion

ConcurrentSLL’sConcurrencyPrimitives

NaïveImplementation ofConcurrent SLL’s

Harris’salgorithm

F&R’sAlgorithm

Conclusion

Concurrent SLL’s

Sequential singly-linked lists are a very simple datastructure.We would like to be able to “lift” SLL’s into a concurrentsetting without using expensive abstractions like locks,semaphores, monitors, etc.In addition to being costly, these abstractions do nothave the property of lock-freedom.

Page 14: Concurrent Singly-Linked Lists - York University · Singly-Linked Lists Insertion Deletion Concurrent SLL’s Concurrency Primitives Naïve Implementation of Concurrent SLL’s Harris’s

CSE6490APresentation

Amgad Rady

IntroductionSingly-Linked Lists

Insertion

Deletion

ConcurrentSLL’sConcurrencyPrimitives

NaïveImplementation ofConcurrent SLL’s

Harris’salgorithm

F&R’sAlgorithm

Conclusion

Lock-freedom

Definition (Lock-freedom)

An algorithm is lock-free if at any configuration in anexecution of the algorithm, if there is at least one processorthat has not crashed then some processor will finish itsoperation in a finite number of steps.

Page 15: Concurrent Singly-Linked Lists - York University · Singly-Linked Lists Insertion Deletion Concurrent SLL’s Concurrency Primitives Naïve Implementation of Concurrent SLL’s Harris’s

CSE6490APresentation

Amgad Rady

IntroductionSingly-Linked Lists

Insertion

Deletion

ConcurrentSLL’sConcurrencyPrimitives

NaïveImplementation ofConcurrent SLL’s

Harris’salgorithm

F&R’sAlgorithm

Conclusion

Concurrent SLL’s cont.

Can we construct a concurrent implementation of SLL’susing only COMPARE & SWAP?Yes! But it’s very difficult.Let’s consider a naïve implementation replacing READ’sand WRITES’s with COMPARE & SWAP.

Page 16: Concurrent Singly-Linked Lists - York University · Singly-Linked Lists Insertion Deletion Concurrent SLL’s Concurrency Primitives Naïve Implementation of Concurrent SLL’s Harris’s

CSE6490APresentation

Amgad Rady

IntroductionSingly-Linked Lists

Insertion

Deletion

ConcurrentSLL’sConcurrencyPrimitives

NaïveImplementation ofConcurrent SLL’s

Harris’salgorithm

F&R’sAlgorithm

Conclusion

Concurrent SLL’s cont.

Can we construct a concurrent implementation of SLL’susing only COMPARE & SWAP?Yes! But it’s very difficult.Let’s consider a naïve implementation replacing READ’sand WRITES’s with COMPARE & SWAP.

Page 17: Concurrent Singly-Linked Lists - York University · Singly-Linked Lists Insertion Deletion Concurrent SLL’s Concurrency Primitives Naïve Implementation of Concurrent SLL’s Harris’s

CSE6490APresentation

Amgad Rady

IntroductionSingly-Linked Lists

Insertion

Deletion

ConcurrentSLL’sConcurrencyPrimitives

NaïveImplementation ofConcurrent SLL’s

Harris’salgorithm

F&R’sAlgorithm

Conclusion

Concurrent SLL’s cont.

Can we construct a concurrent implementation of SLL’susing only COMPARE & SWAP?Yes! But it’s very difficult.Let’s consider a naïve implementation replacing READ’sand WRITES’s with COMPARE & SWAP.

Page 18: Concurrent Singly-Linked Lists - York University · Singly-Linked Lists Insertion Deletion Concurrent SLL’s Concurrency Primitives Naïve Implementation of Concurrent SLL’s Harris’s

CSE6490APresentation

Amgad Rady

IntroductionSingly-Linked Lists

Insertion

Deletion

ConcurrentSLL’sConcurrencyPrimitives

NaïveImplementation ofConcurrent SLL’s

Harris’salgorithm

F&R’sAlgorithm

Conclusion

Concurrent INSERT and DELETE

We delete the node (2) and insert the node (3) concurrentlyinto the list 1,2,4.

1 2

3

4

Page 19: Concurrent Singly-Linked Lists - York University · Singly-Linked Lists Insertion Deletion Concurrent SLL’s Concurrency Primitives Naïve Implementation of Concurrent SLL’s Harris’s

CSE6490APresentation

Amgad Rady

IntroductionSingly-Linked Lists

Insertion

Deletion

ConcurrentSLL’sConcurrencyPrimitives

NaïveImplementation ofConcurrent SLL’s

Harris’salgorithm

F&R’sAlgorithm

Conclusion

Concurrent INSERT and DELETE

The resulting list is 1,4, rather than the correct 1,3,4.

1 2

3

4

Page 20: Concurrent Singly-Linked Lists - York University · Singly-Linked Lists Insertion Deletion Concurrent SLL’s Concurrency Primitives Naïve Implementation of Concurrent SLL’s Harris’s

CSE6490APresentation

Amgad Rady

IntroductionSingly-Linked Lists

Insertion

Deletion

ConcurrentSLL’sConcurrencyPrimitives

NaïveImplementation ofConcurrent SLL’s

Harris’salgorithm

F&R’sAlgorithm

Conclusion

What Went Wrong?

The issue in this example is that the INSERT procedurehas no indication that the node (2) is about to bedeleted.We can fix this by augmenting each node with a markbit to indicate that the node is logically deleted before itis physically deleted.Once a node has been marked, its pointer cannot bechanged.The next section presents a solution due to TimothyHarris.

Page 21: Concurrent Singly-Linked Lists - York University · Singly-Linked Lists Insertion Deletion Concurrent SLL’s Concurrency Primitives Naïve Implementation of Concurrent SLL’s Harris’s

CSE6490APresentation

Amgad Rady

IntroductionSingly-Linked Lists

Insertion

Deletion

ConcurrentSLL’sConcurrencyPrimitives

NaïveImplementation ofConcurrent SLL’s

Harris’salgorithm

F&R’sAlgorithm

Conclusion

What Went Wrong?

The issue in this example is that the INSERT procedurehas no indication that the node (2) is about to bedeleted.We can fix this by augmenting each node with a markbit to indicate that the node is logically deleted before itis physically deleted.Once a node has been marked, its pointer cannot bechanged.The next section presents a solution due to TimothyHarris.

Page 22: Concurrent Singly-Linked Lists - York University · Singly-Linked Lists Insertion Deletion Concurrent SLL’s Concurrency Primitives Naïve Implementation of Concurrent SLL’s Harris’s

CSE6490APresentation

Amgad Rady

IntroductionSingly-Linked Lists

Insertion

Deletion

ConcurrentSLL’sConcurrencyPrimitives

NaïveImplementation ofConcurrent SLL’s

Harris’salgorithm

F&R’sAlgorithm

Conclusion

What Went Wrong?

The issue in this example is that the INSERT procedurehas no indication that the node (2) is about to bedeleted.We can fix this by augmenting each node with a markbit to indicate that the node is logically deleted before itis physically deleted.Once a node has been marked, its pointer cannot bechanged.The next section presents a solution due to TimothyHarris.

Page 23: Concurrent Singly-Linked Lists - York University · Singly-Linked Lists Insertion Deletion Concurrent SLL’s Concurrency Primitives Naïve Implementation of Concurrent SLL’s Harris’s

CSE6490APresentation

Amgad Rady

IntroductionSingly-Linked Lists

Insertion

Deletion

ConcurrentSLL’sConcurrencyPrimitives

NaïveImplementation ofConcurrent SLL’s

Harris’salgorithm

F&R’sAlgorithm

Conclusion

What Went Wrong?

The issue in this example is that the INSERT procedurehas no indication that the node (2) is about to bedeleted.We can fix this by augmenting each node with a markbit to indicate that the node is logically deleted before itis physically deleted.Once a node has been marked, its pointer cannot bechanged.The next section presents a solution due to TimothyHarris.

Page 24: Concurrent Singly-Linked Lists - York University · Singly-Linked Lists Insertion Deletion Concurrent SLL’s Concurrency Primitives Naïve Implementation of Concurrent SLL’s Harris’s

CSE6490APresentation

Amgad Rady

IntroductionSingly-Linked Lists

Insertion

Deletion

ConcurrentSLL’sConcurrencyPrimitives

NaïveImplementation ofConcurrent SLL’s

Harris’salgorithm

F&R’sAlgorithm

Conclusion

DELETE Procedure

Deleting the node containing 2 from the list 1,2,3,4.Mark the node.

1 2 3 4

Page 25: Concurrent Singly-Linked Lists - York University · Singly-Linked Lists Insertion Deletion Concurrent SLL’s Concurrency Primitives Naïve Implementation of Concurrent SLL’s Harris’s

CSE6490APresentation

Amgad Rady

IntroductionSingly-Linked Lists

Insertion

Deletion

ConcurrentSLL’sConcurrencyPrimitives

NaïveImplementation ofConcurrent SLL’s

Harris’salgorithm

F&R’sAlgorithm

Conclusion

DELETE Procedure

Deleting the node containing 2 from the list 1,2,3,4.Mark the node.

1 2 3 4

Page 26: Concurrent Singly-Linked Lists - York University · Singly-Linked Lists Insertion Deletion Concurrent SLL’s Concurrency Primitives Naïve Implementation of Concurrent SLL’s Harris’s

CSE6490APresentation

Amgad Rady

IntroductionSingly-Linked Lists

Insertion

Deletion

ConcurrentSLL’sConcurrencyPrimitives

NaïveImplementation ofConcurrent SLL’s

Harris’salgorithm

F&R’sAlgorithm

Conclusion

A Problematic Execution

1 2 3

4

5

Page 27: Concurrent Singly-Linked Lists - York University · Singly-Linked Lists Insertion Deletion Concurrent SLL’s Concurrency Primitives Naïve Implementation of Concurrent SLL’s Harris’s

CSE6490APresentation

Amgad Rady

IntroductionSingly-Linked Lists

Insertion

Deletion

ConcurrentSLL’sConcurrencyPrimitives

NaïveImplementation ofConcurrent SLL’s

Harris’salgorithm

F&R’sAlgorithm

Conclusion

A Problematic Execution

1 2 3

4

5

Page 28: Concurrent Singly-Linked Lists - York University · Singly-Linked Lists Insertion Deletion Concurrent SLL’s Concurrency Primitives Naïve Implementation of Concurrent SLL’s Harris’s

CSE6490APresentation

Amgad Rady

IntroductionSingly-Linked Lists

Insertion

Deletion

ConcurrentSLL’sConcurrencyPrimitives

NaïveImplementation ofConcurrent SLL’s

Harris’salgorithm

F&R’sAlgorithm

Conclusion

A Problematic Execution

1 2 3 5

Page 29: Concurrent Singly-Linked Lists - York University · Singly-Linked Lists Insertion Deletion Concurrent SLL’s Concurrency Primitives Naïve Implementation of Concurrent SLL’s Harris’s

CSE6490APresentation

Amgad Rady

IntroductionSingly-Linked Lists

Insertion

Deletion

ConcurrentSLL’sConcurrencyPrimitives

NaïveImplementation ofConcurrent SLL’s

Harris’salgorithm

F&R’sAlgorithm

Conclusion

A Problematic Execution

1 2 3 5

4

Page 30: Concurrent Singly-Linked Lists - York University · Singly-Linked Lists Insertion Deletion Concurrent SLL’s Concurrency Primitives Naïve Implementation of Concurrent SLL’s Harris’s

CSE6490APresentation

Amgad Rady

IntroductionSingly-Linked Lists

Insertion

Deletion

ConcurrentSLL’sConcurrencyPrimitives

NaïveImplementation ofConcurrent SLL’s

Harris’salgorithm

F&R’sAlgorithm

Conclusion

A Problematic Execution

1 2 3 5

4

Page 31: Concurrent Singly-Linked Lists - York University · Singly-Linked Lists Insertion Deletion Concurrent SLL’s Concurrency Primitives Naïve Implementation of Concurrent SLL’s Harris’s

CSE6490APresentation

Amgad Rady

IntroductionSingly-Linked Lists

Insertion

Deletion

ConcurrentSLL’sConcurrencyPrimitives

NaïveImplementation ofConcurrent SLL’s

Harris’salgorithm

F&R’sAlgorithm

Conclusion

A Problematic Execution

1 2 3 5

Page 32: Concurrent Singly-Linked Lists - York University · Singly-Linked Lists Insertion Deletion Concurrent SLL’s Concurrency Primitives Naïve Implementation of Concurrent SLL’s Harris’s

CSE6490APresentation

Amgad Rady

IntroductionSingly-Linked Lists

Insertion

Deletion

ConcurrentSLL’sConcurrencyPrimitives

NaïveImplementation ofConcurrent SLL’s

Harris’salgorithm

F&R’sAlgorithm

Conclusion

A Problematic Execution

In the worst case, INSERT can have Ω(n2) running time.The problem here is that INSERT begins searching fromthe head of the list each time it finds a marked node.This can be solved by having marked nodes also pointto their predecessors with a backlink pointer.But this is not quite enough as these backlinks cangrow and affect asymptotic performance.We solve this by introducing a flag bit to each node toindicate that the successor is being deleted. A flaggednode cannot be marked for the duration of the flag,which prevents the backlinks from growing.This solution is due to Fomitchev and Ruppert.

Page 33: Concurrent Singly-Linked Lists - York University · Singly-Linked Lists Insertion Deletion Concurrent SLL’s Concurrency Primitives Naïve Implementation of Concurrent SLL’s Harris’s

CSE6490APresentation

Amgad Rady

IntroductionSingly-Linked Lists

Insertion

Deletion

ConcurrentSLL’sConcurrencyPrimitives

NaïveImplementation ofConcurrent SLL’s

Harris’salgorithm

F&R’sAlgorithm

Conclusion

A Problematic Execution

In the worst case, INSERT can have Ω(n2) running time.The problem here is that INSERT begins searching fromthe head of the list each time it finds a marked node.This can be solved by having marked nodes also pointto their predecessors with a backlink pointer.But this is not quite enough as these backlinks cangrow and affect asymptotic performance.We solve this by introducing a flag bit to each node toindicate that the successor is being deleted. A flaggednode cannot be marked for the duration of the flag,which prevents the backlinks from growing.This solution is due to Fomitchev and Ruppert.

Page 34: Concurrent Singly-Linked Lists - York University · Singly-Linked Lists Insertion Deletion Concurrent SLL’s Concurrency Primitives Naïve Implementation of Concurrent SLL’s Harris’s

CSE6490APresentation

Amgad Rady

IntroductionSingly-Linked Lists

Insertion

Deletion

ConcurrentSLL’sConcurrencyPrimitives

NaïveImplementation ofConcurrent SLL’s

Harris’salgorithm

F&R’sAlgorithm

Conclusion

A Problematic Execution

In the worst case, INSERT can have Ω(n2) running time.The problem here is that INSERT begins searching fromthe head of the list each time it finds a marked node.This can be solved by having marked nodes also pointto their predecessors with a backlink pointer.But this is not quite enough as these backlinks cangrow and affect asymptotic performance.We solve this by introducing a flag bit to each node toindicate that the successor is being deleted. A flaggednode cannot be marked for the duration of the flag,which prevents the backlinks from growing.This solution is due to Fomitchev and Ruppert.

Page 35: Concurrent Singly-Linked Lists - York University · Singly-Linked Lists Insertion Deletion Concurrent SLL’s Concurrency Primitives Naïve Implementation of Concurrent SLL’s Harris’s

CSE6490APresentation

Amgad Rady

IntroductionSingly-Linked Lists

Insertion

Deletion

ConcurrentSLL’sConcurrencyPrimitives

NaïveImplementation ofConcurrent SLL’s

Harris’salgorithm

F&R’sAlgorithm

Conclusion

A Problematic Execution

In the worst case, INSERT can have Ω(n2) running time.The problem here is that INSERT begins searching fromthe head of the list each time it finds a marked node.This can be solved by having marked nodes also pointto their predecessors with a backlink pointer.But this is not quite enough as these backlinks cangrow and affect asymptotic performance.We solve this by introducing a flag bit to each node toindicate that the successor is being deleted. A flaggednode cannot be marked for the duration of the flag,which prevents the backlinks from growing.This solution is due to Fomitchev and Ruppert.

Page 36: Concurrent Singly-Linked Lists - York University · Singly-Linked Lists Insertion Deletion Concurrent SLL’s Concurrency Primitives Naïve Implementation of Concurrent SLL’s Harris’s

CSE6490APresentation

Amgad Rady

IntroductionSingly-Linked Lists

Insertion

Deletion

ConcurrentSLL’sConcurrencyPrimitives

NaïveImplementation ofConcurrent SLL’s

Harris’salgorithm

F&R’sAlgorithm

Conclusion

A Problematic Execution

In the worst case, INSERT can have Ω(n2) running time.The problem here is that INSERT begins searching fromthe head of the list each time it finds a marked node.This can be solved by having marked nodes also pointto their predecessors with a backlink pointer.But this is not quite enough as these backlinks cangrow and affect asymptotic performance.We solve this by introducing a flag bit to each node toindicate that the successor is being deleted. A flaggednode cannot be marked for the duration of the flag,which prevents the backlinks from growing.This solution is due to Fomitchev and Ruppert.

Page 37: Concurrent Singly-Linked Lists - York University · Singly-Linked Lists Insertion Deletion Concurrent SLL’s Concurrency Primitives Naïve Implementation of Concurrent SLL’s Harris’s

CSE6490APresentation

Amgad Rady

IntroductionSingly-Linked Lists

Insertion

Deletion

ConcurrentSLL’sConcurrencyPrimitives

NaïveImplementation ofConcurrent SLL’s

Harris’salgorithm

F&R’sAlgorithm

Conclusion

A Problematic Execution

In the worst case, INSERT can have Ω(n2) running time.The problem here is that INSERT begins searching fromthe head of the list each time it finds a marked node.This can be solved by having marked nodes also pointto their predecessors with a backlink pointer.But this is not quite enough as these backlinks cangrow and affect asymptotic performance.We solve this by introducing a flag bit to each node toindicate that the successor is being deleted. A flaggednode cannot be marked for the duration of the flag,which prevents the backlinks from growing.This solution is due to Fomitchev and Ruppert.

Page 38: Concurrent Singly-Linked Lists - York University · Singly-Linked Lists Insertion Deletion Concurrent SLL’s Concurrency Primitives Naïve Implementation of Concurrent SLL’s Harris’s

CSE6490APresentation

Amgad Rady

IntroductionSingly-Linked Lists

Insertion

Deletion

ConcurrentSLL’sConcurrencyPrimitives

NaïveImplementation ofConcurrent SLL’s

Harris’salgorithm

F&R’sAlgorithm

Conclusion

DELETE Procedure

1 2 3

Page 39: Concurrent Singly-Linked Lists - York University · Singly-Linked Lists Insertion Deletion Concurrent SLL’s Concurrency Primitives Naïve Implementation of Concurrent SLL’s Harris’s

CSE6490APresentation

Amgad Rady

IntroductionSingly-Linked Lists

Insertion

Deletion

ConcurrentSLL’sConcurrencyPrimitives

NaïveImplementation ofConcurrent SLL’s

Harris’salgorithm

F&R’sAlgorithm

Conclusion

DELETE Procedure

1 2 3

Page 40: Concurrent Singly-Linked Lists - York University · Singly-Linked Lists Insertion Deletion Concurrent SLL’s Concurrency Primitives Naïve Implementation of Concurrent SLL’s Harris’s

CSE6490APresentation

Amgad Rady

IntroductionSingly-Linked Lists

Insertion

Deletion

ConcurrentSLL’sConcurrencyPrimitives

NaïveImplementation ofConcurrent SLL’s

Harris’salgorithm

F&R’sAlgorithm

Conclusion

DELETE Procedure

1 2 3

Page 41: Concurrent Singly-Linked Lists - York University · Singly-Linked Lists Insertion Deletion Concurrent SLL’s Concurrency Primitives Naïve Implementation of Concurrent SLL’s Harris’s

CSE6490APresentation

Amgad Rady

IntroductionSingly-Linked Lists

Insertion

Deletion

ConcurrentSLL’sConcurrencyPrimitives

NaïveImplementation ofConcurrent SLL’s

Harris’salgorithm

F&R’sAlgorithm

Conclusion

DELETE Procedure

1 2 3

Page 42: Concurrent Singly-Linked Lists - York University · Singly-Linked Lists Insertion Deletion Concurrent SLL’s Concurrency Primitives Naïve Implementation of Concurrent SLL’s Harris’s

CSE6490APresentation

Amgad Rady

IntroductionSingly-Linked Lists

Insertion

Deletion

ConcurrentSLL’sConcurrencyPrimitives

NaïveImplementation ofConcurrent SLL’s

Harris’salgorithm

F&R’sAlgorithm

Conclusion

DELETE Procedure

1 2 3

Page 43: Concurrent Singly-Linked Lists - York University · Singly-Linked Lists Insertion Deletion Concurrent SLL’s Concurrency Primitives Naïve Implementation of Concurrent SLL’s Harris’s

CSE6490APresentation

Amgad Rady

IntroductionSingly-Linked Lists

Insertion

Deletion

ConcurrentSLL’sConcurrencyPrimitives

NaïveImplementation ofConcurrent SLL’s

Harris’salgorithm

F&R’sAlgorithm

Conclusion

F&R Performance

What does this increase in complexity give us?In Harris’s algorithm, the average cost of an operationis Ω(n · c) where n is the average length of the listduring an execution and c is the average contention.In Fomitchev and Ruppert’s algorithm, the average costof an operation is O(n + c).Is this increase in performance worth the increase incomplexity?

Page 44: Concurrent Singly-Linked Lists - York University · Singly-Linked Lists Insertion Deletion Concurrent SLL’s Concurrency Primitives Naïve Implementation of Concurrent SLL’s Harris’s

CSE6490APresentation

Amgad Rady

IntroductionSingly-Linked Lists

Insertion

Deletion

ConcurrentSLL’sConcurrencyPrimitives

NaïveImplementation ofConcurrent SLL’s

Harris’salgorithm

F&R’sAlgorithm

Conclusion

F&R Performance

What does this increase in complexity give us?In Harris’s algorithm, the average cost of an operationis Ω(n · c) where n is the average length of the listduring an execution and c is the average contention.In Fomitchev and Ruppert’s algorithm, the average costof an operation is O(n + c).Is this increase in performance worth the increase incomplexity?

Page 45: Concurrent Singly-Linked Lists - York University · Singly-Linked Lists Insertion Deletion Concurrent SLL’s Concurrency Primitives Naïve Implementation of Concurrent SLL’s Harris’s

CSE6490APresentation

Amgad Rady

IntroductionSingly-Linked Lists

Insertion

Deletion

ConcurrentSLL’sConcurrencyPrimitives

NaïveImplementation ofConcurrent SLL’s

Harris’salgorithm

F&R’sAlgorithm

Conclusion

F&R Performance

What does this increase in complexity give us?In Harris’s algorithm, the average cost of an operationis Ω(n · c) where n is the average length of the listduring an execution and c is the average contention.In Fomitchev and Ruppert’s algorithm, the average costof an operation is O(n + c).Is this increase in performance worth the increase incomplexity?

Page 46: Concurrent Singly-Linked Lists - York University · Singly-Linked Lists Insertion Deletion Concurrent SLL’s Concurrency Primitives Naïve Implementation of Concurrent SLL’s Harris’s

CSE6490APresentation

Amgad Rady

IntroductionSingly-Linked Lists

Insertion

Deletion

ConcurrentSLL’sConcurrencyPrimitives

NaïveImplementation ofConcurrent SLL’s

Harris’salgorithm

F&R’sAlgorithm

Conclusion

F&R Performance

What does this increase in complexity give us?In Harris’s algorithm, the average cost of an operationis Ω(n · c) where n is the average length of the listduring an execution and c is the average contention.In Fomitchev and Ruppert’s algorithm, the average costof an operation is O(n + c).Is this increase in performance worth the increase incomplexity?

Page 47: Concurrent Singly-Linked Lists - York University · Singly-Linked Lists Insertion Deletion Concurrent SLL’s Concurrency Primitives Naïve Implementation of Concurrent SLL’s Harris’s

CSE6490APresentation

Amgad Rady

IntroductionSingly-Linked Lists

Insertion

Deletion

ConcurrentSLL’sConcurrencyPrimitives

NaïveImplementation ofConcurrent SLL’s

Harris’salgorithm

F&R’sAlgorithm

Conclusion

Plan & Challenges

PlanImplement Fomitchev and Ruppert’s algorithm andassess its performance on a massive number ofthreads, causing Manycore Testing Lab much grief.

ChallengesLegal liability.The usual challenges when implementing anynon-trivial algorithm, except...Java doesn’t have COMPARE & SWAP. It has theweaker primitive COMPARE & SET. Adapting thealgorithm without introducing errors or degradingperformance will be challenging.

Page 48: Concurrent Singly-Linked Lists - York University · Singly-Linked Lists Insertion Deletion Concurrent SLL’s Concurrency Primitives Naïve Implementation of Concurrent SLL’s Harris’s

CSE6490APresentation

Amgad Rady

IntroductionSingly-Linked Lists

Insertion

Deletion

ConcurrentSLL’sConcurrencyPrimitives

NaïveImplementation ofConcurrent SLL’s

Harris’salgorithm

F&R’sAlgorithm

Conclusion

Plan & Challenges

PlanImplement Fomitchev and Ruppert’s algorithm andassess its performance on a massive number ofthreads, causing Manycore Testing Lab much grief.

ChallengesLegal liability.The usual challenges when implementing anynon-trivial algorithm, except...Java doesn’t have COMPARE & SWAP. It has theweaker primitive COMPARE & SET. Adapting thealgorithm without introducing errors or degradingperformance will be challenging.

Page 49: Concurrent Singly-Linked Lists - York University · Singly-Linked Lists Insertion Deletion Concurrent SLL’s Concurrency Primitives Naïve Implementation of Concurrent SLL’s Harris’s

CSE6490APresentation

Amgad Rady

IntroductionSingly-Linked Lists

Insertion

Deletion

ConcurrentSLL’sConcurrencyPrimitives

NaïveImplementation ofConcurrent SLL’s

Harris’salgorithm

F&R’sAlgorithm

Conclusion

Plan & Challenges

PlanImplement Fomitchev and Ruppert’s algorithm andassess its performance on a massive number ofthreads, causing Manycore Testing Lab much grief.

ChallengesLegal liability.The usual challenges when implementing anynon-trivial algorithm, except...Java doesn’t have COMPARE & SWAP. It has theweaker primitive COMPARE & SET. Adapting thealgorithm without introducing errors or degradingperformance will be challenging.

Page 50: Concurrent Singly-Linked Lists - York University · Singly-Linked Lists Insertion Deletion Concurrent SLL’s Concurrency Primitives Naïve Implementation of Concurrent SLL’s Harris’s

CSE6490APresentation

Amgad Rady

IntroductionSingly-Linked Lists

Insertion

Deletion

ConcurrentSLL’sConcurrencyPrimitives

NaïveImplementation ofConcurrent SLL’s

Harris’salgorithm

F&R’sAlgorithm

Conclusion

Plan & Challenges

PlanImplement Fomitchev and Ruppert’s algorithm andassess its performance on a massive number ofthreads, causing Manycore Testing Lab much grief.

ChallengesLegal liability.The usual challenges when implementing anynon-trivial algorithm, except...Java doesn’t have COMPARE & SWAP. It has theweaker primitive COMPARE & SET. Adapting thealgorithm without introducing errors or degradingperformance will be challenging.

Page 51: Concurrent Singly-Linked Lists - York University · Singly-Linked Lists Insertion Deletion Concurrent SLL’s Concurrency Primitives Naïve Implementation of Concurrent SLL’s Harris’s

CSE6490APresentation

Amgad Rady

IntroductionSingly-Linked Lists

Insertion

Deletion

ConcurrentSLL’sConcurrencyPrimitives

NaïveImplementation ofConcurrent SLL’s

Harris’salgorithm

F&R’sAlgorithm

Conclusion

Plan & Challenges

PlanImplement Fomitchev and Ruppert’s algorithm andassess its performance on a massive number ofthreads, causing Manycore Testing Lab much grief.

ChallengesLegal liability.The usual challenges when implementing anynon-trivial algorithm, except...Java doesn’t have COMPARE & SWAP. It has theweaker primitive COMPARE & SET. Adapting thealgorithm without introducing errors or degradingperformance will be challenging.

Page 52: Concurrent Singly-Linked Lists - York University · Singly-Linked Lists Insertion Deletion Concurrent SLL’s Concurrency Primitives Naïve Implementation of Concurrent SLL’s Harris’s

CSE6490APresentation

Amgad Rady

IntroductionSingly-Linked Lists

Insertion

Deletion

ConcurrentSLL’sConcurrencyPrimitives

NaïveImplementation ofConcurrent SLL’s

Harris’salgorithm

F&R’sAlgorithm

Conclusion

Plan & Challenges

PlanImplement Fomitchev and Ruppert’s algorithm andassess its performance on a massive number ofthreads, causing Manycore Testing Lab much grief.

ChallengesLegal liability.The usual challenges when implementing anynon-trivial algorithm, except...Java doesn’t have COMPARE & SWAP. It has theweaker primitive COMPARE & SET. Adapting thealgorithm without introducing errors or degradingperformance will be challenging.

Page 53: Concurrent Singly-Linked Lists - York University · Singly-Linked Lists Insertion Deletion Concurrent SLL’s Concurrency Primitives Naïve Implementation of Concurrent SLL’s Harris’s

CSE6490APresentation

Amgad Rady

IntroductionSingly-Linked Lists

Insertion

Deletion

ConcurrentSLL’sConcurrencyPrimitives

NaïveImplementation ofConcurrent SLL’s

Harris’salgorithm

F&R’sAlgorithm

Conclusion

The End

Questions?