Cooperative Task Management without Manual Stack management Hanyun Tao EECS 582 – W161.

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

Java How to Program, 9/e CET 3640 Professor: Dr. José M. Reyes Álamo © Copyright by Pearson Education, Inc. All Rights Reserved.
CS533 Concepts of Operating Systems Class 5 Integrated Task and Stack Management.
Chapter 5 Processes and Threads Copyright © 2008.
Why Events Are A Bad Idea (for high-concurrency servers) By Rob von Behren, Jeremy Condit and Eric Brewer.
1 CS318 Project #3 Preemptive Kernel. 2 Continuing from Project 2 Project 2 involved: Context Switch Stack Manipulation Saving State Moving between threads,
Cooperative Task Management without Manual Stack Management or, Event-driven Programming is Not the Opposite of Threaded Programming Atul Adya, Jon Howell,
CS533 Concepts of Operating Systems Class 6 The Duality of Threads and Events.
3.5 Interprocess Communication Many operating systems provide mechanisms for interprocess communication (IPC) –Processes must communicate with one another.
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.
3.5 Interprocess Communication
CS533 Concepts of Operating Systems Class 2 Thread vs Event-Based Programming.
CS533 Concepts of Operating Systems Class 7 Integrated Task and Stack Management.
Concurrency, Threads, and Events Robbert van Renesse.
 2004 Deitel & Associates, Inc. All rights reserved. Chapter 4 – Thread Concepts Outline 4.1 Introduction 4.2Definition of Thread 4.3Motivation for Threads.
CS533 Concepts of Operating Systems Class 2 The Duality of Threads and Events.
CS533 Concepts of Operating Systems Class 3 Integrated Task and Stack Management.
1 Chapter 4 Threads Threads: Resource ownership and execution.
Multithreading in Java Nelson Padua-Perez Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
A. Frank - P. Weisberg Operating Systems Introduction to Tasks/Threads.
CS 3013 & CS 502 Summer 2006 Threads1 CS-3013 & CS-502 Summer 2006.
Java How to Program, 9/e CET 3640 Professor: Dr. Reyes Álamo © Copyright by Pearson Education, Inc. All Rights Reserved.
Chapter 51 Threads Chapter 5. 2 Process Characteristics  Concept of Process has two facets.  A Process is: A Unit of resource ownership:  a virtual.
What is Concurrent Programming? Maram Bani Younes.
Cooperative Task Management without Manual Stack Management Or, Event-driven Programming is not the Opposite of Thread Programming Atul Adya, John Howell,
Multithreading Allows application to split itself into multiple “threads” of execution (“threads of execution”). OS support for creating threads, terminating.
Silberschatz, Galvin and Gagne ©2009Operating System Concepts – 8 th Edition Chapter 4: Threads.
Operating Systems Lecture 2 Processes and Threads Adapted from Operating Systems Lecture Notes, Copyright 1997 Martin C. Rinard. Zhiqing Liu School of.
Multithreading in Java Project of COCS 513 By Wei Li December, 2000.
Java Threads 11 Threading and Concurrent Programming in Java Introduction and Definitions D.W. Denbo Introduction and Definitions D.W. Denbo.
Processes & Threads Bahareh Goodarzi. Single & Multiple Thread of control code files data code files data.
 2004 Deitel & Associates, Inc. All rights reserved. 1 Chapter 4 – Thread Concepts Outline 4.1 Introduction 4.2Definition of Thread 4.3Motivation for.
Cooperative Task Management without Manual Stack Management or, Event-driven programming is Not the Opposite of Threaded Programming Atul Adya, Jon Howell,
Review The Joys and Pains of Threads and Multithreading –what is a thread –threads vs. processes –opportunities and risks.
Multithreading in Java Sameer Singh Chauhan Lecturer, I. T. Dept., SVIT, Vasad.
Introduction to Operating Systems and Concurrency.
CS603 Basics of underlying platforms January 9, 2002.
Cooperative Task Management without Manual Stack Management OR Presented by Tina Swenson CS533 - February 12, 2007 Event-driven Programming is Not the.
Department of Computer Science and Software Engineering
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 4: Threads.
CSE 60641: Operating Systems Next topic: CPU (Process/threads/scheduling, synchronization and deadlocks) –Why threads are a bad idea (for most purposes).
1 Cooperative Task Management without Manual Stack Management or Event-driven Programming is not the Opposite of Threaded Programming Atul Adya, Jon Howell,
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.
1 OS Review Processes and Threads Chi Zhang
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.
Embedded Computer - Definition When a microcomputer is part of a larger product, it is said to be an embedded computer. The embedded computer retrieves.
1 Why Threads are a Bad Idea (for most purposes) based on a presentation by John Ousterhout Sun Microsystems Laboratories Threads!
Operating System Concepts
1 Threads, SMP, and Microkernels Chapter 4. 2 Process Resource ownership - process includes a virtual address space to hold the process image Scheduling/execution-
Lecturer 3: Processes multithreaded Operating System Concepts Process Concept Process Scheduling Operation on Processes Cooperating Processes Interprocess.
Multithreading vs. Event Driven in Code Development of High Performance Servers.
Chapter 4 – Thread Concepts
Threads & Multithreading
Chapter 4: Threads.
Why Events Are A Bad Idea (for high-concurrency servers)
Chapter 4 – Thread Concepts
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,
Chapter 15, Exploring the Digital Domain
CS 143A Quiz 1 Solution.
Threads and Concurrency
Threads Chapter 4.
Threads Chapter 5 2/17/2019 B.Ramamurthy.
Threads Chapter 5 2/23/2019 B.Ramamurthy.
Still Chapter 2 (Based on Silberchatz’s text and Nachos Roadmap.)
CS510 Operating System Foundations
Why Events Are a Bad Idea (for high concurrency servers)
CS703 – Advanced Operating Systems
Presentation transcript:

