17-05-2014, 04:43 PM
REMOTE PROCEDURE CALL
REMOTE PROCEDURE .pdf (Size: 67.56 KB / Downloads: 177)
Many distributed systems have been based on explicit message exchange
between processes. However, the procedures send and receive do not conceal
communication, which is important to achieve access transparency in distributed
systems. This problem has long been known, but little was done about it until a
paper by Birrell and Nelson (1984) introduced a completely different way of han-
dling communication. Although the idea is refreshingly simple (once someone has
thought of it), the implications are often subtle. In this section we will examine
the concept, its implementation, its strengths, and its weaknesses.
In a nutshell, what Birrell and Nelson suggested was allowing programs to
call procedures located on other machines. When a process on machine A calls a
procedure on machine B, the calling process on A is suspended, and execution of
the called procedure takes place on B. Information can be transported from the
caller to the callee in the parameters and can come back in the procedure result.
No message passing at all is visible to the programmer. This method is known as
Remote Procedure Call, or often just RPC.
Conventional Procedure Call
To understand how RPC works, it is important first to fully understand how a
conventional (i.e., single machine) procedure call works. Consider a call in C like
count = read(fd, buf, nbytes);
where fd is an integer indicating a file, buf is an array of characters into which
data are read, and nbytes is another integer telling how many bytes to read. If the
call is made from the main program, the stack will be as shown in Fig. 2-1(a)
before the call. To make the call, the caller pushes the parameters onto the stack
in order, last one first, as shown in Fig. 2-1(b). (The reason that C compilers push
the parameters in reverse order has to do with printf—by doing so, printf can
always locate its first parameter, the format string.)
Client and Server Stubs
The idea behind RPC is to make a remote procedure call look as much as pos-
sible like a local one. In other words, we want RPC to be transparent—the calling
procedure should not be aware that the called procedure is executing on a dif-
ferent machine or vice versa. Suppose that a program needs to read some data
from a file. The programmer puts a call to read in the code to get the data. In a
traditional (single-processor) system, the read routine is extracted from the library
by the linker and inserted into the object program. It is a short procedure, which is
generally implemented by calling an equivalent read system call. In other words,
the read procedure is a kind of interface between the user code and the local
operating system.