cooperative task management without manual stack
play

Cooperative Task Management without Manual Stack Management or, - PowerPoint PPT Presentation

Cooperative Task Management without Manual Stack Management or, Event-driven Programming is Not the Opposite of Threaded Programming Atul Adya, Jon Howell, Marvin Theimer, William J. Bolosky, John R. Douceur Microsoft Research Presented by Li


  1. Cooperative Task Management without Manual Stack Management or, Event-driven Programming is Not the Opposite of Threaded Programming Atul Adya, Jon Howell, Marvin Theimer, William J. Bolosky, John R. Douceur Microsoft Research Presented by Li Lei

  2. Agenda 1. Introduction 2. Task Management and Stack Management 3. A Hybrid Approach 4. Conclusion 2

  3. Introduction • Motivation – People think “event-driven” programming is the opposite of “multithreaded” programming. – Combination of these two styles has some problems. • Solution – We can combine these two styles, with concerning two issues. – Provide an approach to solving these problems.

  4. Agenda 1. Introduction 2. Task Management and Stack Management 3. A Hybrid Approach 4. Conclusion 4

  5. Task Management • Preemptive Task Management – Execution of tasks can interleave on uniprocessor or overlap on multiprocessor – Efficient but has race conditions • Serial Task Management – Executes tasks without any interleavings – No race condition but inefficient, e.g blocking on I/O • Cooperative Task Management – A task code only yields control to other tasks at well-defined point in its execution – Preserves the advantages of Preemptive and serial task management

  6. Preemptive Serial Cooperative A A A B I/O B I/O A complete B B A A

  7. Stack Management • Automatic Stack Management (ASM) – With ASM, the programmer expresses each complete task as a single procedure in the source language – It is associated with the style “multithreaded” programming • Manual Stack Management (MSM) – MSM requires a programmer to rip the code for any given task into event handlers – Event handlers are procedures that respond to the events – It is associated with the style “event-driven” programming

  8. ASM vs. MSM A procedure P with its two event A procedure p with ASM handlers P1, P2, by MSM P1() P() I/O I/O I/O completes P2()

  9. Based on these issues, we clarify … Sweet spot Automatic Multithreaded Stack Management No Not Oppo possit ite Manual Event-driven Cooperative Preemptive Task Management

  10. Disadvantages of MSM and ASM • Disadvantages of MSM – Affect on program structures – Introduce more rules about semantics – Software evolution exacerbates this problem • Disadvantages of ASM – Callee procedure as yielding affects the property of caller procedure – Software evolution bring such a problem

  11. Agenda 1. Introduction 2. Task Management and Stack Management 3. A Hybrid Approach 4. Conclusion 11

  12. A Hybrid Approach… • Combination of ASM and MSM – Combines their advantages and avoid their disadvantages – In software development, programmers working on a same project can use what ever styles they like • Some problems exist in the hybrid approach – The code with MSM calls the code with ASM (MSM calls ASM) – The code with ASM calls the code with MSM (ASM calls MSM)

  13. MSM calls ASM Problem 1 • P is a procedure with MSM, including two event handler P1, and P2. P1 • F is a procedure with ASM, including I/O operations. • P1 calls F, and P2 is invoked when F finishes F() • They are running at a single thread I/O Both th P P and F block ck F() on I/ I/O ! ! P2

  14. ASM calls MSM Problem 2 • P is a procedure with ASM • F is a procedure with MSM, and two event P handlers, including I/O operations, • P calls F1, and F2 is invoked when I/o completes F1 Immediate ately Return rn to P P o once F1 1 f finishes I/O I/O Completetion P F2 Second re retu turn to to P P afte after F2 f 2 finish shes es I I/O c complet etion . . P

  15. How to solve these problems? Use e some glue code e that can connec ect them smoothly … y … The approach in the paper uses an adaptor to insert between the code with ASM and the code with MSM such that the codes with different styles can not directly communicate. Adaptor Code with MSM Code with ASM

  16. MSM calls ASM Problem 1 • P is a procedure with MSM, including two event handler P1, and P2. P1 • F is a procedure with ASM, including I/O operations. • P1 calls F, and P2 is invoked when F finishes F() • They are running at a single thread I/O F() P2

  17. MSM calls ASM Ad Adap aptor r fo fork rk a a new thre thread P1 an and exe xecu cute F F on it. t. Adaptor The e control can be sched edule e F() back ck. P1 I/O F() F F cal calls back ack adptor, w with P2, Adaptor handler er. P2

  18. ASM calls MSM Problem 2 • P is a procedure with ASM • F is a procedure with MSM, and two event P handlers, including I/O operations, • P calls F1, and F2 is invoked when I/o completes F1 I/O I/O Completetion P F2 P

  19. ASM calls MSM Adaptor c calls F1 1 inst stead o of P P P calls lls F1. Adaptor F1 Ad Adap aptor r does not t re retu turn rn to to Adaptor I/O p, s sched eduling other er t threa eads. s. I/O I/O complete F2 Adaptor The a adaptor calls P finally P

  20. Agenda 1. Introduction 2. Task Management and Stack Management 3. A Hybrid Approach 4. Conclusion 20

  21. Conclusion • “Event-driven” is not the opposite of “multithreaded” – There is a combination that uses both of them: Cooperative Task Management with automatic stack management • Some problems are addressed in combination – Interactions between ASM and MSM – Adaptor can solve this problem by connecting each of them in the middle.

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend