error handling via the happens before relation
play

Error Handling via the Happens-Before Relation Nicholas D. Matsakis - PowerPoint PPT Presentation

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,


  1. Error Handling via the Happens-Before Relation Nicholas D. Matsakis Thomas R. Gross ETH Zurich 1 Sunday, April 18, 2010

  2. Exception Handling • Goal of this talk: • Extend exception handling into a parallel setting 2 Sunday, April 18, 2010

  3. Sequential Exceptions void child() { statement 1; statement 2; statement 3; } 3 Sunday, April 18, 2010

  4. Sequential Exceptions void child() { statement 1; statement 2; statement 3; } 3 Sunday, April 18, 2010

  5. Sequential Exceptions void child() { statement 1; statement 2; statement 3; } 3 Sunday, April 18, 2010

  6. Sequential Exceptions void child() { statement 1; statement 2; statement 3; } 3 Sunday, April 18, 2010

  7. Sequential Exceptions void child() { statement 1; statement 2; statement 3; } 3 Sunday, April 18, 2010

  8. Sequential Exceptions void child() { statement 1; statement 2; statement 3; } 3 Sunday, April 18, 2010

  9. Sequential Exceptions void child() { statement 1; statement 2; statement 3; } 4 Sunday, April 18, 2010

  10. Sequential Exceptions void child() { statement 1; statement 2; statement 3; } 4 Sunday, April 18, 2010

  11. Sequential Exceptions void child() { statement 1; ! statement 2; statement 3; } 4 Sunday, April 18, 2010

  12. Sequential Exceptions void child() { statement 1; ! statement 2; statement 3; } 4 Sunday, April 18, 2010

  13. Sequential Exceptions void child() { statement 1; ! statement 2; Subsequent statement 3; statements } are skipped. 4 Sunday, April 18, 2010

  14. Sequential Exceptions void parent() { child(); ...; } 5 Sunday, April 18, 2010

  15. Sequential Exceptions void parent() ! { child(); ...; } 5 Sunday, April 18, 2010

  16. Sequential Exceptions void parent() ! { child(); ...; } 5 Sunday, April 18, 2010

  17. Sequential Exceptions void parent() ! { child(); Subsequent statements ...; in outer } scopes are also skipped. 5 Sunday, April 18, 2010

  18. Sequential Exceptions void grandparent() { try { parent(); ... } catch (...) { } } 6 Sunday, April 18, 2010

  19. Sequential Exceptions void grandparent() { ! try { parent(); ... } catch (...) { } } 6 Sunday, April 18, 2010

  20. Sequential Exceptions void grandparent() { ! try { parent(); ... } catch (...) { } } 6 Sunday, April 18, 2010

  21. Sequential Exceptions void grandparent() { ! try { parent(); ... } catch (...) { Continues } until caught. } 6 Sunday, April 18, 2010

  22. Key Points • After an error occurs: • Subsequent statements are skipped • Until the error is caught in some enclosing scope 7 Sunday, April 18, 2010

  23. Exceptions and Threads • In a sequential setting, subsequent statements are easy to identify. • Not with threads. 8 Sunday, April 18, 2010

  24. Threads write read Buffer Producer Consumer 9 Sunday, April 18, 2010

  25. Threads write read Buffer Producer Consumer 9 Sunday, April 18, 2010

  26. Threads write read Buffer Producer Consumer 9 Sunday, April 18, 2010

  27. Threads write read Buffer Producer Consumer 9 Sunday, April 18, 2010

  28. Threads write read Buffer Producer Consumer 9 Sunday, April 18, 2010

  29. Threads write read Buffer Producer Consumer 10 Sunday, April 18, 2010

  30. Threads write read Buffer Producer Consumer 10 Sunday, April 18, 2010

  31. Threads write read Buffer Producer Consumer 10 Sunday, April 18, 2010

  32. Threads write read ! Buffer Producer Consumer 10 Sunday, April 18, 2010

  33. Threads write read ! Buffer Producer Consumer 10 Sunday, April 18, 2010

  34. Threads write read ! Buffer Producer Consumer 10 Sunday, April 18, 2010

  35. Invisible Ordering • Ordering between statements in different threads is never stated explicitly • Created by side-effects • signals, locks 11 Sunday, April 18, 2010

  36. Intervals • An alternative model for parallel programs • Based on an explicit happens-before relation 12 Sunday, April 18, 2010

  37. Interval Interval a = a interval { statement 1; statement 2; }; 13 Sunday, April 18, 2010

  38. Interval Interval a = interval {...}; a Interval b = b c interval {...}; Interval c = interval {...}; 14 Sunday, April 18, 2010

  39. 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

  40. 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

  41. 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

  42. 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

  43. 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

  44. 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

  45. 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

  46. 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

  47. Two-Phase Execution par par = interval { doSomething(); method(par); doSomethingElse(); } 17 Sunday, April 18, 2010

  48. Two-Phase Execution par par = interval { doSomething(); method(par); doSomethingElse(); } 17 Sunday, April 18, 2010

  49. Two-Phase Execution par par = interval { doSomething(); method(par); a b doSomethingElse(); c } 17 Sunday, April 18, 2010

  50. Two-Phase Execution par par = interval { doSomething(); method(par); a b doSomethingElse(); c } 17 Sunday, April 18, 2010

  51. Two-Phase Execution par par = interval { doSomething(); method(par); a b doSomethingElse(); c } 17 Sunday, April 18, 2010

  52. 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

  53. Everything Goes Well par par = interval { doSomething(); method(par); doSomethingElse(); } 19 Sunday, April 18, 2010

  54. Everything Goes Well par par = interval { doSomething(); method(par); doSomethingElse(); } 19 Sunday, April 18, 2010

  55. Everything Goes Well par par = interval { doSomething(); method(par); a b doSomethingElse(); c } 19 Sunday, April 18, 2010

  56. Everything Goes Well par par = interval { doSomething(); method(par); a b doSomethingElse(); c } 19 Sunday, April 18, 2010

  57. Everything Goes Well par par = interval { doSomething(); method(par); a b doSomethingElse(); c } 19 Sunday, April 18, 2010

  58. Everything Goes Well par par = interval { doSomething(); method(par); a b doSomethingElse(); c } 19 Sunday, April 18, 2010

  59. Everything Goes Well par par = interval { doSomething(); method(par); a b doSomethingElse(); c } 19 Sunday, April 18, 2010

  60. Child Fails par par = interval { doSomething(); method(par); doSomethingElse(); } 20 Sunday, April 18, 2010

  61. Child Fails par par = interval { doSomething(); method(par); a b doSomethingElse(); c } 20 Sunday, April 18, 2010

  62. Child Fails par par = interval { doSomething(); ! method(par); a b doSomethingElse(); c } 20 Sunday, April 18, 2010

  63. Child Fails par par = interval { doSomething(); ! method(par); a b doSomethingElse(); c } 20 Sunday, April 18, 2010

  64. Child Fails par par = interval { doSomething(); ! method(par); a b doSomethingElse(); c S } 20 Sunday, April 18, 2010

  65. Child Fails par par = interval { doSomething(); ! method(par); a b doSomethingElse(); c S } 20 Sunday, April 18, 2010

  66. Parent Fails par par = interval { doSomething(); method(par); doSomethingElse(); } 21 Sunday, April 18, 2010

  67. Parent Fails par par = interval { doSomething(); method(par); a b doSomethingElse(); c } 21 Sunday, April 18, 2010

  68. Parent Fails par par = interval { ! doSomething(); method(par); a b doSomethingElse(); c } 21 Sunday, April 18, 2010

  69. Parent Fails par par = interval { ! doSomething(); method(par); a b doSomethingElse(); c } 21 Sunday, April 18, 2010

  70. Parent Fails par par = interval { ! doSomething(); method(par); a b S S doSomethingElse(); c S } 21 Sunday, April 18, 2010

Recommend


More recommend