160 likes | 297 Views
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<E> dummy = new Node<E>(null,null);
E N D
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
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
Enqueue If NO CompareAndSet is used in 3 steps Swing Tail to the last node
Dequeue Is current Head unchanged? Are Head and Tail pointing to the same node because Tail is not updated?
Properties • no uncaught exceptions • no data races • All listeners can be found in javapathfinder-trunk\src\gov\nasa\jpf\tools
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?
Struggling with NullPointerException • NonNullChecker is used • First Attempt • 2 threads
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:
PreciseRaceDetector • Two threads • Enqueue|Dequeue • Enqueue|Enqueue • Dequeue|Dequeue • Three threads… • Four thread… • Result:
Exceptions and Data races • No Exceptions in the concurrent queue operations • No Data races • My question: is my testing enough?
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
Post Condition • Start from q.head • Print value of each node sequentially • Reach q.tail
Conclusion • Testing the program step by step • The more enqueue operation, the more time consumed by JPF checking • Testing time increases significantly