Presentation is loading. Please wait.

Presentation is loading. Please wait.

Checking nonblocking concurrent queue program

Similar presentations


Presentation on theme: "Checking nonblocking concurrent queue program"— Presentation transcript:

1 Checking nonblocking concurrent queue program
Jun Miao York University 5/9/2018

2 Concurrent Queue Queue is a widely used ADT in computer science
Insertions and deletions follow the first-in first-out scheme

3 Node Structure Node <V> V item;
AtomicStampedReference<Node<V>> next; AtomicStampedReference ReferenceIntegerPair<V>: private final V reference private final int integer

4 Dummy Node <null, null>
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 Stamp = 0 Reference Dummy Node <null, null> Stamp = 0 Reference

5 Enqueue If NO CompareAndSet is used in 3 steps
Create a new node Store current Tail and last node Is current Tail unchanged? Is the stored node still the last one? Insert the node at the end Update reference of Tail to new node If NO CompareAndSet is used in 3 steps Swing Tail to the last node

6 Dequeue Is current Head unchanged?
Store current Head, Tail, and the first available node Is the queue empty? Get information from the first available node Update Head Is current Head unchanged? Are Head and Tail pointing to the same node because Tail is not updated?

7 Properties no uncaught exceptions no data races
All listeners can be found in javapathfinder-trunk\src\gov\nasa\jpf\tools

8 NullPointerException
Problem: q.head points to a null node The only possible reason: 1. q.head != q.tail 2. q.head.next == null But how does this happen?

9 Struggling with NullPointerException
NonNullChecker is used First Attempt 2 threads Thread 1 Enqueue() Dequeue() Thread 2

10 Simple is good Second Attempt Start 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:

11 PreciseRaceDetector Two threads Three threads… Four thread… Result:
Enqueue|Dequeue Enqueue|Enqueue Dequeue|Dequeue Three threads… Four thread… Result:

12 Exceptions and Data races
No Exceptions in the concurrent queue operations No Data races My question: is my testing enough?

13 Something interesting
This 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

14 Post Condition Start from q.head Print value of each node sequentially
Reach q.tail

15 Conclusion Testing the program step by step
The more enqueue operation, the more time consumed by JPF checking Testing time increases significantly

16 Question Time


Download ppt "Checking nonblocking concurrent queue program"

Similar presentations


Ads by Google