E N D
Cooperative Task Management without Manual Stack Managementor, Event-driven programming is Not the Opposite of Threaded ProgrammingAtul Adya, Jon Howell, Marvin Theimer, William J. Bolosky, John R. DouceurMicrosoft ResearchPresented by: Yujing He ( hey@cecs.pdx.edu )CS 533-April 24th, 2006
Threads & Fibers ☆ Threads ♦ lightest unit of kernel scheduling; ♦ preemptively scheduled; ♦ a stack and a copy of the registers; ☆ Fibers ♦implemented in user space; ♦ cooperatively scheduled; ♦ efficient context switching;
Definitions ☆ Task Management preemptive, serial, cooperative ☆ Stack Management manual (event-driven), automatic (procedure-oriented) ☆ I/O Management synchronous, asynchronous ☆ Conflict Management pessimistic, optimistic ☆ Data Partitioning might reduce resource conflict
Other Concepts ☆ Continuation ♦ bundles state indicating where the event left off working on the task; ♦ plus a reference to an event-handler that encodes what should be done when the requested I/O has completed. ☆ Stack Ripping ♦ functions along the path ripped into more parts because of I/O calls; ♦ primary drawback to manual stack management in event-driven programming
Hybrid Approach ☆ Based on Windows Operating System ♦ Threads are scheduled preemptively; Fibers are scheduled cooperatively; ♦ Scheduling multiple fibers on a thread; Only one fiber is active at any time. ♦ Using adapter to connect between threaded programming and event programming; ☆ Examples ♦ Manual calling Automatic—Event calling Thread; ♦ Automatic calling Manual—Thread calling Event;
Hybrid Approach (Continued) ☆ Function Names GetCertData—Looks up certificate in the memory catch or disk/network and returns the answer; (manual) GetCAInfo—looks in a hash-table for a specified certificate authority (CA) id and returns a pointer to the corresponding object; (manual) VerifyCert—calls “GetCAInfo” to obtain a CA with which to verify a certificate; (automatic) FetchCert—fetches a security certificate using “GetCertData” and then calls “VerifyCert” in order to confirm its validity; (manual) FiberContinue—a continuation for event handlers; (manual) CFA—Continuation-to-Fiber Adapter (in Manual calling Automatic) FCA—Fiber-to-Continuation Adapter(in Automatic calling Manual)
ManualCallingAutomaticFetchCert—fetches a security certificate using “GetCertData” and then calls “VerifyCert” in order to confirm its validity;
ManualCallingAutomaticFetchCert—fetches a security certificate using “GetCertData” and then calls “VerifyCert” in order to confirm its validity;
AutomaticCallingManualFetchCert—fetches a security certificate using “GetCertData” and then calls “VerifyCert” in order to confirm its validity;
AutomaticCallingManualFetchCert—fetches a security certificate using “GetCertData” and then calls “VerifyCert” in order to confirm its validity;
AutomaticCallingManualShort Circuit Branch No I/O Block
Implementation ☆Farsite: a distributed, secure, serverless file system running over desktops; (Windows NT) ☆ UCoM: a wireless phone application for hand-held devices such as PDAs. (Windows CE)
Conclusion ☆ Task management is best done cooperatively, and stack management is best done automatically ; ☆ A hybrid model adapts between code with automatic and with manual stack management, enabling cooperation among disparate programmers and software evolution of disparate code bases; ☆ The hybrid approach is in fact complicated, but it is also necessary sometimes.
References [1] Stephen Ferg; Event-Driven Programming: Introduction, Tutorial, history; 2006. http://eventdrivenpgm.sourceforge.net/ [2] Atul Adya, Jon Howell, Marvin Theimer, et al. Cooperative Task Management without Manual Stack Management or, Event-driven Programming is Not the Opposite of Threaded Programming. Proceedings of the USENIX 2002 Annual Conference, pages 289-302, June 2002. [3] Wikipedia, the free encyclopedia; http://en.wikipedia.org/wiki/Main_Page [4] Satish Gottimukkala; Presentation of Cooperative Task Management without ManualStack Management or, Event-driven Programming is Not the Opposite of Threaded Programming; http://web.cecs.pdx.edu/~walpole/class/cs533/spring2005/slides/71.ppt