CSC 480 - Multiprocessor Programming, Spring, 2012 Chapter 12 – Testing Concurrent Programs Dr. Dale E. Parson, week 12.

Slides:



Advertisements
Similar presentations
Multiple Processor Systems
Advertisements

White Box and Black Box Testing Tor Stålhane. What is White Box testing White box testing is testing where we use the info available from the code of.
Concurrency Important and difficult (Ada slides copied from Ed Schonberg)
Chapter 6: Process Synchronization
CSC Multiprocessor Programming, Spring, 2011 Outline for Chapter 6 – Task Execution Dr. Dale E. Parson, week 7.
CSC Multiprocessor Programming, Spring, 2011 Outline for Chapter 5 – Building Blocks – Library Classes, Dr. Dale E. Parson, week 5.
Silberschatz, Galvin and Gagne ©2009Operating System Concepts – 8 th Edition Chapter 4: Threads.
CS444/CS544 Operating Systems Introduction to Synchronization 2/07/2007 Prof. Searleman
Designing a thread-safe class  Store all states in public static fields  Verifying thread safety is hard  Modifications to the program hard  Design.
Precept 3 COS 461. Concurrency is Useful Multi Processor/Core Multiple Inputs Don’t wait on slow devices.
Concurrency, Threads, and Events Robbert van Renesse.
Client Server Design Alternatives© Dr. Ayman Abdel-Hamid, CS4254 Spring CS4254 Computer Network Architecture and Programming Dr. Ayman A. Abdel-Hamid.
CPS110: Implementing threads/locks on a uni-processor Landon Cox.
U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science Emery Berger University of Massachusetts, Amherst Operating Systems CMPSCI 377 Lecture.
CS533 Concepts of Operating Systems Class 4 Remote Procedure Call.
Fundamentals of Python: From First Programs Through Data Structures
1 Testing Concurrent Programs Why Test?  Eliminate bugs?  Software Engineering vs Computer Science perspectives What properties are we testing for? 
Threads in Java. History  Process is a program in execution  Has stack/heap memory  Has a program counter  Multiuser operating systems since the sixties.
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.
Producer-Consumer Problem The problem describes two processes, the producer and the consumer, who share a common, fixed-size buffer used as a queue.bufferqueue.
14.1 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts with Java – 8 th Edition Chapter 4: Threads.
Threaded Programming in Python Adapted from Fundamentals of Python: From First Programs Through Data Structures CPE 401 / 601 Computer Network Systems.
11/18/20151 Operating Systems Design (CS 423) Elsa L Gunter 2112 SC, UIUC Based on slides by Roy Campbell, Sam.
ICS 313: Programming Language Theory Chapter 13: Concurrency.
Consider the program fragment below left. Assume that the program containing this fragment executes t1() and t2() on separate threads running on separate.
The Singleton Pattern SE-2811 Dr. Mark L. Hornick 1.
CSC Multiprocessor Programming, Spring, 2012 Chapter 7 – Cancellation & Shutdown Dr. Dale E. Parson, week 9-10.
SPL/2010 Guarded Methods and Waiting 1. SPL/2010 Reminder! ● Concurrency problem: asynchronous modifications to object states lead to failure of thread.
Lecture 3 : Performance of Parallel Programs Courtesy : MIT Prof. Amarasinghe and Dr. Rabbah’s course note.
CSC Multiprocessor Programming, Spring, 2012 Chapter 11 – Performance and Scalability Dr. Dale E. Parson, week 12.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Concurrency & Dynamic Programming.
CSC Multiprocessor Programming, Spring, 2011 Chapter 9 – GUI Applications Dr. Dale E. Parson, week 11.
Debugging Threaded Applications By Andrew Binstock CMPS Parallel.
13-1 Chapter 13 Concurrency Topics Introduction Introduction to Subprogram-Level Concurrency Semaphores Monitors Message Passing Java Threads C# Threads.
U NIVERSITY OF M ASSACHUSETTS A MHERST Department of Computer Science Computer Systems Principles Synchronization Emery Berger and Mark Corner University.
CSC Multiprocessor Programming, Spring, 2012 Chapter 8 – Applying Thread Pools Dr. Dale E. Parson, week 10.
PROGRAMMING TESTING B MODULE 2: SOFTWARE SYSTEMS 22 NOVEMBER 2013.
CGS 3763 Operating Systems Concepts Spring 2013 Dan C. Marinescu Office: HEC 304 Office hours: M-Wd 11: :30 AM.
Specifying Multithreaded Java semantics for Program Verification Abhik Roychoudhury National University of Singapore (Joint work with Tulika Mitra)
CSC Multiprocessor Programming, Spring, 2012 Outline for Chapter 4 – Composing Objects – thread-safe object-oriented composition, Dr. Dale E. Parson,
1 Why Threads are a Bad Idea (for most purposes) based on a presentation by John Ousterhout Sun Microsystems Laboratories Threads!
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.
CSC Multiprocessor Programming, Spring, 2012 Chapter 10 – Avoiding Liveness Hazards Dr. Dale E. Parson, week 11.
Java Thread Programming
Tutorial 2: Homework 1 and Project 1
GlassFish Performance Tuning: Tips from the Field
Threaded Programming in Python
Threads vs. Events SEDA – An Event Model 5204 – Operating Systems.
Chapter 9: Virtual Memory
Processes and Threads Processes and their scheduling
CSC Multiprocessor Programming, Spring, 2012
CS533 Concepts of Operating Systems Class 3
CSC Multiprocessor Programming, Spring, 2011
Lecture 8 Thread Safety.
COT 5611 Operating Systems Design Principles Spring 2014
Race Conditions & Synchronization
Producer-Consumer Problem
COT 5611 Operating Systems Design Principles Spring 2012
Background and Motivation
Threaded Programming in Python
CS533 Concepts of Operating Systems Class 3
CS510 - Portland State University
Lecture 9 Synchronization.
Why Threads Are A Bad Idea (for most purposes)
CS510 Operating System Foundations
Why Threads Are A Bad Idea (for most purposes)
Why Threads Are A Bad Idea (for most purposes)
Software Engineering and Architecture
CSC Multiprocessor Programming, Spring, 2011
More concurrency issues
Presentation transcript:

