Threads vs Events TAME Event Style Programming with
- Slides: 11
Threads vs. Events TAME – Event Style Programming with Threads 5204 – Operating Systems
Threads vs. Events TAME • expressive abstractions for event-based programming • implemented via source-source translation • avoids stack ripping • type safety and composability via templates M. Krohn, E. Kohler, M. F. Kaashoek, “Events Can Make Sense, ” USENIX Annual Technical Conference, 2007, pp. 87 -100. CS 5204 – Operating Systems 2
Threads vs. Events A typical thread programming problem c f (blocking, synchronous operation, e. g. , I/O) Problem: the thread becomes blocked in the called routine (f) and the caller (c) is unable to continue even if it logically is able to do so. CS 5204 – Operating Systems 3
Threads vs. Events A partial solution c f (non-blocking, asynchronous operation, e. g. , I/O) register handler (signal + data) Issues • Synchronization: how does the caller know when the signal has occurred without busy-waiting? • Data: how does the caller know what data resulted from the operation? CS 5204 – Operating Systems 4
Threads vs. Events A “Tame” solution c f e (1) (2) (4) (5) (11) (3) (non-blocking, asynchronous operation, e. g. , I/O) (10) r: <I> slot <T> a; (9) e(a): <T> handler (7) a <- data wait point <I> (8) e. trigger(data) rendezvous<I> CS 5204 – Operating Systems <T> (signal + data) (6) event<T> 5
Threads vs. Events Tame Primitives CS 5204 – Operating Systems 6
Threads vs. Events An example tamed gethost_ev(dsname, event<ipaddr> e); CS 5204 – Operating Systems 7
Threads vs. Events Variations on control flow parallel control flow window/pipeline control flow CS 5204 – Operating Systems 8
Threads vs. Events Event IDs & Composability CS 5204 – Operating Systems 9
Threads vs. Events Closures f( …params…) { copy rendezvous<> r; tvars { …locals…}; copy closure twait(r); continue_here: r: } Smart pointers and reference counting insure correct deallocation of events, redezvous, and closures. CS 5204 – Operating Systems 10
Threads vs. Events Performance (relative to Capriccio) CS 5204 – Operating Systems 11
- Tame events
- "wicked problem"
- Storm on the island
- To tame the perilous skies
- What is the prison program quantum mechanics
- Tame
- Wind dives and strafes invisibly
- Mutually exclusive vs non mutually exclusive
- Sentinel incident reporting
- Compound probability
- Independent event vs dependent event
- Independent and dependent probability