Checking nonblocking concurrent queue program

Post on 15-Jan-2016

36 views 0 download

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

transcript

Jun MiaoYork University

04/21/23

Concurrent QueueQueue is a widely used ADT in computer

scienceInsertions and deletions follow the first-in

first-out scheme

Node Structure

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

Enqueue

If NO

Swing Tail to the last node

CompareAndSet is used in 3 steps

DequeueIs current Head unchanged?

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

Propertiesno uncaught exceptionsno data races

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

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?

Struggling with NullPointerExceptionNonNullChecker is usedFirst Attempt2 threads

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:

PreciseRaceDetectorTwo threads

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

Three threads…Four thread…

Result:

Exceptions and Data racesNo Exceptions in the concurrent queue

operationsNo Data races

My question: is my testing enough?

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

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

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

consumed by JPF checkingTesting time increases significantly

Question Time