1 / 87

Charts and nets: States, Messages, and Events

This event explores the concepts of event charts and object behavior analysis in programming. It covers basic actions, method calls, spatial and temporal boundaries, concurrent and sequential activities, and more.

rphillip
Download Presentation

Charts and nets: States, Messages, and Events

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Charts and nets:States, Messages, and Events Tony Hoare In honour of David Harel Vienna July 2014

  2. Eventsbasic actions and method callsthat occur during execution of a program

  3. Event labelsbasic actions and method callsthat occur in the text of the program x := 9 c ! 9 c ? 9

  4. Space and Time where and when an event occurs space time

  5. Spatial Boundaries horizontal, separating concurrent activities space time

  6. Temporal Boundaries vertical, separating sequential activities space time

  7. Dependencies an event at the head of an arrow depends on the event at the tail

  8. Rules for arrows • do not cross a time-boundary backwards • Local arrows are drawn horizontal • They must not cross space boundaries • Non-local arrows are not horizontal • They must not close a cycle.

  9. Object values 9 3 7 x 4 7 7 9 0 y

  10. Object identifiers x y

  11. Object values 9 3 7 x 4 7 7 9 0 y

  12. Message identifiers c! c[25] c[26] c?

  13. The State of Memory • is a map from the identifier of each line which crosses a given temporal boundary to the value which labels the crossing arrow.

  14. State of memory { x = 9, y = 0} 9 x 0 y

  15. Objects

  16. Concurrent object behaviour. • A trace of behaviour of an object is an event chart, containing all the events in which it has engaged, connected by dependency arrows. • A class is the set of all possible traces of objects of the class (and related objects.

  17. A local object boxes represent actions of the object arrows connect successive actions

  18. A local object the red arrows connect actions in the same thread protected from interference by other threads

  19. A shared object blue arrows connect actions which may occur in a different threads (or they may occur in the same thread).

  20. An exclusion semaphore is released by the same thread that most recently acquired it. A released semaphore may be acquired by any thread.

  21. with labels enter enter exit exit The boxes are labelled to indicate the nature of the actions: enter or exit

  22. Object allocation alloc has one red output arrow and no red input arrow

  23. Object disposal disp has one red input arrow and no red output arrow

  24. A Communication channel single input port and single output port

  25. A shared output port allows multiple outputting threads

  26. with labels to indicate that the value communicated is the same at both ends of the channel dispose !3 !7 alloc ad =7 =3 ?7 disp ?3 alloc

  27. with a single buffer which is passed back to outputter for refilling !3 disp !7 alloc ad =7 =3 ?7 disp ?3 alloc

  28. a synchronous channel no buffering at all. input and output are simultaneous !3 disp !7 alloc ad =7 =3 ?7 disp ?3 alloc

  29. a re-ordering channel… allows crossing of arrows !3 disp !7 alloc ad =7 =3 ?3 disp ?7 alloc

  30. …with loss of message !7 disp !3 alloc ad =7 disp ?7 alloc

  31. Diagrams in Debugging • display a trace of concurrent execution • with slices for selected objects • keyed to the text of the program • with dependencies to show sources of error • and consequences of its correction.

  32. A program (or an object class) denotes the set of all possible diagrams of execution, on any computer system running in any environment. Programs

  33. Spatial Boundaries horizontal, separating concurrent activities space time

  34. Temporal Boundaries vertical, separating sequential activities space time

  35. Concurrent Composition of event charts p, q, r p q r (p ‖ q)‖ r = p ‖ (q ‖ r)

  36. Sequential composition p q r (p ; q) ; r = p ; (q ; r)

  37. Rules for arrows • do not cross a time-boundary backwards • Local arrows are drawn horizontal • They must not cross space boundaries • Non-local arrows are not horizontal • They must not close a cycle.

  38. A Program Error (race)

  39. Another Program Error (deadlock) p

  40. Top T • stands for a trace with programming error • T;p = p;T = p||T otherwise…..

  41. Operators • p;q splits the trace across time, into parts that can be executed at different instants. • p∥q splits it across space, into parts that can be executed in different places. • I describes doing nothing

  42. Sequential Composition • p;q = p+q if q x p contained in neg(dep*) • p||q = p+q if p x q contained in neg(red u conv(red)) n neg(dep* n conv(dep*)) } = T otherwise • I = { }

  43. Trace algebra

  44. Refinement ≼ • ≼ is a partial order • Covariance: p ≼ q implies • p;r ≼ q;r • r;p ≼ r;q • p∥r ≼ q∥r

  45. Exchange Axiom(p∥q) ; (p’∥q’) ≼ (p;p’) ∥ (q;q’) ; p p’ p p’ ; ≼ ; q q q’ q’ note the self-duality of the law

  46. p ≼ q means that p and q perform all the same actions, but p performs more pairs of them sequentially, and q performs more pairs concurrently. As a result,… • p is more determinate, q is more abstract

  47. Interleaving • (p∥q) ; (p’∥q’) ≼ (p;p’) ∥ (q;q’) • LHS is an interleaving implementation of the more general concurrency of RHS • It is the special case when the two RHS ‘;’s happen to be simultaneous

  48. Frame Laws • (p∥q) ; (p’∥q’) ≼ (p;p’) ∥ (q;q’) • Theorems (frame): • (p∥q) ; q’ ≼ p∥(q;q’) • p;(p’∥q’) ≼ (p;p’)∥q’ • p;q’ ≼ p∥q’ and q;p’ ≼ p’∥q Proof: substitute  for variables of the axiom that are omitted in the theorem

  49. Example abcd∥ xyzw (a;bcd) ∥ (xy;zw) (a∥xy) ; (bcd∥zw) (a∥x;y) ; (b;cd∥zw) (a∥x);y ; (b∥zw) ; cd xayzbwcd

  50. A Program • is the set of all traces that it can evoke when executed on any computer system and in any interacting environment. P;Q = {p;q | p e P & q e Q } P||Q = {p||q | p e P & q e Q } P < Q = all p e P . exists q e Q . p < q All our laws for ; and || are preserved for sets

More Related