Download presentation
Presentation is loading. Please wait.
1
Remote Procedure Call in SR Programming Language By Tze-Kin Tsang 3/20/2000
2
Remote Procedure Call (RPC) Introduction Mechanisms for Remote Procedure Call Equivalence to Send/Receive Pairs Return, Reply, and Forward Statements Summary
3
Introduction : RPC involves two processes –the invoker/client and the server Client: the process doing the call Server: the process created to service the call Typically in different resources and might even be on different virtual or physical machines RPC is synchronous from the client’s perspective The invoking process waits for results to be returned from the call
4
RPC is accomplished through the use of operations to initiate a RPC, the invoking process calls an operation, which is serviced by a proc a call invocation of a remote proc results in a process being created to service the invocation a remote procedure call resembles a sequential procedure call both syntactically and semantically the remote proc is transparent to the caller –does not know whether the call is located on a different virtual or physical machine a remote procedure call takes longer than a local, sequential procedure call
5
Mechanisms for Remote Procedure Call The mechanisms for RPC are operations, call invocation, and procs. A new process is created to execute the proc’s code for the invocation. The invoked proc can be located in another resource, which might be located on another virtual or physical machine.
6
The syntax and semantics of the local and remote calls are the same only the implementation and consequently the performance are different
7
Problems: can lead to more than one process manipulating the shared stack variables at the same time for example, two processes, each execute an invocation of push, can overflow the array. synchronize the processes to avoid the problems –semaphore
8
Equivalence to Send/Receive Pairs A (remote) procedure call can be written as a send to a proc to create the process plus a receive to get back results when the process has completed.
9
The following codes are equivalent. Op p (val x: int; var y: int; res z: int) process q var a, b, c: int … call p (a, b, c) end proc p (x, y, z) z := x+4 y -:=10 end Op p (x, y: int), r (y, z: int) process q var a, b, c: int … send p (a, b) receive r (b, c) end proc p (x, y) var z: int z := x+4 y -:= 10 send r (y, z) end
10
The following codes are equivalent. Op p (val x: int; var y: int; res z: int) process q (i := 1 to …) var a, b, c: int … call p (a, b, c) end proc p (x, y, z) z := x+4 y -:=10 end Op p (x, y: int; rcap: cap (y, z: int)) process q (i := 1 to …) var a, b, c: int … op r (y, z: int) send p (a, b, r) receive r (b, c) end proc p (x, y, rcap) var z: int z := x+4 y -:= 10 send rcap (y, z) end
11
Call Invocation VS Send/Receive Pair a call invocation provides a cleaner interface than does a send/receive pair a call invocation allows invocations of value-returning operations within expressions send/receive pair requires declaring a local operation to which results get sent and passing a capability for that operation
12
Send/receive pairs are useful when a client wants to do some work between initiating a request for service and picking up results from that request call invocation precludes clients from performing other work while waiting for the server to give back results
13
Return, Reply, and Forward Statements provide additional flexibility in handling remote procedure calls appear in the body of a proc alter the way results are passed back to the invoking process
14
Return It has the form: return A return statement terminates both the call invocation and the process that executes the return any results of the invocation (variable, result parameters, and return value) are returned to the invoker
15
When a proc does not want to wait for its completion, it may execute a return statement if the proc was invoked by send –return statement just terminates the process that executes the return –any results from the proc are not actually returned
16
Reply It has the form: reply The reply statement is used by a proc to continue execution after servicing an invocation of the proc terminates the invocation being serviced by the enclosing proc a process that executes a reply statement continues executing with the statement following the reply
17
no effect to a send invocation a subsequent reply has no effect to an invocation for which a reply has already been executed
18
Forward The forward statement defers replying to a called invocation and instead passes on this reponsibility transparent to the original invoker
19
it has the form: forward operation (expr, expr, …) takes the operation invocation currently being serviced evaluates a possibly new set of arguments invokes the named operation an invocation can be forwarded to any operation having the same signature the caller remains blocked until the new invocation has been serviced to completion
20
the forwarding process continues with the next statement, but no subsequent changes to variables will be seen by other process a subsequent forward of the same invocation = a send invocation from the forwarding process a subsequent reply to a forwarded invocation has no effect a subsequent return has the usual effect of causing the executing process to exit the block
21
Resource fun () op f (x: int) returns z: int op g (y: int) returns z: int process p var a := f(1); write (a) end proc f(x) returns z forward g (2*x) … # continue executing, perhaps changing z end proc g(y) returns z z := y+10 end
22
A realistic example: Client processes make requests for service to a central allocator process. The allocator assigns a server process to the request by forwarding the invocation to it. The allocator might represent a file server that determines on which server the requested file is located and forwards the client’s request to the server, which typically would be located on a different machine.
23
Summary Remote Procedure Call involves two processes, a client and a server. RPC is another use of operation The mechanisms for RPC are operation declarations, call invocations, and procs. RPC is equivalent to send/receive pairs The return, reply, and forward statements provide additional flexibility in handling remote procedure calls.
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.