Concurrent Lock-Free and Wait-Free Algorithms

Medha Vasanth School of Computer Science Carleton University, Ottawa, Canada [email protected] www.dehne.net

COMP 5704 Project Presentation

Outline  Introduction  Compare and Swap  Building Blocks • Micheal and Scott Queue (MS Queue) • Kogan and Petrank Queue (KP Queue)

   

Fast-path Slow-path Approach Correctness Implementation and Results Questions COMP 5704 Project Presentation

Introduction  Parallel Data Structures – FIFO Queue Tail

Head Dummy Node

Value 5 next

 Lock Freedom progress



3

provides

7 null

global

program

 Wait Freedom – ensures progress of every process  Linearizability COMP 5704 Project Presentation

Compare and Swap (CAS) 

Basic primitive CAS(mem_loc,exp_val,new_val) val mem_loc No

CAS Unsuccessful

If val==exp_val

Yes

Set mem_loc to new_val CAS Successful

COMP 5704 Project Presentation

Building Blocks Michael and Scott Queue (MS Queue) Enqueue: Tail pointing to the last node Tail

Head Dummy Node

Value 5 next

3 null

COMP 5704 Project Presentation

7 null

Building Blocks Michael and Scott Queue (MS Queue) Enqueue: Tail pointing to the last node Tail

Head Dummy Node

Value 5 next

3 null

Tail

Head Dummy Node

7 null

Value 5 next

3

COMP 5704 Project Presentation

7 null

Building Blocks Enqueue: Tail pointing to the second last node Head Dummy Node

Tail Value 5 next

3 null

COMP 5704 Project Presentation

Building Blocks Enqueue: Tail pointing to the second last node Head Dummy Node

Tail Value 5 next

Head 3 null

Dummy Node

COMP 5704 Project Presentation

Tail Value 5 next

3 null

Building Blocks Enqueue: Tail pointing to the second last node Head Dummy Node

Tail Value 5 next

Head 3 null

Dummy Node

Value 5 next

Tail

Head Dummy Node

Tail

Value 5 next

3

COMP 5704 Project Presentation

7 null

3 null

Building Blocks Dequeue: Head pointing to the first node Head Dummy Node

Tail Value 5 next

3

COMP 5704 Project Presentation

7 null

Building Blocks Dequeue: Head pointing to the first node Head

Tail

Dummy Node

Value 5 next

7 null

3

Head Tail Dummy Node

Value 3 next

7 null

COMP 5704 Project Presentation

Building Blocks Kogan and Petrank Queue (KP Queue)  Extends the idea of the MS Queue  Uses priority based helping with phase numbers  Basic Idea • All threads performing the same operation realize that some operation is in progress • Update the state array • Fix the internal structure of the queue COMP 5704 Project Presentation

Building Blocks Enqueue : Step 1 head

tail

value: 200 enqTid: 0 deqTid: -1 next:

500 1 -1

300 4 -1 null

State of thread t5 phase: 9 pending: true enqueue: true next:

COMP 5704 Project Presentation

100 5 -1 null

Building Blocks Enqueue: Step 2 head value: 200 enqTid: 0 deqTid: -1 next:

tail 500 1 -1

300 4 -1

State of thread t5 phase: 9 pending: true enqueue: true next:

COMP 5704 Project Presentation

100 5 -1 null

Building Blocks Enqueue: Step 3 head value: 200 enqTid: 0 deqTid: -1 next:

tail 500 1 -1

300 4 -1

State of thread t5 phase: 9 pending: false enqueue: true next:

COMP 5704 Project Presentation

100 5 -1 null

Building Blocks Enqueue: Step 4 head value: 200 enqTid: 0 deqTid: -1 next:

tail 500 1 -1

300 4 -1

COMP 5704 Project Presentation

100 5 -1 null

Building Blocks Dequeue: Step 1 State of thread t1 phase: 9 pending: true enqueue: false next: head value: 200 enqTid: 0 deqTid: -1 next:

tail 500 1 -1

COMP 5704 Project Presentation

300 4 -1

100 5 -1 null

Building Blocks Dequeue: Step 2 State of thread t1 phase: 9 pending: true enqueue: false next: head value: 200 enqTid: 0 deqTid: 1 next:

tail 500 1 -1

COMP 5704 Project Presentation

300 4 -1

100 5 -1 null

Building Blocks Dequeue: Step 3 State of thread t1 phase: 9 pending: false true enqueue: false next: head value: 200 enqTid: 0 deqTid: 1 next:

tail 500 1 -1

COMP 5704 Project Presentation

300 4 -1

100 5 -1 null

Building Blocks Dequeue: Step 4 head value: 200 enqTid: 0 deqTid: 1 next:

500 1 -1

tail 300 4 -1

COMP 5704 Project Presentation

100 5 -1 null

Building Blocks Dequeue: Step 4 head value: 200 enqTid: 0 deqTid: 1 next:

tail

500 1 -1

300 4 -1

head

100 5 -1 null

tail

value:500 enqTid:1 deqTid-1 next:

300 4 -1

COMP 5704 Project Presentation

100 5 -1 null

Fast-path Slow-path Approach yes

Diagram taken from Kogan, Alex, and Erez Petrank. "A methodology for creating fast wait-free data structures." Proceedings of the 17th ACM SIGPLAN symposium on Principles and Practice of Parallel

Do I need to Help?

Programming. ACM, 2012.

Help slow op

no

Try to apply my op using Fast path (most (most X X times) times)

Success?

yes

return

no Try to apply my op using Slow path (Until successful) COMP 5704 Project Presentation