Cooperative Task Management without Manual Stack management Hanyun Tao EECS 582 – W161

The War of Programming Model Event Driven v.s Multithreaded Berkeley: Stanford: EECS 582 – W162

Event Driven Programming Model Easy to use when reasoning about concurrency Code difficult to read Code difficult to maintain Good for single-processor (cooperative concurrency) EECS 582 – W163

Multithreaded Programming Model Code is more readable Code is easier to maintain Difficult to reason about concurrency with threads Good for multi-processors (true concurrency) EECS 582 – W164

Goal : Get the Best from both World! EECS 582 – W165

Definition of Terms  Task Management  Stack Management  I/O Management  Conflict Management  Data Partitioning EECS 582 – W166

Task Management Preemptive Task Management Tasks can interleave on uniprocessor or overlap on multiprocessor Serial Task Management One at a time, no conflict Cooperative Task Management Only yields control to other tasks at a well-defined point Such as wait for long-running I/O EECS 582 – W167

Stack Management Manual Stack Management Inherent in Cooperative Task Management Finishing a “single” tasks may require to rip stack for multiple time Automatic Stack Management Inherent in pre-emptive Task Management Downside: Hidden concurrency assumptions Solution: Static & Dynamic Check EECS 582 – W168

Other Management Models I/O Management Asynchronous versus Synchronous I/O Management Conflict Management Concerned with avoiding resource conflicts Serial & Cooperative (between yield point) – Atomic, no need to avoid conflict Preemptive Task Management – need synchronization primitives Data Partitioning The more you break up your shared state, the fewer conflicts you should have EECS 582 – W169

The Sweet Spot EECS 582 – W1610 Cooperative tasks are the most desirable when reasoning about concurrency usually associated with event-driven programming Automatic stack management is the most desirable when reading/maintaining code Usually associated with threaded or serial programming

The Sweet Spot EECS 582 – W1611

Solution Build a system that uses Cooperative Task Management without Manual Stack Management Pulls together the best of both worlds Ease of reasoning about concurrency Readable/maintainable code EECS 582 – W1612

Implementation Detail Use fibers User level thread package Many-to-many threading solution for Windows Platform Non-preemptive Scheduled cooperatively – one fiber hands control off to another fiber Scheduling multiple fiber on a single thread EECS 582 – W1613

Implementation Detail A Scheduler runs on a MainFiber Schedule both manual stack management code and automatic stack management code Code written with manual stack management always runs on a fiber other than MainFiber Compute-Only functions can run on any fiber EECS 582 – W1614

Manual Calling Automatic Uses a Continuation to Fiber Adapter (CFA): Glues the notion of a continuation to the notion of a blocking call Handles the details of the continuation: rips itself into two, schedules the second half within the first and calls the blocking function on the second fiber Second half of CFA uses continuation to call the original task’s continuation EECS 582 – W1615

Manual Calling Automatic EECS 582 – W1616

Automatic Calling Manual Uses a Fiber to Continuation Adapter (FCA) FCA executes on secondary thread May short-circuit if no blocking occurred Glues the notion of a blocking call to one that uses a continuation Handles the details of the transformation: creates a new “fiberContinuation” which causes MainFiber to switch back to the secondary fiber, executes the manual stack function and switches back to the main thread FiberContinuation simply resumes the suspended fiber EECS 582 – W1617

Automatic Calling Manual EECS 582 – W1618

Conclusion Clarify the Debate of Event Driven & Multithreaded Model by Identifying two separate Concepts Task Management Stack Management Presents a hybrid model that adapts between code with automatic and with manual stack management Enabling cooperation among disparate programmers & code bases EECS 582 – W1619