Verifying a Two-Lock Concurrent Queue Hussain Tinwala Fall 2007.

Slides:



Advertisements
Similar presentations
Chapter 24 Lists, Stacks, and Queues
Advertisements

Wait-Free Linked-Lists Shahar Timnat, Anastasia Braginsky, Alex Kogan, Erez Petrank Technion, Israel Presented by Shahar Timnat 469-+
Automatic Verification Book: Chapter 6. What is verification? Traditionally, verification means proof of correctness automatic: model checking deductive:
CSEN5322 Quiz-5.
Module R2 Overview. Process queues As processes enter the system and transition from state to state, they are stored queues. There may be many different.
Module R2 CS450. Next Week R1 is due next Friday ▫Bring manuals in a binder - make sure to have a cover page with group number, module, and date. You.
Simulation Verification of Different Constraints in System Level Design in SystemC Piyush Ranjan Satapathy CS220 Class Project Presentation.
Concurrent Programming Problems OS Spring Concurrency pros and cons Concurrency is good for users –One of the reasons for multiprogramming Working.
Maged M. Michael, “Hazard Pointers: Safe Memory Reclamation for Lock- Free Objects” Presentation Robert T. Bauer.
Monitors & Blocking Synchronization 1. Producers & Consumers Problem Two threads that communicate through a shared FIFO queue. These two threads can’t.
© 2004, D. J. Foreman 1 The Dining Philosophers Problem.
Module 20 Troubleshooting Common SQL Server 2008 R2 Administrative Issues.
CS444/CS544 Operating Systems Introduction to Synchronization 2/07/2007 Prof. Searleman
Chapter 5 Concurrency: Mutual Exclusion and Synchronization Operating Systems: Internals and Design Principles, 6/E William Stallings Patricia Roy Manatee.
1 Chapter 24 Lists Stacks and Queues. 2 Objectives F To design list with interface and abstract class (§24.2). F To design and implement a dynamic list.
Threads Load new page Page is loading Browser still responds to user (can read pages in other tabs)
CS510 Concurrent Systems Class 2 A Lock-Free Multiprocessor OS Kernel.
Synchronization in Java Nelson Padua-Perez Bill Pugh Department of Computer Science University of Maryland, College Park.
Synchronization in Java Fawzi Emad Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
Queue, Deque, and Priority Queue Implementations Chapter 11 Copyright ©2012 by Pearson Education, Inc. All rights reserved.
Skip Lists1 Skip Lists William Pugh: ” Skip Lists: A Probabilistic Alternative to Balanced Trees ”, 1990  S0S0 S1S1 S2S2 S3S3 
Multithreading.
שירן חליבה Concurrent Queues. Outline: Some definitions 3 queue implementations : A Bounded Partial Queue An Unbounded Total Queue An Unbounded Lock-Free.
1 Thread Synchronization: Too Much Milk. 2 Implementing Critical Sections in Software Hard The following example will demonstrate the difficulty of providing.
Advanced Java Session 3 New York University School of Continuing and Professional Studies.
CSE 425: Concurrency III Monitors A monitor is a higher level construct for synchronizing multiple threads’ access to a common code segment –Can implement.
Concurrency: Mutual Exclusion and Synchronization Chapter 5.
November 15, 2007 A Java Implementation of a Lock- Free Concurrent Priority Queue Bart Verzijlenberg.
Multithreading : synchronization. Avanced Programming 2004, Based on LYS Stefanus’s slides slide 4.2 Solving the Race Condition Problem A thread must.
COMP 111 Threads and concurrency Sept 28, Tufts University Computer Science2 Who is this guy? I am not Prof. Couch Obvious? Sam Guyer New assistant.
Copyright 2001, Matt Dwyer, John Hatcliff, and Radu Iosif. The syllabus and all lectures for this course are copyrighted materials and may not be used.
Maged M.Michael Michael L.Scott Department of Computer Science Univeristy of Rochester Presented by: Jun Miao.
Project 2 kthreads, concurrency, shuttle. Highlevel overview User space –program wants to control the shuttle simulation by sending requests. –start_shuttle()
1 Lock-Free concurrent algorithm for Linked lists: Verification CSE-COSC6490A : Concurrent Object-Oriented Languages York University - W09 Speaker: Alexandre.
Concurrency Control 1 Fall 2014 CS7020: Game Design and Development.
Discussion Week 2 TA: Kyle Dewey. Overview Concurrency Process level Thread level MIPS - switch.s Project #1.
CHAPTER 5 PRIORITY QUEUES (HEAPS) §1 ADT Model Objects: A finite ordered list with zero or more elements. Operations:  PriorityQueue Initialize( int.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Concurrency & Dynamic Programming.
Programming Abstractions Cynthia Lee CS106X. Topics:  Priority Queue › Linked List implementation › Heap data structure implementation  TODAY’S TOPICS.
Copyright © Curt Hill Concurrent Execution An Overview for Database.
1 Algorithms Queues, Stacks and Records stored in Linked Lists or Arrays.
November 27, 2007 Verification of a Concurrent Priority Queue Bart Verzijlenberg.
2/19/2016 3:18 PMSkip Lists1  S0S0 S1S1 S2S2 S3S3    2315.
1 1 Nastaran Shafiei VERIFICATION OF A NON-BLOCKING ARRAY-BASED QUEUE ALGORITHM.
Linked list: a list of items (nodes), in which the order of the nodes is determined by the address, called the link, stored in each node C++ Programming:
Parallel Computation of Skyline Queries Verification COSC6490A Fall 2007 Slawomir Kmiec.
CS 151: Object-Oriented Design November 26 Class Meeting Department of Computer Science San Jose State University Fall 2013 Instructor: Ron Mak
1 Critical Section Problem CIS 450 Winter 2003 Professor Jinhua Guo.
1 G53SRP: Java Concurrency Control (2) – wait/notify Chris Greenhalgh School of Computer Science.
CSC CSC 143 Threads. CSC Introducing Threads  A thread is a flow of control within a program  A piece of code that runs on its own. The.
Mutual Exclusion Algorithms. Topics r Defining mutual exclusion r A centralized approach r A distributed approach r An approach assuming an organization.
Agenda  Quick Review  Finish Introduction  Java Threads.
Healing Data Races On-The-Fly
Checking nonblocking concurrent queue program
COT 4600 Operating Systems Fall 2009
Project 3 Threads and Synchronization
Extra slide #3.
Arrays and Linked Lists
David Harel, Robby Lampert, Assaf Marron, Gera Weiss
Chapter 26 Concurrency and Thread
Race Conditions & Synchronization
Dr. Mustafa Cem Kasapbaşı
Synchronized Threads and Threads Coordination
A Concurrent Lock-Free Priority Queue for Multi-Thread Systems
Concurrent Graph Exploration with Multiple Robots
Linked List Configurations
Verifying GME with JPF COSC6490A Zhenyu Pan York University 2007.
CSE 153 Design of Operating Systems Winter 2019
Linked List Configurations
Distributed Dynamic Channel Allocation in Wireless Network
Presentation transcript:

Verifying a Two-Lock Concurrent Queue Hussain Tinwala Fall 2007

Simulation Review Searching for Deadlocks Race Conditions Queue Verification Overview

Reviewing the Simulation

Searching for Deadlocks (1) JPF did not find errors… Introduced a problem I faced during implementation with Dequeuer threads:

Searching for Deadlocks (2)

Searching for Deadlocks (3) Run Simulation with 1 Enqueuer, 1 Dequeuer and 1 node: jpf -c jpf.properties… gov.nasa.jpf.jvm.choice.ThreadChoiceFromSet {Thread-0,>Thread-1} Enqueuer.java:57 : synchronized(sim) Enqueuer.java:59 : sim.notifyAll(); transition #47 thread: 1 gov.nasa.jpf.jvm.choice.ThreadChoiceFromSet {>Thread-0} Dequeuer.java:38 : synchronized (sim) Dequeuer.java:40 : sim.wait(); ====================================================== snapshot #1 thread index=1,name=Thread-0,status=WAITING, waiting on: call stack:at Dequeuer.run(Dequeuer.java:40) ====================================================== results error #1: gov.nasa.jpf.jvm.NotDeadlockedProperty \ "deadlock encountered: thread index=0,name=main,s..."

Race Conditions (1) Two types: - Critical: different outcomes - Non-critical: eventual outcome of the program is the same Both are synchronized methods modify read

Race Conditions (2) prompt> jpf -c jpf.properties … - Removed `synchronized’ - jpf with 1 Enqueuer and 1 Dequeuer --> no error - jpf with 1 Enqueuer and n Dequeuers --> no error - jpf with >1 Enqueuer --> error - Enqueuer threads use both methods - modifies a value - reads a value - Dequeuer threads only use `getNumEnqsLeft’ - reads a value - Potential for a race condition…

Race Conditions (3) - Using JPF to detect race conditions: - Add to configuration file: # listeners jpf.listener=gov.nasa.jpf.tools.precise.PreciseRaceDetector - Running JPF with 2 Enqueuers and 1 Dequeuer - jpf -c jpf.properties… at Simulator.getNumEnqsLeft(Simulator.java:57) at Enqueuer.run(Enqueuer.java:52) owned (because method is synchronized) at Simulator.decrementNumEnqsLeft(Simulator.java:53) at Enqueuer.run(Enqueuer.java:51) =========================================== results error #1: gov.nasa.jpf.tools.PreciseRaceDetector "race for: "int Simulator.numEnqsLeft" Thread-1 and Thread-2...” =========================================== results error #1: RaceDetector "potential field race: So we have 2 Enqueuers - One is updating the value - The other is attempting to read it

Race Conditions (4) - Adding `synchronized’ to the methods removes the race condition - Question: Do both methods need to be synchronized? - Yes: To get rid of the race condition - No: A race does not have to be bad - Synchronizing the method that modifies a value may be sufficient - Added `synchronized’ only to the decrementNumEnqsLeft method which is used by Enqueuer threads. - getNumEnqsLeft method left without `synchronized’ - Tested again: jpf -c jpf.properties …

Race Conditions (5) - JPF finds no deadlocks or errors but it does find a race condition - But that is okay… it is a non-critical race condition - No matter what order the execution takes, there will always be AT LEAST one Enqueuer thread that will find - getNumEnqsLeft() == 0 - And so, it will be able to notify any waiting Dequeuer threads. - Overall Advantage: There is less blocking in the Enqueuer thread

Verifying the Queue Nodes are always inserted after the last node in the linked list Nodes are always deleted from the beginning of the linked list Head always points to the first node in the list Tail always points to the last node in the list Potential Approach: –Use a PropertyListener Ex: QueuePropertyListener extends PropertyListenerAdapter –Then at each transition, verify the above mentioned properties

Thank you Questions?