Checking nonblocking concurrent queue program

Slides:



Advertisements
Similar presentations
STACKS & QUEUES. Stacks Abstract data types An abstract data type (ADT) is an abstraction of a data structure An ADT specifies : –Data stored –Operations.
Advertisements

Queues and Linked Lists
Data Structure HKOI training /4/2010 So Pak Yeung.
Ceng-112 Data Structures I Chapter 5 Queues.
1 Chapter 4 Synchronization Algorithms and Concurrent Programming Gadi Taubenfeld © 2014 Synchronization Algorithms and Concurrent Programming Synchronization.
Queues1 Part-B2 Queues. Queues2 The Queue ADT (§4.3) The Queue ADT stores arbitrary objects Insertions and deletions follow the first-in first-out scheme.
Maged M. Michael, “Hazard Pointers: Safe Memory Reclamation for Lock- Free Objects” Presentation Robert T. Bauer.
COSC 1P03 Data Structures and Abstraction 9.1 The Queue Whenever you are asked if you can do a job, tell 'em, "Certainly, I can!" Then get busy and find.
1 Queues (5.2) CSE 2011 Winter May Announcements York Programming Contest Link also available from.
CS Data Structures II Review COSC 2006 April 14, 2017
Scalable Synchronous Queues By William N. Scherer III, Doug Lea, and Michael L. Scott Presented by Ran Isenberg.
CS 106 Introduction to Computer Science I 12 / 06 / 2006 Instructor: Michael Eckmann.
CS 206 Introduction to Computer Science II 10 / 20 / 2008 Instructor: Michael Eckmann.
Simple, Fast, and Practical Non- Blocking and Blocking Concurrent Queue Algorithms Presenter: Jim Santmyer By: Maged M. Micheal Michael L. Scott Department.
© 2004 Goodrich, Tamassia Queues1. © 2004 Goodrich, Tamassia Queues2 The Queue ADT (§4.3) The Queue ADT stores arbitrary objects Insertions and deletions.
שירן חליבה Concurrent Queues. Outline: Some definitions 3 queue implementations : A Bounded Partial Queue An Unbounded Total Queue An Unbounded Lock-Free.
CSE 373 Data Structures and Algorithms Lecture 2: Queues.
DATA STRUCTURES AND ALGORITHMS Lecture Notes 4 Prepared by İnanç TAHRALI.
Data Structures (part 2). Stacks An Everyday Example Your boss keeps bringing you important items to deal with and keeps saying: “Put that last ‘rush’
Mohammad Amin Kuhail M.Sc. (York, UK) University of Palestine Faculty of Engineering and Urban planning Software Engineering Department Computer Science.
Lecture7: Queue Bohyung Han CSE, POSTECH CSED233: Data Structures (2014F)
Lab 7 Queue ADT. OVERVIEW The queue is one example of a constrained linear data structure. The elements in a queue are ordered from least recently added.
Maged M.Michael Michael L.Scott Department of Computer Science Univeristy of Rochester Presented by: Jun Miao.
Chapter 8 Queue I CS Data Structures I COSC2006 April 24, 2017
1 Lock-Free concurrent algorithm for Linked lists: Verification CSE-COSC6490A : Concurrent Object-Oriented Languages York University - W09 Speaker: Alexandre.
JAVA MEMORY MODEL AND ITS IMPLICATIONS Srikanth Seshadri
Cousin of the Stack.  An abstract data type (container class) in which items are entered at one end and removed from the other end  First In First.
Nirmalya Roy School of Electrical Engineering and Computer Science Washington State University Cpt S 122 – Data Structures Data Structures Queues.
1 Lecture 14: Queues Lecturer: Santokh Singh CompSci 105 SS 2005 Principles of Computer Science.
A Methodology for Creating Fast Wait-Free Data Structures Alex Koganand Erez Petrank Computer Science Technion, Israel.
UNIT II Queue. Syllabus Contents Concept of queue as ADT Implementation using linked and sequential organization. – linear – circular queue Concept –
CSE 373: Data Structures and Algorithms Lecture 2: Queues.
Chapter 5 Linked List by Before you learn Linked List 3 rd level of Data Structures Intermediate Level of Understanding for C++ Please.
Lecture 21 Data Structures, Algorithms and Complexity Stacks and Queues GRIFFITH COLLEGE DUBLIN.
Verifying a Two-Lock Concurrent Queue Hussain Tinwala Fall 2007.
1 Lecture 15: Big O Notation (Wednesday) Lecturer: Santokh Singh CompSci 105 SS 2005 Principles of Computer Science Test See Web for Details Don’t be deleted!
Queue ADT for lining up politely. COSC 2006 queue2 Queue – simple collection class  first-in first-out (FIFO) structure insert new elements at one end.
Dale Roberts Department of Computer and Information Science, School of Science, IUPUI CSCI 240 Abstract Data Types Queues Dale Roberts, Lecturer
Queues1 © 2014 Goodrich, Tamassia, Goldwasser Presentation for use with the textbook Data Structures and Algorithms in Java, 6 th edition, by M. T. Goodrich,
Linked Data Structures
Cpt S 122 – Data Structures Abstract Data Types
Chapter 15 Lists Objectives
Department of Computer Science, University of Rochester
CSE 373: Data Structures and Algorithms
Queue data structure.
Stacks and Queues.
Queues Queues Queues.
Programming Abstractions
Stack and Queue APURBO DATTA.
CS510 Concurrent Systems Jonathan Walpole.
Introduction to Data Structure
Data Structures and Database Applications Queues in C#
Basic Data Types Queues
Queues 11/9/2018 6:28 PM Queues 11/9/2018 6:28 PM Queues.
Queues 11/16/2018 4:19 AM Queues 11/16/2018 4:19 AM Queues.
Queues.
CS510 Concurrent Systems Jonathan Walpole.
Lock-Free concurrent algorithm for Linked lists: Implementation
CSC 143 Queues [Chapter 7].
Queues 12/3/2018 Queues © 2014 Goodrich, Tamassia, Goldwasser Queues.
Queues 3/9/15 Presentation for use with the textbook Data Structures and Algorithms in Java, 6th edition, by M. T. Goodrich, R. Tamassia, and M. H. Goldwasser,
Queues 12/30/2018 9:24 PM Queues 12/30/2018 9:24 PM Queues.
Stacks and Queues CLRS, Section 10.1.
Cs212: Data Structures Computer Science Department Lecture 7: Queues.
Model Checking of a lock-free stack
Binary Search Trees Chapter 7 Objectives
CS210- Lecture 5 Jun 9, 2005 Agenda Queues
ADT Queue (Array Implementation)
Instructor: Dr. Michael Geiger Spring 2019 Lecture 29: Linked queues
CS210- Lecture 6 Jun 13, 2005 Announcements
Presentation transcript:

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

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

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

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

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

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?

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 Thread 1 Enqueue() Dequeue() Thread 2

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 Three threads… Four thread… Result: 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

Question Time