E81 CSE 532S: Advanced Multi-Paradigm Software Development Chris Gill Department of Computer Science and Engineering Washington University in St. Louis.

Slides:



Advertisements
Similar presentations
Virtual Memory 3 Fred Kuhns
Advertisements

E81 CSE 532S: Advanced Multi-Paradigm Software Development Chris Gill Department of Computer Science and Engineering Washington University in St. Louis.
Concurrency (p2) synchronized (this) { doLecture(part2); } synchronized (this) { doLecture(part2); }
CSE 522 Real-Time Scheduling (4)
E81 CSE 532S: Advanced Multi-Paradigm Software Development Chris Gill Department of Computer Science and Engineering Washington University in St. Louis.
E81 CSE 532S: Advanced Multi-Paradigm Software Development Chris Gill Department of Computer Science and Engineering Washington University in St. Louis.
Designing a thread-safe class  Store all states in public static fields  Verifying thread safety is hard  Modifications to the program hard  Design.
CS533 Concepts of Operating Systems Class 3 Monitors.
Concurrency…leading up to writing a web crawler. Web crawlers.
CS220 Software Development Lecture: Multi-threading A. O’Riordan, 2009.
Server Architecture Models Operating Systems Hebrew University Spring 2004.
Synchronization in Java Fawzi Emad Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
Preemptive Scheduling Vivek Pai / Kai Li Princeton University.
Project Part I Background Tom Roeder CS sp.
More Multithreaded Programming in Java David Meredith Aalborg University.
E81 CSE 532S: Advanced Multi-Paradigm Software Development Chris Gill Department of Computer Science and Engineering Washington University, St. Louis
Multithreaded Web Server.
CSE 532: Midterm Review CSE 532 Fall 2013 Midterm Exam 80 minutes, during the usual lecture/studio time: 10:10am to 11:30am on Monday October 21, 2013.
Nachos.
E81 CSE 532S: Advanced Multi-Paradigm Software Development Chris Gill Department of Computer Science Washington University, St. Louis
Nachos Phase 1 Code -Hints and Comments
Python Concurrency Threading, parallel and GIL adventures Chris McCafferty, SunGard Global Services.
Spring/2002 Distributed Software Engineering C:\unocourses\4350\slides\DefiningThreads 1 Inter-Thread communication State dependency: Guarded Methods.
Scheduling Basic scheduling policies, for OS schedulers (threads, tasks, processes) or thread library schedulers Review of Context Switching overheads.
Porting Irregular Reductions on Heterogeneous CPU-GPU Configurations Xin Huo, Vignesh T. Ravi, Gagan Agrawal Department of Computer Science and Engineering.
Java Threads 11 Threading and Concurrent Programming in Java Introduction and Definitions D.W. Denbo Introduction and Definitions D.W. Denbo.
E81 CSE 532S: Advanced Multi-Paradigm Software Development Venkita Subramonian, Christopher Gill, Guandong Wang, Zhenning Hu, Zhenghui Xie Department of.
Proactor Pattern Venkita Subramonian & Christopher Gill
U NIVERSITY OF M ASSACHUSETTS A MHERST Department of Computer Science Computer Systems Principles Concurrency Patterns Emery Berger and Mark Corner University.
1 (Worker Queues) cs What is a Thread Pool? A collection of threads that are created once (e.g. when a server starts) That is, no need to create.
E81 CSE 532S: Advanced Multi-Paradigm Software Development Chris Gill Department of Computer Science and Engineering Washington University in St. Louis.
Threaded Programming in Python Adapted from Fundamentals of Python: From First Programs Through Data Structures CPE 401 / 601 Computer Network Systems.
Huseyin YILDIZ Software Design Engineer Microsoft Corporation SESSION CODE: DEV314.
SPL/2010 Guarded Methods and Waiting 1. SPL/2010 Reminder! ● Concurrency problem: asynchronous modifications to object states lead to failure of thread.
U NIVERSITY OF M ASSACHUSETTS A MHERST Department of Computer Science Software Systems Advanced Synchronization Emery Berger and Mark Corner University.
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.
How & When The Kernel Runs David Ferry, Chris Gill Department of Computer Science and Engineering Washington University, St. Louis MO
1 Why Threads are a Bad Idea (for most purposes) based on a presentation by John Ousterhout Sun Microsystems Laboratories Threads!
Concurrency (Threads) Threads allow you to do tasks in parallel. In an unthreaded program, you code is executed procedurally from start to finish. In a.
Interrupts and Interrupt Handling David Ferry, Chris Gill CSE 522S - Advanced Operating Systems Washington University in St. Louis St. Louis, MO
CSE 532: Course Review CSE 532 Fall 2015 Final Exam 120 minutes, covering material throughout semester –1pm to 3pm on Wednesday December 16, 2015 –Arrive.
Java Thread Programming
Kernel Synchronization David Ferry, Chris Gill CSE 522S - Advanced Operating Systems Washington University in St. Louis St. Louis, MO
Tutorial 2: Homework 1 and Project 1
C++11 Atomic Types and Memory Model
Thread Pools (Worker Queues) cs
Event Handling Patterns Asynchronous Completion Token
A Scheme concurrency library
How & When The Kernel Runs
CSC Multiprocessor Programming, Spring, 2012
January 29, 2004 Adrienne Noble
Semester Review Chris Gill CSE 422S - Operating Systems Organization
Writing and Testing Your First RTOS Project with MQX
Threads and Cooperation
The Active Object Pattern
Kernel Synchronization II
Condition Variables and Producer/Consumer
Cancellation.
Condition Variables and Producer/Consumer
Half-Sync/Half-Async (HSHA) and Leader/Followers (LF) Patterns
Henk Corporaal TUEindhoven 2011
Monitor Object Pattern
Testing and Debugging Concurrent Code
Overview of the Lab 2 Assignment: Multicore Real-Time Tasks
Kernel Synchronization II
Time Sources and Timing
CSE 153 Design of Operating Systems Winter 19
CSE 451 Section 1/27/2000.
More concurrency issues
Presentation transcript:

