|
What are Remote Procedure Calls?
Remote Procedure Call is a method for encapsulating communication in a distributed system. The essence of the technique is to allow programs on different machines to interact using simple procedure call/return semantic; just as if the two programs were on the same machine.
Advantages of Remote Procedure Calls
- The procedure call is a widely accepted, used and understood abstraction.
- The use of Remote Procedure Calls enables remote interfaces to be specified as a set of named operations with designated types. Thus the interface can be clearly documented and distributed programs can be statically checked for type errors.
- Because a standardized and precisely defined interface is specified, the communication code for an application can be generated automatically.
- Because a standardized and precisely defined interface is specified, developers can write client and server modules that can be moved among computers and operating systems with little modification.
The remote procedure call mechanism can be viewed as a refinement of reliable, blocking message passing. The calling program makes a normal procedure call with parameters on its machine. Eg.
CALL P (X, Y)
Where,
P = Procedure name.
X = passed argument.
Y = returned value.
It may or may not be transparent for the user that the intention is to invoke a remote procedure on some other machine. A dummy or stub procedure P must be included in the caller’s address space or be dynamically linked to it at call time.This procedure creates a message that identifies the procedure being called and includes the parameters. It the n sends this message to a remote system and waits for a reply. When a reply is received, the stub procedure returns to the calling program, providing the returned values.
At the remote machine, another stub program is associated with the called procedure. When a message comes in, it is examined and a local CALL P(X, Y) is generated. This Remote Procedure is thus called locally, so its normal assumptions about where to find parameters, the stack etc., are identical to the case of a purely local procedure call. Several design issues like parameter passing, parameter representation, client server binding are associated with Remote Procedure Calls.
Parameter Passing
Most programming languages allow parameters to be passed as values (call by value) or as pointers to a location that contains the value (call by reference). Call by value is simple for a Remote Procedure Call: The parameters are simply copied into the message and sent to the remote system. It is more difficult to implement call by reference. A unique system wide pointer is needed for each object in such a case.
Parameter Representation
Another issue is how to represent parameters and results in messages. If the called and calling programs are in identical programming languages on the same type of machines with the same operating system, then the representation requirement may present no problems. If there are differences in these areas, then there will probably be differences in ways in which numbers and even text are represented.
The best approach to this problem is to provide a standardized format for common objects, such as integers, floating point numbers, characters and character strings. Then the native parameters on any machine can be converted to and from the standardized representation.
Client/Server Binding
Binding specifies how the relationship between a remote procedure and the calling program will be established. A binding is formed when two applications have made a logical connection and are prepared to exchange command and data.
Non-persistent Binding: Non Persistent Binding means that a logical connection is established between the two processes at the time of the remote procedure call and that as soon as the values are returned, the connection is dismantled. Because a connection requires the maintenance of state information on both ends, it consumes resources. The non-persistent style is used to conserve those resources.
With persistent binding, a connection that is set up for a remote procedure call is sustained after the procedure call returns. The connection can be used for future Remote Procedure Calls. If a specified period of time passes with no activity on the connection, then the connection is terminated.
|