Optimizing Cooperative and Multithreaded Task Management Models

cooperative task management without manual stack n.w
1 / 19
Embed
Share

Explore the contrast between event-driven and multithreaded programming models in EECS 582. Understand the benefits and challenges of each approach and the importance of effective task and stack management in achieving optimal system performance.

  • Task Management
  • Stack Management
  • Cooperative Concurrency
  • Multithreaded Programming
  • EECS Research

Uploaded on | 0 Views


Download Presentation

Please find below an Image/Link to download the presentation.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.

You are allowed to download the files provided on this website for personal or commercial use, subject to the condition that they are used lawfully. All files are the property of their respective owners.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.

E N D

Presentation Transcript


  1. Cooperative Task Management without Manual Stack management Hanyun Tao EECS 582 W16 1

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

  3. 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 W16 3

  4. 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 W16 4

  5. GoalGet the Best from both World! EECS 582 W16 5

  6. Definition of Terms Task Management Stack Management I/O Management Conflict Management Data Partitioning EECS 582 W16 6

  7. 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 W16 7

  8. 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 W16 8

  9. 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 W16 9

  10. The Sweet Spot 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 EECS 582 W16 10

  11. The Sweet Spot EECS 582 W16 11

  12. 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 W16 12

  13. 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 W16 13

  14. Main Fiber Secondary Fiber Implementation Detail Ta Scheduler Call Ta State: Call I/O and wait A=1. B=2, C=3 I/O Return control to Main Fiber (Scheduler) Scheduler Ty 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 Tz I/O Returns Resume Ta Ta State: A=1, B=2, C=3 Complete task and return control to main fiber Scheduler EECS 582 W16 14

  15. 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 W16 15

  16. Manual Calling Automatic EECS 582 W16 16

  17. 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 W16 17

  18. Automatic Calling Manual EECS 582 W16 18

  19. 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 W16 19

Related


More Related Content