Download presentation
Presentation is loading. Please wait.
Published byHector Small Modified over 9 years ago
1
Cooperative Task Management without Manual Stack Management Or, Event-driven Programming is not the Opposite of Thread Programming Atul Adya, John Howell, Marvin Theimer, William J. Bolosky, John R. Douceur Microsoft Research Presented by : Satish Gottimukkala
2
Outline Introduction Definitions Stack Management Hybrid Approach Related Work Conclusion
3
Introduction Two major Concurrency models : Multithreaded programming Difficult to handle race conditions, deadlocks (Ousterhout 96) Event-driven programming Task explicitly yields control by returning to the scheduler Task runs serially between yield points Vs
4
Definitions Task management Serial, preemptive, cooperative Stack management Automatic, manual I/O management Synchronous, asynchronous Conflict management With concurrency, need locks, semaphores, monitors Data partitioning Shared, task-specific
5
Cooperative Task Management Cooperative Task Management Concurrency considered only at I/O yield points Task must re-validate state after resuming
6
Task Management Vs Stack Management
7
Stack Management Automatic Stack Management (ASM) Each complete task a procedure Task state stored on stack Allows natural code structure Manual Stack Management (MSM) Each step an event handler Event handlers invoked by scheduler Control flow expressed through continuations Necessary state + next event handler Forces programmer to abandon basic programming language features Mistakenly conflated with cooperative task mgmt
8
Stack Ripping Function Scoping Two or more functions represent a single conceptual function Automatic variables From stack to heap Control structures Loops can get nasty Debugging stack Need to recover call stack
9
Hidden assumptions Hidden assumptions become explicit Concurrency Static check: yielding, atomic Dynamic check: startAtomic(), endAtomic(), yield()
10
Hybrid approach Separate out concerns of task and stack mgmt Cooperative task management Avoid synchronization issues Allow interactions between manual and automatic stack mgmt code styles
11
Hybrid approach Based on Windows fibers User-level, cooperative threads Main fiber Event scheduler Event handlers Auxiliary fibers Blocking code
12
Manual calling automatic Set up continuation Copy result Invoke original continuation Set up fiber Switch to fiber Issue: I/O Are we really blocking? No, we use asynchronous I/O and yield back to main fiber
13
Automatic calling manual Set up special continuation Test whether we actually switched fibers If not, simply return Invoke event handler Return to main fiber When done with task Resume fiber
14
Related work “Event-driven” to reduce concurrency bugs [Oust96] Cooperative task management conflated with MSM “Event-driven” model for performance Popular for web servers Inter-stage: each task reads as in MSM Equivalence of “procedure-oriented” and “message-oriented” systems [Lauer+Needham] Cooperative task management not considered
15
Conclusion Clears debate between event driven versus threaded programming models by separating concerns of task and stack management Manual stack management leads to poor code structure Code evolution exacerbates problem Automatic stack management leads to natural code structure Adopts hybrid approach which shows that Manual and Automatic Stack Management code can co-exist Enables cooperation among disparate programmers and software evolution of disparate code bases
16
Thank you Thank you Questions??? Questions??? Suggestions!!! Suggestions!!!
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.