E81 CSE 532S: Advanced Multi-Paradigm Software Development Chris Gill Department of Computer Science and Engineering Washington University in St. Louis Advanced C++11 Thread Management

Thread Pools Simplest version –A thread per core, all run a common worker thread function Waiting for tasks to complete –Promises and futures give rendezvous with work completion –Could also post work results on an active object’s queue, which also may help avoid cache ping-pong –Futures also help with exception safety, e.g., a thrown exception propagates to thread that calls get on the future Granularity of work is another key design decision –Too small and the overhead of managing the work adds up –To coarse and responsiveness, concurrency, may suffer Work stealing lets idle threads relieve busy ones –May need to hand off promise as well as work, etc.

Interrupting Threads (Part I) Thread with interruption point is (cleanly) interruptible –Another thread can set a flag that it will notice and then exit –Clever use of lambdas, promises, move semantics lets a thread-local interrupt flag be managed (see listing 9.9) –Need to be careful to avoid dangling pointers on thread exit For simple cases, detecting interruption may be trivial –E.g., event loop with interruption point checked each time For condition variables interruption is more complex –E.g., using the guard idiom to avoid exception hazards –E.g., waiting with a timeout (and handling spurious wakes) –Can eliminate spurious wakes with a scheme based on a custom lock and a condition_variable_any (listing 9.12)

Interrupting Threads (Part II) Unlike condition variable waits, thread interruption with other blocking calls goes back to timed waiting –No access to internals of locking and unlocking semantics –Best you can do is unblock and check frequently (with interval chosen to balance overhead and responsiveness) Handling interruptions –Can use standard exception handling in interrupted thread –Can use promises and futures between threads to propagate –Put a catch block in the wrapper that initializes the interrupt flag, so uncaught exception doesn’t end the entire program Can combine interruption and joining with threads –E.g., to stop background threads and wait for them to end