View Full Document

Events Can Make Sense



View the full content.
View Full Document
View Full Document

16 views

Unformatted text preview:

Events Can Make Sense Max Krohn MIT CSAIL Eddie Kohler UCLA Frans Kaashoek MIT CSAIL Straw Poll How To Manage Concurrency In Network Applications Threads Straw Poll How To Manage Concurrency In Network Applications Events As much as I love events I admit they make code unreadable True stack ripping sucks Stack Ripping Before Adya et al 02 int send email const char email dnsname hostname extract hostname email ipaddr addr gethostbyname hostname int fd tcp connect addr return do smtp fd email Stack Ripping After void send email ev const char email event int done dnsname hostname extract hostname email gethostbyname email wrap send email 2 email done void send mail 2 const char email event int done ipaddr addr tcp connect addr wrap send email 3 email done void send mail 3 const char email event int done int fd do smtp fd email wrap send mail 4 done void send mail 4 int result event int done done trigger result Just use threads But What s Wrong with Threads Good at launch and then immediate block int rc read fd buf 1024 Not as good at parallel launch Difficult to prevent a thread from blocking Need to spawn new threads Stack rip to move state between stacks Synchronize entry and exit Threads n Serial Sends void send serial int results const char emails int n for int i 0 i n i results i send email emails i Threads n Parallel Sends Contribution Tame new primitives for high performance network programming Explicit control over concurrency as in events Good readability as in threads Continues Adya et al s line of research Usenix 2002 Makes practical ideas from Haskell and Concurrent ML Outline 1 Design 2 Implementation 3 Evaluation Tame primitive event Creating a new event event e mkevent Passed from caller to callee callee e Callee triggers an event to tell caller when to proceed void callee event e e trigger Tame primitive twait Execute all code in twait Only continue past once all events created inside have triggered twait if x foo mkevent while y bar mkevent Tame



Access the best Study Guides, Lecture Notes and Practice Exams

Loading Unlocking...
Login

Join to view Events Can Make Sense and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Events Can Make Sense and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?