CSE 60641: Operating Systems Next topic: CPU (Process/threads/scheduling, synchronization and deadlocks) –Why threads are a bad idea (for most purposes).

Slides:



Advertisements
Similar presentations
CS 443 Advanced OS Fabián E. Bustamante, Spring 2005 Cooperative Task Management without Manual Stack Management or Event-driven programming is not the.
Advertisements

Capriccio: Scalable Threads for Internet Services Rob von Behren, Jeremy Condit, Feng Zhou, Geroge Necula and Eric Brewer University of California at Berkeley.
1 SEDA: An Architecture for Well- Conditioned, Scalable Internet Services Matt Welsh, David Culler, and Eric Brewer Computer Science Division University.
Threads, Events, and Scheduling Andy Wang COP 5611 Advanced Operating Systems.
Why Events Are A Bad Idea (for high-concurrency servers) By Rob von Behren, Jeremy Condit and Eric Brewer.
Capriccio: Scalable Threads for Internet Services ( by Behren, Condit, Zhou, Necula, Brewer ) Presented by Alex Sherman and Sarita Bafna.
Contiki A Lightweight and Flexible Operating System for Tiny Networked Sensors Presented by: Jeremy Schiff.
Cooperative Task Management without Manual Stack Management or, Event-driven Programming is Not the Opposite of Threaded Programming Atul Adya, Jon Howell,
UCoM Software Architecture Universal Communicator Research UCoM Programming Model The Problem  Multi-threaded code is difficult to write.
Threads 1 CS502 Spring 2006 Threads CS-502 Spring 2006.
Why Events Are a Bad Idea (for high-concurrency servers) Author: Rob von Behren, Jeremy Condit and Eric Brewer Presenter: Wenhao Xu Other References: [1]
“Why Events are a Bad Idea (For high-concurrency servers)” Paper by Rob von Behren, Jeremy Condit and Eric Brewer, May 2003 Presentation by Loren Davis,
CS533 Concepts of Operating Systems Class 7 Integrated Task and Stack Management.
CS533 Concepts of Operating Systems Class 3 Integrated Task and Stack Management.
User-Level Interprocess Communication for Shared Memory Multiprocessors Brian N. Bershad, Thomas E. Anderson, Edward D. Lazowska, and Henry M. Levy Presented.
Why Events Are A Bad Idea (for high-concurrency servers) Rob von Behren, Jeremy Condit and Eric Brewer Computer Science Division, University of California.
PRASHANTHI NARAYAN NETTEM.
Why Threads Are A Bad Idea (for most purposes) John Ousterhout Sun Microsystems Laboratories
Why Events Are A Bad Idea (for high-concurrency servers) Rob von Behren, Jeremy Condit and Eric Brewer University of California at Berkeley
Why Events Are A Bad Idea (for high-concurrency servers) Rob von Behren, Jeremy Condit and Eric Brewer Presented by: Hisham Benotman CS533 - Concepts of.
Cooperative Task Management without Manual Stack Management Or, Event-driven Programming is not the Opposite of Thread Programming Atul Adya, John Howell,
Parallel Programming Models Jihad El-Sana These slides are based on the book: Introduction to Parallel Computing, Blaise Barney, Lawrence Livermore National.
LiNK: An Operating System Architecture for Network Processors Steve Muir, Jonathan Smith Princeton University, University of Pennsylvania
SEDA: An Architecture for Well-Conditioned, Scalable Internet Services Presented by Changdae Kim and Jaeung Han OFFENCE.
Operating Systems Lecture 2 Processes and Threads Adapted from Operating Systems Lecture Notes, Copyright 1997 Martin C. Rinard. Zhiqing Liu School of.
Lecture 3 Process Concepts. What is a Process? A process is the dynamic execution context of an executing program. Several processes may run concurrently,
Cooperative Task Management without Manual Stack Management or, Event-driven programming is Not the Opposite of Threaded Programming Atul Adya, Jon Howell,
Capriccio: Scalable Threads for Internet Services Rob von Behren, Jeremy Condit, Feng Zhou, Geroge Necula and Eric Brewer University of California at Berkeley.
Processes Introduction to Operating Systems: Module 3.
CS333 Intro to Operating Systems Jonathan Walpole.
Lecture 5: Threads process as a unit of scheduling and a unit of resource allocation processes vs. threads what to program with threads why use threads.
5204 – Operating Systems Threads vs. Events. 2 CS 5204 – Operating Systems Forms of task management serial preemptivecooperative (yield) (interrupt)
Operating Systems CSE 411 CPU Management Sept Lecture 10 Instructor: Bhuvan Urgaonkar.
System Components ● There are three main protected modules of the System  The Hardware Abstraction Layer ● A virtual machine to configure all devices.
Cooperative Task Management without Manual Stack Management OR Presented by Tina Swenson CS533 - February 12, 2007 Event-driven Programming is Not the.
M. Accetta, R. Baron, W. Bolosky, D. Golub, R. Rashid, A. Tevanian, and M. Young MACH: A New Kernel Foundation for UNIX Development Presenter: Wei-Lwun.
Presenting: Why Events Are A “Bad” Idea ( for high-concurrency servers) Paper by: Behren, Condit and Brewer, 2003 Presented by: Rania Elnaggar 1/30/2008.
1 Cooperative Task Management without Manual Stack Management or Event-driven Programming is not the Opposite of Threaded Programming Atul Adya, Jon Howell,
13-1 Chapter 13 Concurrency Topics Introduction Introduction to Subprogram-Level Concurrency Semaphores Monitors Message Passing Java Threads C# Threads.
Thread basics. A computer process Every time a program is executed a process is created It is managed via a data structure that keeps all things memory.
By: Rob von Behren, Jeremy Condit and Eric Brewer 2003 Presenter: Farnoosh MoshirFatemi Jan
Threads versus Events CSE451 Andrew Whitaker. This Class Threads vs. events is an ongoing debate  So, neat-and-tidy answers aren’t necessarily available.
CSE 153 Design of Operating Systems Winter 2015 Midterm Review.
1 Why Events Are A Bad Idea (for high-concurrency servers) By Rob von Behren, Jeremy Condit and Eric Brewer (May 2003) CS533 – Spring 2006 – DONG, QIN.
Threads. Readings r Silberschatz et al : Chapter 4.
Atul Adya, Jon Howell, Marvin Theimer, William J. Bolosky, John R. Douceur Microsoft Research Presented by Poonam Singh CS 533 – Winter 2010.
CS533 Concepts of Operating Systems Jonathan Walpole.
CS533 - Concepts of Operating Systems 1 Threads, Events, and Reactive Objects - Alan West.
1 Why Threads are a Bad Idea (for most purposes) based on a presentation by John Ousterhout Sun Microsystems Laboratories Threads!
Cooperative Task Management without Manual Stack management Hanyun Tao EECS 582 – W161.
Paper Review of Why Events Are A Bad Idea (for high-concurrency servers) Rob von Behren, Jeremy Condit and Eric Brewer By Anandhi Sundaram.
Lecturer 3: Processes multithreaded Operating System Concepts Process Concept Process Scheduling Operation on Processes Cooperating Processes Interprocess.
Adding Concurrency to a Programming Language Peter A. Buhr and Glen Ditchfield USENIX C++ Technical Conference, Portland, Oregon, U. S. A., August 1992.
Introduction to Operating Systems Concepts
Chapter 4: Threads Modified by Dr. Neerja Mhaskar for CS 3SH3.
Why Events Are A Bad Idea (for high-concurrency servers)
CS399 New Beginnings Jonathan Walpole.
Threads, Events, and Scheduling
Chapter 4: Threads.
Cooperative Task Management without Manual Stack Management or, Event-driven Programming is Not the Opposite of Threaded Programming Atul Adya, Jon Howell,
Threads, Events, and Scheduling
Threads, Events, and Scheduling
Why Threads Are A Bad Idea (for most purposes)
CS510 Operating System Foundations
Why Events Are a Bad Idea (for high concurrency servers)
CSE 153 Design of Operating Systems Winter 2019
Why Threads Are A Bad Idea (for most purposes)
Why Threads Are A Bad Idea (for most purposes)
CSE 153 Design of Operating Systems Winter 2019
CS 5204 Operating Systems Lecture 5
Presentation transcript:

