Error Handling via the Happens-Before Relation Nicholas D. Matsakis Thomas R. Gross ETH Zurich 1 Sunday, April 18, 2010
Exception Handling • Goal of this talk: • Extend exception handling into a parallel setting 2 Sunday, April 18, 2010
Sequential Exceptions void child() { statement 1; statement 2; statement 3; } 3 Sunday, April 18, 2010
Sequential Exceptions void child() { statement 1; statement 2; statement 3; } 3 Sunday, April 18, 2010
Sequential Exceptions void child() { statement 1; statement 2; statement 3; } 3 Sunday, April 18, 2010
Sequential Exceptions void child() { statement 1; statement 2; statement 3; } 3 Sunday, April 18, 2010
Sequential Exceptions void child() { statement 1; statement 2; statement 3; } 3 Sunday, April 18, 2010
Sequential Exceptions void child() { statement 1; statement 2; statement 3; } 3 Sunday, April 18, 2010
Sequential Exceptions void child() { statement 1; statement 2; statement 3; } 4 Sunday, April 18, 2010
Sequential Exceptions void child() { statement 1; statement 2; statement 3; } 4 Sunday, April 18, 2010
Sequential Exceptions void child() { statement 1; ! statement 2; statement 3; } 4 Sunday, April 18, 2010
Sequential Exceptions void child() { statement 1; ! statement 2; statement 3; } 4 Sunday, April 18, 2010
Sequential Exceptions void child() { statement 1; ! statement 2; Subsequent statement 3; statements } are skipped. 4 Sunday, April 18, 2010
Sequential Exceptions void parent() { child(); ...; } 5 Sunday, April 18, 2010
Sequential Exceptions void parent() ! { child(); ...; } 5 Sunday, April 18, 2010
Sequential Exceptions void parent() ! { child(); ...; } 5 Sunday, April 18, 2010
Sequential Exceptions void parent() ! { child(); Subsequent statements ...; in outer } scopes are also skipped. 5 Sunday, April 18, 2010
Sequential Exceptions void grandparent() { try { parent(); ... } catch (...) { } } 6 Sunday, April 18, 2010
Sequential Exceptions void grandparent() { ! try { parent(); ... } catch (...) { } } 6 Sunday, April 18, 2010
Sequential Exceptions void grandparent() { ! try { parent(); ... } catch (...) { } } 6 Sunday, April 18, 2010
Sequential Exceptions void grandparent() { ! try { parent(); ... } catch (...) { Continues } until caught. } 6 Sunday, April 18, 2010
Key Points • After an error occurs: • Subsequent statements are skipped • Until the error is caught in some enclosing scope 7 Sunday, April 18, 2010
Exceptions and Threads • In a sequential setting, subsequent statements are easy to identify. • Not with threads. 8 Sunday, April 18, 2010
Threads write read Buffer Producer Consumer 9 Sunday, April 18, 2010
Threads write read Buffer Producer Consumer 9 Sunday, April 18, 2010
Threads write read Buffer Producer Consumer 9 Sunday, April 18, 2010
Threads write read Buffer Producer Consumer 9 Sunday, April 18, 2010
Threads write read Buffer Producer Consumer 9 Sunday, April 18, 2010
Threads write read Buffer Producer Consumer 10 Sunday, April 18, 2010
Threads write read Buffer Producer Consumer 10 Sunday, April 18, 2010
Threads write read Buffer Producer Consumer 10 Sunday, April 18, 2010
Threads write read ! Buffer Producer Consumer 10 Sunday, April 18, 2010
Threads write read ! Buffer Producer Consumer 10 Sunday, April 18, 2010
Threads write read ! Buffer Producer Consumer 10 Sunday, April 18, 2010
Invisible Ordering • Ordering between statements in different threads is never stated explicitly • Created by side-effects • signals, locks 11 Sunday, April 18, 2010
Intervals • An alternative model for parallel programs • Based on an explicit happens-before relation 12 Sunday, April 18, 2010
Interval Interval a = a interval { statement 1; statement 2; }; 13 Sunday, April 18, 2010
Interval Interval a = interval {...}; a Interval b = b c interval {...}; Interval c = interval {...}; 14 Sunday, April 18, 2010
Happens Before Interval a = interval {...}; a b Interval b = interval {...}; Interval c = interval {...}; c a.end.addHb(c.start); b.end.addHb(c.start); 15 Sunday, April 18, 2010
Happens Before Interval a = interval {...}; a b Interval b = interval {...}; Interval c = interval {...}; c a.end.addHb(c.start); b.end.addHb(c.start); 15 Sunday, April 18, 2010
Happens Before Interval a = interval {...}; a b Interval b = interval {...}; Interval c = interval {...}; c a.end.addHb(c.start); b.end.addHb(c.start); 15 Sunday, April 18, 2010
Hierarchy par void method(Interval par) { a b a = interval(par) {...} b = interval(par) {...} c = interval(par) {...} a.end.addHb(c.start); c b.end.addHb(c.start); } 16 Sunday, April 18, 2010
Hierarchy par void method(Interval par) { a b a = interval(par) {...} b = interval(par) {...} c = interval(par) {...} a.end.addHb(c.start); c b.end.addHb(c.start); } 16 Sunday, April 18, 2010
Hierarchy par void method(Interval par) { a b a = interval(par) {...} b = interval(par) {...} c = interval(par) {...} a.end.addHb(c.start); c b.end.addHb(c.start); } 16 Sunday, April 18, 2010
Hierarchy par void method(Interval par) { a b a = interval(par) {...} b = interval(par) {...} c = interval(par) {...} a.end.addHb(c.start); c b.end.addHb(c.start); } 16 Sunday, April 18, 2010
Hierarchy par void method(Interval par) { a b a = interval(par) {...} b = interval(par) {...} c = interval(par) {...} a.end.addHb(c.start); c b.end.addHb(c.start); } 16 Sunday, April 18, 2010
Two-Phase Execution par par = interval { doSomething(); method(par); doSomethingElse(); } 17 Sunday, April 18, 2010
Two-Phase Execution par par = interval { doSomething(); method(par); doSomethingElse(); } 17 Sunday, April 18, 2010
Two-Phase Execution par par = interval { doSomething(); method(par); a b doSomethingElse(); c } 17 Sunday, April 18, 2010
Two-Phase Execution par par = interval { doSomething(); method(par); a b doSomethingElse(); c } 17 Sunday, April 18, 2010
Two-Phase Execution par par = interval { doSomething(); method(par); a b doSomethingElse(); c } 17 Sunday, April 18, 2010
Error Handling • If an exception is thrown at point P and caught at point Q: • Statements that happen after P and before Q are skipped. • An interval may catch errors that occur in it or its children. 18 Sunday, April 18, 2010
Everything Goes Well par par = interval { doSomething(); method(par); doSomethingElse(); } 19 Sunday, April 18, 2010
Everything Goes Well par par = interval { doSomething(); method(par); doSomethingElse(); } 19 Sunday, April 18, 2010
Everything Goes Well par par = interval { doSomething(); method(par); a b doSomethingElse(); c } 19 Sunday, April 18, 2010
Everything Goes Well par par = interval { doSomething(); method(par); a b doSomethingElse(); c } 19 Sunday, April 18, 2010
Everything Goes Well par par = interval { doSomething(); method(par); a b doSomethingElse(); c } 19 Sunday, April 18, 2010
Everything Goes Well par par = interval { doSomething(); method(par); a b doSomethingElse(); c } 19 Sunday, April 18, 2010
Everything Goes Well par par = interval { doSomething(); method(par); a b doSomethingElse(); c } 19 Sunday, April 18, 2010
Child Fails par par = interval { doSomething(); method(par); doSomethingElse(); } 20 Sunday, April 18, 2010
Child Fails par par = interval { doSomething(); method(par); a b doSomethingElse(); c } 20 Sunday, April 18, 2010
Child Fails par par = interval { doSomething(); ! method(par); a b doSomethingElse(); c } 20 Sunday, April 18, 2010
Child Fails par par = interval { doSomething(); ! method(par); a b doSomethingElse(); c } 20 Sunday, April 18, 2010
Child Fails par par = interval { doSomething(); ! method(par); a b doSomethingElse(); c S } 20 Sunday, April 18, 2010
Child Fails par par = interval { doSomething(); ! method(par); a b doSomethingElse(); c S } 20 Sunday, April 18, 2010
Parent Fails par par = interval { doSomething(); method(par); doSomethingElse(); } 21 Sunday, April 18, 2010
Parent Fails par par = interval { doSomething(); method(par); a b doSomethingElse(); c } 21 Sunday, April 18, 2010
Parent Fails par par = interval { ! doSomething(); method(par); a b doSomethingElse(); c } 21 Sunday, April 18, 2010
Parent Fails par par = interval { ! doSomething(); method(par); a b doSomethingElse(); c } 21 Sunday, April 18, 2010
Parent Fails par par = interval { ! doSomething(); method(par); a b S S doSomethingElse(); c S } 21 Sunday, April 18, 2010
Recommend
More recommend