Presentation is loading. Please wait.

Presentation is loading. Please wait.

Distributed Programming Concepts and Notations. Inter-process Communication Synchronous Messages Asynchronous Messages Select statement Remote procedure.

Similar presentations


Presentation on theme: "Distributed Programming Concepts and Notations. Inter-process Communication Synchronous Messages Asynchronous Messages Select statement Remote procedure."— Presentation transcript:

1 Distributed Programming Concepts and Notations

2 Inter-process Communication Synchronous Messages Asynchronous Messages Select statement Remote procedure calls Atomic transactions

3 Message based programming languages No shared variables Each object has a caretaker Can operate on an object only by sending a message to its caretaker

4 Basic Constructs send expression-list to destination receive variable-list from source can be used for communication synchronization

5 Basic Issues How to specify designators ? How is communication synchronized ?

6 Designator Specification Direct Naming P1: P2: var a,x:integer; var b,y:integer; x:=2*a; receive b from P1; send x to P2 y:=y+b; Advantages simple efficient implementation Disadvantages must know at compile time receive from anyone

7 Mailboxes process simpleNS; nsmb: mailbox; request:message_type; begin create(nsmb); repeat forever receive request from nsmb; case request.mtype of. end; client: send myreq to nsmb; Advantages: generality Disadvantages: inefficient to implement

8 Buffering Synchronous vs Asynchronous communication Blocking send vs Non-blocking send Unbuffered send vs Unbounded buffering Advantages of synchronous communication easier implementation easy proof rules easy to synchronize fault-tolerance easier Disadvantages exploitation of concurrency difficult

9 Avoiding blocking on receive peek() selective receive receive var from designator about key

10 Selective Communication Guarded command: e.g. extension: guard = boolean expression and optionally a message passing statement. A guard may Succeed other side is also ready to communicate Fail other side has already terminated or May neither succeed nor fail.

11 CSP: Synchronous messages process buffer; var slots:array [0..N-1] of integer; head, tail:0..N-1; size:0..N; begin head, tail, size := 0,0,0; *[ size < N; receive slots[tail] from producer -> size := size+1; tail:=tail + 1 mod N; [] size > 0; send slots[head] to consumer -> size := size-1; head:=head + 1 mod N; ] end

12 Remote Procedure Calls Key idea: try to preserve the semantics of local procedure calls P1: call process.pname(parameters) P2: remote procedure pname(..) end;

13 Kinds of RPC Simple declaration Accept statements

14 Ada - rendezvous P1: call P2:accept Synchronization parameters transmitted execute body parameters transmitted back

15 Comparison Advantages of accept statement server has flexibility of when to serve can provide different services by different bodies can combine with guarded commands to provide non-determinism Disadvantages of accept statement difficult to understand or prove correctness

16 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;

17 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

18 Care must be taken regarding global variables pointers as parameters representation of parameters at least once/ at most once semantics


Download ppt "Distributed Programming Concepts and Notations. Inter-process Communication Synchronous Messages Asynchronous Messages Select statement Remote procedure."

Similar presentations


Ads by Google