Outline �� 0024 Spring 2010 � – 21 :: 2 – Source [1] �
Talking About Executions � Why? � � � Can ’ t we specify the linearization point of each operation without describing an execution? � Not Always � � � In some cases, linearization point depends on the execution � 0024 Spring 2010 � – 21 :: 3 – Source [1] �
Formal Model of Executions � De fi ne precisely what we mean � � � Ambiguity is bad when intuition is weak � Allow reasoning � � � Formal � � � But mostly informal � � � In the long run, actually more important � � � Ask me why! � 0024 Spring 2010 � – 21 :: 4 – Source [1] �
Split Method Calls into Two Events � Invocation � � � method name & args � � � q. enq( x) Response � � � result or exception � � � q. enq( x) returns voi d � � q. deq( ) returns x � � q. deq( ) throws em pt y 0024 Spring 2010 � – 21 :: 5 – Source [1] �
Invocation Notation � A q.enq(x) (4) 0024 Spring 2010 � – 21 :: 6 – Source [1] �
Invocation Notation � A q.enq(x) thread (4) 0024 Spring 2010 � – 21 :: 7 – Source [1] �
Invocation Notation � A q.enq(x) thread method (4) 0024 Spring 2010 � – 21 :: 8 – Source [1] �
Invocation Notation � A q.enq(x) thread method object (4) 0024 Spring 2010 � – 21 :: 9 – Source [1] �
Invocation Notation � A q.enq(x) thread method object arguments (4) 0024 Spring 2010 � – 21 :: 10 – Source [1] �
Response Notation � A q: void (2) 0024 Spring 2010 � – 21 :: 11 – Source [1] �
Response Notation � A q: void thread (2) 0024 Spring 2010 � – 21 :: 12 – Source [1] �
Response Notation � A q: void thread result (2) 0024 Spring 2010 � – 21 :: 13 – Source [1] �
Response Notation � A q: void thread result object (2) 0024 Spring 2010 � – 21 :: 14 – Source [1] �
Response Notation � A q: void thread result object (2) 0024 Spring 2010 � – 21 :: 15 – Source [1] �
Response Notation � A q: empty() thread exception object (2) 0024 Spring 2010 � – 21 :: 16 – Source [1] �
History - Describing an Execution � A q. enq( 3) A q: voi d A q. enq( 5) H = B p. enq( 4) B p: voi d Sequence of B q. deq( ) invocations and B q: 3 responses 0024 Spring 2010 � – 21 :: 17 – Source [1] �
De fi nition � Invocation & response match if � Object names Thread agree names agree A q. enq( 3) Method call A q: voi d (1) 0024 Spring 2010 � – 21 :: 18 – Source [1] �
Object Projections � A q. enq( 3) A q: voi d H = B p. enq( 4) B p: voi d B q. deq( ) B q: 3 0024 Spring 2010 � – 21 :: 19 – Source [1] �
Object Projections � A q. enq( 3) A q: voi d H|q = B p. enq( 4) B p: voi d B q. deq( ) B q: 3 0024 Spring 2010 � – 21 :: 20 – Source [1] �
Thread Projections � A q. enq( 3) A q: voi d H = B p. enq( 4) B p: voi d B q. deq( ) B q: 3 0024 Spring 2010 � – 21 :: 21 – Source [1] �
Thread Projections � A q. enq( 3) A q: voi d H|B = B p. enq( 4) B p: voi d B q. deq( ) B q: 3 0024 Spring 2010 � – 21 :: 22 – Source [1] �
Complete Subhistory � A q. enq( 3) A q: voi d A q. enq( 5) H = B p. enq( 4) B p: voi d An invocation is B q. deq( ) pending if it has no B q: 3 matching respnse 0024 Spring 2010 � – 21 :: 23 – Source [1] �
Complete Subhistory � A q. enq( 3) A q: voi d A q. enq( 5) H = B p. enq( 4) B p: voi d May or may not B q. deq( ) have taken effect B q: 3 0024 Spring 2010 � – 21 :: 24 – Source [1] �
Complete Subhistory � A q. enq( 3) A q: voi d A q. enq( 5) H = B p. enq( 4) B p: voi d discard pending B q. deq( ) invocations B q: 3 0024 Spring 2010 � – 21 :: 25 – Source [1] �
Complete Subhistory � A q. enq( 3) A q: voi d Complete(H) = B p. enq( 4) B p: voi d B q. deq( ) B q: 3 0024 Spring 2010 � – 21 :: 26 – Source [1] �
Sequential Histories � A q. enq( 3) A q: voi d B p. enq( 4) B p: voi d B q. deq( ) B q: 3 A q: enq( 5) (4) 0024 Spring 2010 � – 21 :: 27 – Source [1] �
Sequential Histories � match A q. enq( 3) A q: voi d B p. enq( 4) B p: voi d B q. deq( ) B q: 3 A q: enq( 5) (4) 0024 Spring 2010 � – 21 :: 28 – Source [1] �
Sequential Histories � match A q. enq( 3) A q: voi d match B p. enq( 4) B p: voi d B q. deq( ) B q: 3 A q: enq( 5) (4) 0024 Spring 2010 � – 21 :: 29 – Source [1] �
Sequential Histories � match A q. enq( 3) A q: voi d match B p. enq( 4) B p: voi d match B q. deq( ) B q: 3 A q: enq( 5) (4) 0024 Spring 2010 � – 21 :: 30 – Source [1] �
Sequential Histories � match A q. enq( 3) A q: voi d match B p. enq( 4) B p: voi d match B q. deq( ) Final pending B q: 3 invocation OK A q: enq( 5) (4) 0024 Spring 2010 � – 21 :: 31 – Source [1] �
Sequential Histories � match A q. enq( 3) A q: voi d match B p. enq( 4) B p: voi d match B q. deq( ) Final pending B q: 3 invocation OK A q: enq( 5) (4) 0024 Spring 2010 � – 21 :: 32 – Source [1] �
Well-Formed Histories � A q. enq( 3) B p. enq( 4) B p: voi d H= B q. deq( ) A q: voi d B q: 3 0024 Spring 2010 � – 21 :: 33 – Source [1] �
Well-Formed Histories � Per-thread B p. enq( 4) projections sequential B p: voi d H| B= B q. deq( ) A q. enq( 3) B q: 3 B p. enq( 4) B p: voi d H= B q. deq( ) A q: voi d B q: 3 0024 Spring 2010 � – 21 :: 34 – Source [1] �
Well-Formed Histories � Per-thread B p. enq( 4) projections sequential B p: voi d H| B= B q. deq( ) A q. enq( 3) B q: 3 B p. enq( 4) B p: voi d H= B q. deq( ) A q: voi d A q. enq( 3) H| A= B q: 3 A q: voi d 0024 Spring 2010 � – 21 :: 35 – Source [1] �
Equivalent Histories � Threads see the same H| A = G | A thing in both H| B = G | B A q. enq( 3) A q. enq( 3) B p. enq( 4) A q: voi d B p: voi d B p. enq( 4) H= G = B q. deq( ) B p: voi d A q: voi d B q. deq( ) B q: 3 B q: 3 0024 Spring 2010 � – 21 :: 36 – Source [1] �
Sequential Speci fi cations � A sequential speci fi cation is some way of telling whether a � � � Single-thread, single-object history � � � Is legal � For example: � � � Pre and post-conditions � � � But plenty of other techniques exist … � 0024 Spring 2010 � – 21 :: 37 – Source [1] �
Legal Histories � A sequential (multi-object) history H is legal if � � � For every object x � � � H|x is in the sequential spec for x � 0024 Spring 2010 � – 21 :: 38 – Source [1] �
Precedence � A q. enq( 3) A method call precedes B p. enq( 4) another if response B p. voi d event precedes A q: voi d invocation event B q. deq( ) B q: 3 Method call Method call (1) 0024 Spring 2010 � – 21 :: 39 – Source [1] �
Non-Precedence � A q. enq( 3) B p. enq( 4) Some method calls B p. voi d overlap one another B q. deq( ) A q: voi d B q: 3 Method call Method call (1) 0024 Spring 2010 � – 21 :: 40 – Source [1] �
Notation � Given � � � History H � � � method executions m 0 and m 1 in H � We say m 0 � H m 1 , if � � � m 0 precedes m 1 � Relation m 0 � H m 1 is a � � � Partial order � m 0 m 1 � � Total order if H is sequential � 0024 Spring 2010 � – 21 :: 41 – Source [1] �
Linearizability � History H is linearizable if it can be extended to G by � � � Appending zero or more responses to pending invocations � � � Discarding other pending invocations � So that G is equivalent to � � � Legal sequential history S � � � where � G � � S � 0024 Spring 2010 � – 21 :: 42 – Source [1] �
What is � G � � S � � G = { a � c, b � c} � S = { a � b, a � c, b � c} a c b � G time time � S (8) 0024 Spring 2010 � – 21 :: 43 – Source [1] �
Remarks � Some pending invocations � � � Took effect, so keep them � � � Discard the rest � Condition � G � � S � � � Means that S respects “ real-time order ” of G � 0024 Spring 2010 � – 21 :: 44 – Source [1] �
Example � A q. enq( 3) B q. enq( 4) B q: voi d B q. deq( ) B q: 4 B q: enq( 6) A. q.enq(3) B.q.enq(4 ) B.q.deq(4 ) B. q.enq(6) time 0024 Spring 2010 � – 21 :: 45 – Source [1] �
Example � A q. enq( 3) Complete this B q. enq( 4) pending B q: voi d invocation B q. deq( ) B q: 4 B q: enq( 6) A. q.enq(3) B.q.enq(4 ) B.q.deq(4 ) B. q.enq(6) time 0024 Spring 2010 � – 21 :: 46 – Source [1] �
Example � A q. enq( 3) Complete this B q. enq( 4) pending B q: voi d invocation B q. deq( ) B q: 4 B q: enq( 6) A q: voi d A.q.enq(3 ) B.q.enq(4 ) B.q.deq(4 ) B. q.enq(6) time 0024 Spring 2010 � – 21 :: 47 – Source [1] �
Example � A q. enq( 3) B q. enq( 4) B q: voi d discard this one B q. deq( ) B q: 4 B q: enq( 6) A q: voi d A.q.enq(3 ) B.q.enq(4 ) B.q.deq(4 ) B. q.enq(6) time 0024 Spring 2010 � – 21 :: 48 – Source [1] �
Recommend
More recommend