CSE 60641: Operating Systems Next topic: CPU (Process/threads/scheduling, synchronization and deadlocks) –Why threads are a bad idea (for most purposes). J Ousterhout - Keynote at the 1996 Usenix Annual Technical –Why Events Are A Bad Idea (for high-concurrency servers) Rob von Behren, Jeremy Condit and Eric Brewer, HotOS IX –Event-driven Programming is Not the Opposite of Threaded Programming, Atul Adya, Jon Howell, Marvin Theimer, William J. Bolosky, John R. Douceur. USENIX '02 4-Jan-16CSE 60641: Operating Systems1

What is the problem being addressed? Programming for concurrency –Why do we worry about this? Threads are a popular abstraction –Light weight (as compared to tasks) –They retain stack Event based program –When a event happens, the system calls a event dispatcher which calls the appropriate service routine. –Easy to program –The service routine does not know where it came from (no stack). Hence the need to manually manage stacks 1/4/2016CSE 60641: Operating Systems2

Ousterhout Author of TCL programming language Threads are too hard for most programmers. Even for experts, development is painful. –Synchronization, deadlocks –Hard to debug: data dependencies, timing dependencies –Break abstraction: cannot design modules independently –Callbacks don’t work with locks –Achieving good performance is hard Simple locking yields low concurrency Fine-grain locking increases complexity, reduces performance –Threads not well-supported (circa 1995) 1/4/2016CSE 60641: Operating Systems3

