/
Cooperative Task Management without Manual Stack Management Cooperative Task Management without Manual Stack Management

Cooperative Task Management without Manual Stack Management - PowerPoint Presentation

sherrill-nordquist
sherrill-nordquist . @sherrill-nordquist
Follow
408 views
Uploaded On 2016-09-07

Cooperative Task Management without Manual Stack Management - PPT Presentation

or Eventdriven Programming is Not the Opposite of Threaded Programming Presented by Li Lei Atul Adya Jon Howell Marvin Theimer William J Bolosky John R Douceur Microsoft Research ID: 462092

asm msm management calls msm asm calls management procedure event adaptor code task stack problem hybrid programming including problems

Share:

Link:

Embed:

Download Presentation from below link

Download Presentation The PPT/PDF document "Cooperative Task Management without Manu..." is the property of its rightful owner. Permission is granted to download and print the materials on this web site for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.


Presentation Transcript

Slide1

Cooperative Task Management without Manual Stack Managementor, Event-driven Programming is Not the Opposite of Threaded Programming

Presented by Li Lei

Atul

Adya

, Jon Howell, Marvin

Theimer

, William J.

Bolosky

,

John

R. Douceur

Microsoft ResearchSlide2

AgendaIntroductionTask Management and Stack Management

A Hybrid ApproachConclusion

2Slide3

IntroductionMotivationPeople think “event-driven” programming is the opposite of “multithreaded” programming.

Combination of these two styles has some problems.

SolutionWe can combine these two styles, with concerning two issues.Provide an approach to solving these problems.Slide4

AgendaIntroductionTask Management and Stack Management

A Hybrid ApproachConclusion

4Slide5

Task ManagementPreemptive Task Management

Execution of tasks can interleave on uniprocessor or overlap on multiprocessor

Efficient but has race conditionsSerial 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 managementSlide6

A

B

B

A

A

A

B

A

B

A

I/O

I/O complete

Preemptive

Serial

CooperativeSlide7

Stack ManagementAutomatic Stack Management (ASM)

With ASM, the programmer expresses each complete task as a single procedure in the source languageIt is associated with the style “multithreaded” programmingManual Stack Management (MSM)

MSM requires a programmer to rip the code for any given task into event handlersEvent handlers are procedures that respond to the events

It is associated with the style “event-driven” programmingSlide8

ASM vs. MSM

P()

I/O

I/O

completes

I/O

A procedure p with ASM

A procedure P with its two event handlers P1, P2, by MSM

P1()

P2()Slide9

Based on these issues, we clarify …

Stack Management

Task Management

Cooperative

Preemptive

Manual

Automatic

Event-driven

Multithreaded

Sweet spot

Not

OppossiteSlide10

Disadvantages of MSM and ASM

Disadvantages of MSMAffect on program structuresIntroduce more rules about semantics

Software evolution exacerbates this problemDisadvantages of ASMCallee

procedure as yielding affects the property of caller procedure

Software evolution bring such a problemSlide11

AgendaIntroductionTask Management and Stack Management

A Hybrid ApproachConclusion

11Slide12

A Hybrid Approach…Combination of ASM and MSM

Combines their advantages and avoid their disadvantagesIn 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)Slide13

MSM calls ASM Problem 1P1

F()

I/O

F()

P2

P is a procedure with MSM, including two event handler P1, and P2.

F is a procedure with ASM, including I/O operations.

P1 calls F, and P2 is invoked when F finishes

They are running at a single thread

Both P and F block on I/O !Slide14

ASM calls MSM Problem 2P

F1

F2

P

P is a procedure with ASM

F is a procedure with MSM, and two event handlers, including I/O operations,

P calls F1, and F2 is invoked when I/o completes

P

Immediately Return to P once F1 finishes

Second return to P after F2 finishes I/O completion .

I/O

I/O

CompletetionSlide15

How to solve these problems?Use some glue code that can connect them smoothly …

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.

Code with ASM

Code with MSM

AdaptorSlide16

MSM calls ASM Problem 1P1

F()

I/O

F()

P2

P is a procedure with MSM, including two event handler P1, and P2.

F is a procedure with ASM, including I/O operations.

P1 calls F, and P2 is invoked when F finishes

They are running at a single threadSlide17

MSM calls ASMP1

F()

I/O

F()

P2

Adaptor

Adaptor

P1

Adaptor fork a new thread and execute F on it.

The control can be schedule back.

F calls back

adptor

, with P2, handler.Slide18

ASM calls MSM Problem 2P

F1

F2

P

P is a procedure with ASM

F is a procedure with MSM, and two event handlers, including I/O operations,

P calls F1, and F2 is invoked when I/o completes

P

I/O

I/O

CompletetionSlide19

ASM calls MSMP

F1

F2

P

Adaptor

Adaptor

I/O

Adaptor

Adaptor calls F1 instead of P calls F1.

I/O

Adaptor does not return to p, scheduling other threads.

The adaptor calls P finally

I/O completeSlide20

AgendaIntroductionTask Management and Stack Management

A Hybrid ApproachConclusion

20Slide21

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 MSMAdaptor can solve this problem by connecting each of them in the middle.Slide22

Questions ?