Fast-path Slow-path Approach Do I need to help? Helping Record of thread ti

State of thread tj

curTid: j lastPhase: 9 nextCheck: 0

phase: 9 pending: true enqueue: true next:

Fast path: MS Queue Slow path: KP Queue

COMP 5704 Project Presentation

Correctness Correctness can be achieved by proving the following properties 

Linearizability : Execution of every operation has a set of linearization points.



Wait Freedom : Every thread completes its operation in O( F + D.n 2 ) steps.

COMP 5704 Project Presentation

Implementation and Results Java implementation with MPJ. Fast-path Slow-path Approach 380.00 340.00 Time in milliseconds



300.00

FH(50,50)

260.00

FH(20,20)

220.00

FH(10,10) FH(0,0)

180.00 140.00 100.00 4

8

12

16

No of Threads

COMP 5704 Project Presentation

Implementation and Results 



Performance can be improved by changing constants. Scalable and as efficient as the lock-free MS Queue.

COMP 5704 Project Presentation

Questions ?

COMP 5704 Project Presentation

Questions  



How does the CAS operation work? What is the difference between lock-freedom and wait-freedom? When does a thread execute on the slowpath?

COMP 5704 Project Presentation

Concurrent Lock-Free and Wait-Free Algorithms

COMP 5704 Project Presentation. Concurrent Lock-Free and Wait-Free. Algorithms. Medha Vasanth. School of Computer Science. Carleton University, Ottawa ...

60KB Sizes 3 Downloads 137 Views

Recommend Documents

Concurrent Lock-Free and Wait-Free Algorithms
School of Computer Science. Carleton University, Ottawa ... the state array. • Fix the internal structure of the queue .... Try to apply my op using. Fast path. (most X ...

Concurrent Lock-Free and Wait-Free Algorithms
Dec 10, 2012 - Abstract. The wide spread use of multicore and cluster configurations necessitates the need to efficiently achieve parallelism in all aspects of a system. This also necessitates the need to devise efficient and parallel data structures

Concurrent Reading and Writing - Leslie Lamport
process at a time can modify the data, but concurrent reading and ... unit of data might be an individual memory byte or a single disk track. ... of data, called digits, whose reading and writing are indivisible ..... U mailbox m. It is not hard to d

design for manufacturability and concurrent engineering pdf ...
design for manufacturability and concurrent engineering pdf. design for manufacturability and concurrent engineering pdf. Open. Extract. Open with. Sign In.

Concurrent programming
Page 9. 9. CMSC 15400. Three ways to create concurrent flows. Allow server to handle mul ple clients simultaneously. 1. ..... Single core laptop. 0. 1. 2. 3. 0 2 4 6 ...

Concurrent Stream Processing - GitHub
... to SQL and execute federated queries across data sources. ... where source data arrives in streams. .... or a single input pipe that is copied to two destinations.

Split-Voting in Taiwan's Concurrent Election and Referendum: An ...
Jun 1, 2010 - ... of Direct Democracy: Referendums in Global Perspective (Toronto: ...... variables (primary industries, attainment of college-level education, ...

Examination of the Factor Structure and Concurrent ...
The current article offers researchers a revised version of a mindfulness measure ..... factor methods model and last, an alternative one-factor mindfulness model ...

Examination of the Factor Structure and Concurrent ...
medical and psychological theories and treatment has led to ... factor analysis revealed the presence of a two-factor (mindfulness and mindlessness) solution. Study 2 .... Data Analysis ... when the sample size is large (Bollen, 1989).

Compositional Synthesis of Concurrent Systems ...
cient for a system designer, because if there is a counterexample, he/she needs ... As a better solution4 to Problem 1, we propose a compositional synthesis.

LITERATURE REVIEW: Concurrent Lock-Free and Wait ...
Oct 16, 2012 - Fetch&Add and the load-linked(LL)/store-conditional(SC) primitives. ... approach is not applicable for large data sets such as search trees.

concurrent programming in java design principles and patterns pdf ...
concurrent programming in java design principles and patterns pdf. concurrent programming in java design principles and patterns pdf. Open. Extract. Open with.

AKL+: A Concurrent Language Based on Object-Oriented and Logic ...
Introduction. AKL+ is a concurrent object-oriented language based on the concepts of classes, generic classes ... based object-oriented languages, either logic based languages extended with object- oriented constructs or .... For a formal definition

Split-Voting in Taiwan's Concurrent Election and Referendum: An ...
Jun 1, 2010 - KEYWORDS: referendum turnout; split voting; social context; Taiwan; eco- ... make up their minds how to vote in referendums according to the recom- ... 4Robert Huckfeldt and John Sprague, "Network in Context: The Social Flow of Politica

Genetic Algorithms and Artificial Life
In the 1950s and 1960s several computer scientists independently studied .... individual learning and species evolution a ect one another (e.g., 1, 2, 13, 37 ... In recent years, algorithms that have been termed \genetic algorithms" have ..... Bedau

Genetic Algorithms and Artificial Life
... in the population. 3. Apply selection and genetic operators (crossover and mutation) to the population to .... an environment|aspects that change too quickly for evolution to track genetically. Although ...... Princeton University Press, Princeto

Investigating Sensor Networks with Concurrent ... - IEEE Xplore
The background behind this demonstration is described as an one-page poster submission. The goal is to show a flow of tools for quick sensor network modeling, from an high level abstraction down to a system validation, including random network genera

concurrent-enrollment-1617-1.pdf
Conditions to receive financial aid for distance education courses within the University of HawaiÊ»i System: 1. Have a University of HawaiÊ»i System campus ...