Asynchronous Communication Mechanisms (ACMs) Fei Xia Fei Xia EECE, Newcastle University
��������������������������� �������������������������� � Point to point connection data writer writer reader reader Data is a stream of items of a set type. Writer and reader are cyclic processes. Writer provides one item of data per cycle. Reader uses one item per cycle.
��������������� � Simple approach writer reader a b t
���� � An ACM divides temporal domains ACM writer reader writer timing domain reader timing domain temporal divide
��������� Each process updates its � ACM own control variables A process can only read the Control � writer reader variables value of a control variable of another process Shared memory Concurrent processes Concurrent processes data data data data � � executing on different timing domains The shared memory is organized 1-bit control variables � � as a set of � cells Does not require any � A cell is a memory location that synchronization primitives � can store one data item Order of execution does � Each process has its own set of not interfere on the � control variables correctness of the result
������� Atomic register [Lamport 86] � The problem of asynchronous communication can be solved using � shared registers Complex registers are built from simple ones � ACMs [Simpson 87-03] � Defined a fully ACM that preserves data-coherence with 4 slots Defined a fully ACM that preserves data-coherence with 4 slots � � Classification of ACMs � Systematic synthesis of ACMs [Yakovlev Group 96-08] � ACMs are modelled using MATLAB for use in higher level systems � Automatic synthesis of ACMs [Gorgônio, Xia 05-08] � State space generation (BFS based) � Petri net synthesis using theory of regions � Modular approach using Petri nets modules as building blocks � Modelling and verification using CPN �
������������������ ����� ������������� ������� �� ���������� ������� ���� ��������� ���� ��������� BB BB RRBB RRBB ! ��������� ! ��������� ! ��������� ! ��������� OWBB OWBB OWBB OWBB OWRRBB OWRRBB OWRRBB OWRRBB Overwriting enables the writer to be fully asynchronous � Rereading enables the reader to be fully asynchronous � BB stands for bounded buffer �
������������������� ACM Writer Reader Control variables variables Shared data data memory enough memory to enough memory to contain an arbitrary contain an arbitrary number of items number of items
"�������� C C 0 0 C C 1 C � C 1 � -1 1 C C 2 2 � � cells in a ring … … cells in a ring … …
#���������������$����� RRBB with three cells from an interleaving specification � � ��� ���� ��� ���� ���������� ���� ���� ���� ���� ���� ���� ���� ���� ���� ���������� ���������� ���� ���� ���� ���� ���������� ���� ���� ���� waiting ���� ���� ���� ���� ���� ���� ��� ��� ���� cyclic rereading
��"" Adding “silent actions” � ��� ��� µ �� � µ �� � λ ��� ���� ���� λ: writer silent actions; µ �� � ���� µ �� � ���� ���� ���� µ: reader silent actions λ ��� ���� ���� µ �� � µ �� � λ ��� ���� ���� µ �� � ���� µ �� � ���� ���� ���� prepare to λ ��� ���� ���� reread µ �� � µ �� � λ ��� ���� ���� µ �� � ���� µ �� � ���� ���� ���� λ ��� ���� ���� ��� ���
��""���������� var � : 0.. � -1; � : 0.. � -1; initialized sensibly (say � = � -1) and initialize data items in the cells. ��� ��� µ �� � µ �� � writer reader λ ��� ���� ���� wr: write cell � ; r0: if ( � +1 mod � )≠ � then � :=( � +1 mod � ); µ �� � ���� µ �� � ���� ���� ���� ww: wait until � ≠ � +1; λ ��� λ ��� ���� ���� ���� ���� w0: � :=( � +1 mod � ); w0: � :=( � +1 mod � ); rd: read cell � ; rd: read cell � ; µ �� � µ �� � λ ��� ���� ���� µ �� � ���� µ �� � ���� ���� ���� λ ��� ���� ���� µ �� � µ �� � λ ��� ���� ���� µ �� � ���� µ �� � ���� ���� ���� λ ��� ���� ���� ��� ���
��""��������������� ACM cell � Writer Reader � and � cell memory cell memory data data advance advance ACM cell � +1 Writer Reader � and � cell memory data data
������������������������ var � : 0..1; � : 0..1; initialized sensibly (one cell has � =1 and another has � =1, all others being 0) and initialize data in the cells. %����� %����� ������ ������ wr: write; r0: if � next=0 then w0: � :=0; � next:=1; begin � :=0; � next:=1; ww: wait until � next=0; advance to next end wa: advance to next; rd: read;
! ��������� Needs more than one “slot” per cell � This will allow the writer to “overtake” the reader if overwriting the oldest � item in the buffer Item to be overwritten can be � Oldest in the buffer � Newest in the buffer Newest in the buffer � � Some other item (does not make as much sense as the previous choices) � Also has to do with if the ACM is organized as a FIFO, a stack or a random � bag
� λ ����� λ ����� ���� µ ���� � µ ���� � ���� ���� ���� ��� ���� µ ���� � µ ���� � λ ����� λ ����� ���� ���� ���� ��� λ ����� λ ����� λ ����� λ ����� ��� ���� ���� µ ���� � µ ���� � &������!%��"" ���� ���� ���� ���� ���� ��� ���� µ ���� � λ ����� λ ����� µ ���� � ���� ��� µ ���� � µ ���� � µ ���� ���� ���� ��� µ ���� � µ ���� � µ
&������!%��"" Control variables writer writer cell 0 cell 1 cell 2 slot 0 slot 0 x x 00 x x 10 x x 20 data x 01 slot 1 One-hot enconding (1-bit variable) reader reader Control variables
��������!%��""���������� var � : 0..1; � : 0..1; ���� : 0..1 (this cell is overwritten); ������� : 0..1 (writer releases cell for reader); %����� ������ w0: ���� next:=0; w0: ���� next:=0; r0: if ���� =1 then r0: if ���� =1 then if � ≠ � then ���� :=1; begin ���� :=0; � =(not) � ; advance to next end wr: write slot � ; � := � ; wa: ������� :=1; rd: read slot � ; ������� next:=0; ra: if ������� next=1 then advance to next; advance to next
�������������������
��'������������� Alex Yakovlev Alex Yakovlev Hugo Simpson Ian Clark Eric Campbell Jordi Cortadella Kyller Gorgonio
Recommend
More recommend