Event-driven programming One execution stream: no CPU concurrency Long-running handlers make applications nonresponsive –Fork off sub-processes for long running things, use events to find out when done. –Break up handlers (event-driven I/O) Can’t maintain local state across events (handler must return) –Manual stack maintenance Stack is used to maintain local data, state and return Events – all local state is lost after scheduling an event 1/4/2016CSE 60641: Operating Systems4

Conclusions Concurrency is fundamentally hard; avoid whenever possible (most of recent machines are multi-core) Threads more powerful than events, but power is rarely needed Threads much harder to program than events; for experts only Use events as primary development tool (both GUIs and distributed systems) Use threads only for performance-critical kernels 1/4/2016CSE 60641: Operating Systems5

Adya et al. Argue that things are little more complicated Task management: preemptive, serial and cooperative (yields control at well defined points) Stack management: manual, automatic I/O management: synchronous, asynchronous Conflict management: –Pessimistic – locks –Optimistic – use speculation; if conflict, roll back and retry Data partitioning 1/4/2016CSE 60641: Operating Systems6

Event-driven: cooperative task management and manual stack management Threaded: preemptive and automatic stack mgmt Sweet spot: cooperative task management, automatic stack management Stack ripping: event driven code –Function scoping: two or more functions represent a single conceptual function 1.Read network event, schedule disk read 2.Process read event, schedule write event –Automatic variables: local (stack variables) need to be moved into heap to survive across yield points 1/4/2016CSE 60641: Operating Systems7

Control structures: entry point must be a language function Debugging stack: call stack must be manually recovered, manual optimization of tail calls The authors show a hybrid approach: manual calling automatic, automatic calling manual 1/4/2016CSE 60641: Operating Systems8

Brewer et al. – Events are a bad idea Weaknesses of threads are artifacts of poor threads Compiler support for thread systems Applicable for high concurrency servers Problems with threads: –Performance: Many attempts to use threads for high concurrency have not performed well Poor implementation. O(n) components –Control flows: encourages programmers to think linearly Robust systems need acknowledgments, even in events 1/4/2016CSE 60641: Operating Systems9

–Synchronization: mechanisms are too heavy-weight Cooperative threads –State management: Thread stacks are an ineffective way to manage live state Dynamic thread stack size management –Scheduling: Threads treat processors are virtual – runtime is too generic and prevents it from making optimal scheduling decisions. Events can perform shortest remaining completion time scheduling, favor certain request streams to maintain locality etc. Duality argument 1/4/2016CSE 60641: Operating Systems10