40 likes | 160 Views
Distributed Programming. Concepts and Notations. Inter-process Communication. Synchronous Messages Asynchronous Messages Select statement Remote procedure calls Atomic transactions. Ada example. task buffer; entry deposit(in value:T); entry fetch(out value:T); var
E N D
Distributed Programming Concepts and Notations
Inter-process Communication • Synchronous Messages • Asynchronous Messages • Select statement • Remote procedure calls • Atomic transactions
Ada example • task buffer; • entry deposit(in value:T); • entry fetch(out value:T); • var • slots:array [0..N-1] of T; • head, tail:0..N-1; • size:0..N; • begin • head, tail, size := 0,0,0; • loop • select • when size < N => accept deposit(in value:T); • slots[tail] := value; • size := size+1; tail:=tail + 1 mod N; • or when size > 0 => accept fetch(out value:T); • value := slots[head]; • size := size-1; head:=head + 1 mod N; • end select; • end loop;
Ada example contd. task produce repeat item := produce(); call buffer.deposit(item); forever; end; task consumer; repeat call buffer.fetch(item); consume(item); forever; end