CSC Multiprocessor Programming, Spring, 2012 Chapter 12 – Testing Concurrent Programs Dr. Dale E. Parson, week 12

Testing considerations Test for safety. Nothing bad ever happens. Test for liveness. Something good eventually happens Test code can introduce timing and synchronization changes. Performance testing and benchmarks. Throughput, Responsiveness (Latency), Scalability

Testing for correctness Validating invariants and precondition -> postcondition satisfaction can be automated. Design by Contract constraints should remain visible on a per-thread basis. From any individual thread’s perspective, objects maintain their constraints. Thread.getState useful for debugging, not for testing or application logic. Try to have more active threads than CPUs to increase probability of timing indeterminacy.

Variety in testing Test resource management. Vary the load and the client-side demand to stress the system. Test on a variety of platforms (CPU and O.S.). Add trace hooks when they do not hurt performance or skew CPU load noticeably. Use configuration parameters that you can vary to bring out nondeterminacies. Thread pool size, buffer sizes, concurrent connections.

Comparing multiple algorithms Use configuration to set factories, such as plug-in factory methods, to load alternative classes, e.g., alternative library implementations of queues, lists, sets, maps. Vary these configuration parameters for performance testing. Use internal time measurement library methods to profile major components and data flows. Get real time and CPU time(s).

Pitfalls for testing and measurement Garbage collection can introduce non-linear jumps in numbers. Shut it off with –verbose:gc. Bad idea  Run enough processing to average out its effects Dynamic (Just In Time) compilation is another source of non-linear jumps in numbers. Again, shutting it off is a bad idea. Again, solution is to hammer the typical application paths through the code, and try to traverse them all. A coverage tool is useful for the latter.

Server mode JVM Prefer –server to –client JVM for production and testing on multiprocessor systems. Make sure that any benchmark does not get optimized away as dead code. Use any computed result somehow, and call System’s currentTimeMillis and nanoTime around the running code of interest. Code inspections are useful, even by yourself the next morning.

Static Analysis Tools Tools are under development. Invoking Thread.run, unreleased lock, empty synchronization block, double-checked locking (reading state before and after acquiring lock), starting a thread from a constructor, notify errors (notify after no state change), calling (a)wait while not in a loop that tests a lock predicate or without a lock held, misuse of a Lock or Condition (using their intrinsic locks), sleeping or waiting while holding a lock, spinning on (non-volatile) variables. Commercial tools.