16
Jun Miao York University 06/15/22

Checking nonblocking concurrent queue program

  • Upload
    carson

  • View
    36

  • Download
    0

Embed Size (px)

DESCRIPTION

Checking nonblocking concurrent queue program. Jun Miao York University 9/12/2014. Concurrent Queue. Queue is a widely used ADT in computer science Insertions and deletions follow the first-in first-out scheme. Node Structure. Initialization. Node dummy = new Node(null,null); - PowerPoint PPT Presentation

Citation preview

Page 1: Checking  nonblocking  concurrent queue program

Jun MiaoYork University

04/21/23

Page 2: Checking  nonblocking  concurrent queue program

Concurrent QueueQueue is a widely used ADT in computer

scienceInsertions and deletions follow the first-in

first-out scheme

Page 3: Checking  nonblocking  concurrent queue program

Node Structure

Page 4: Checking  nonblocking  concurrent queue program

Initialization Node<E> dummy = new Node<E>(null,null); this.head = new

AtomicStampedReference<Node<E>>(dummy,0); this.tail = new

AtomicStampedReference<Node<E>>(dummy,0); head

tail

Dummy Node <null,

null>

Reference

Reference

Stamp = 0

Stamp = 0

Page 5: Checking  nonblocking  concurrent queue program

Enqueue

If NO

Swing Tail to the last node

CompareAndSet is used in 3 steps

Page 6: Checking  nonblocking  concurrent queue program

DequeueIs current Head unchanged?

Are Head and Tail pointing to the same node because Tail is not updated?

Page 7: Checking  nonblocking  concurrent queue program

Propertiesno uncaught exceptionsno data races

All listeners can be found in javapathfinder-trunk\src\gov\nasa\jpf\tools

Page 8: Checking  nonblocking  concurrent queue program

NullPointerExceptionProblem: q.head points to a null node

The only possible reason:1. q.head != q.tail2. q.head.next == null

But how does this happen?

Page 9: Checking  nonblocking  concurrent queue program

Struggling with NullPointerExceptionNonNullChecker is usedFirst Attempt2 threads

Page 10: Checking  nonblocking  concurrent queue program

Simple is goodSecond AttemptStart from 1 thread with 1 operation 2 threads: 2 enqueue , 2 dequeue, 1 enqueue

and 1 dequeue 3 threads: 3 enqueue …. 4 threads: 4 enqueue…

Result:

Page 11: Checking  nonblocking  concurrent queue program

PreciseRaceDetectorTwo threads

1. Enqueue|Dequeue2. Enqueue|Enqueue3. Dequeue|Dequeue

Three threads…Four thread…

Result:

Page 12: Checking  nonblocking  concurrent queue program

Exceptions and Data racesNo Exceptions in the concurrent queue

operationsNo Data races

My question: is my testing enough?

Page 13: Checking  nonblocking  concurrent queue program

Something interestingThis algorithm came out of a discussion with

Franck van Breugel and Sergey Kulikov from the University of York. All credits for it goes to Franck and Sergey, all the bugs are mine.

Author: Willem Visser

Page 14: Checking  nonblocking  concurrent queue program

Post ConditionStart from q.headPrint value of each node sequentiallyReach q.tail

Page 15: Checking  nonblocking  concurrent queue program

ConclusionTesting the program step by stepThe more enqueue operation, the more time

consumed by JPF checkingTesting time increases significantly

Page 16: Checking  nonblocking  concurrent queue program

Question Time