160 likes | 169 Views
This presentation discusses a cooperative task management approach that eliminates the need for manual stack management in event-driven programming. It introduces the definitions of task and stack management, outlines both automatic and manual stack management methods, and proposes a hybrid approach that combines the benefits of both. The presentation also explores related work and concludes with the advantages of the proposed approach.
E N D
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
Outline • Introduction • Definitions • Stack Management • Hybrid Approach • Related Work • Conclusion
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
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
Cooperative Task Management • Concurrency considered only at I/O yield points • Task must re-validate state after resuming
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 Stack Management
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
Hidden assumptions • Hidden assumptions become explicit • Concurrency • Static check: yielding, atomic • Dynamic check: startAtomic(), endAtomic(), yield()
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
Hybrid approach • Based on Windows fibers • User-level, cooperative threads • Main fiber • Event scheduler • Event handlers • Auxiliary fibers • Blocking code
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/Oand yield back to main fiber
Automatic calling manual • Set up special continuation • Test whether we actuallyswitched fibers • If not, simply return • Invoke event handler • Return to main fiber • When done with task • Resume fiber
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
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
Thank you Questions??? Suggestions!!!