RPC is a powerful technique for constructing distributed, client-server based applications. It is based on extending the notion of conventional, or local procedure calling, so that the called procedure need not exist in the same address space as the calling procedure. The two processes may be on the same system, or they may be on different systems with a network connecting them. By using RPC, programmers of distributed applications avoid the details of the interface with the network. The transport independence of RPC isolates the application from the physical and logical elements of the data communications mechanism and allows the application to use a variety of transports.
RPC makes the client/server model of computing more powerful and easier to program.
Working:
Each RPC occurs in the context of a thread. A thread is a single sequential flow of control with one point of execution at any instant. A thread created and managed by application code is an application thread.
RPC applications use application threads to issue both RPCs and RPC run-time calls. An RPC client contains one or more client application threads, each of which may perform one or more RPCs.
In addition, for executing called remote procedures, an RPC server uses one or more call threads that the RPC run-time system provides. When beginning to listen, the server application thread specifies the maximum number of concurrent calls it will execute.
Single-threaded applications have a maximum of one call thread. The maximum number of call threads in multi-threaded applications depends on the design of the application and RPC implementation policy. The RPC run-time system creates the call threads in the server execution context.
An RPC extends across client and server execution contexts. Therefore, when a client application thread calls a remote procedure, it becomes part of a logical thread of execution known as an RPC thread.
An RPC thread is a logical construct that encompasses the various phases of an RPC as it extends across actual threads of execution and the network.
After making an RPC, the calling client application thread becomes part of the RPC thread. Usually, the RPC thread maintains execution control until the call returns.
The RPC thread of a successful RPC moves through the execution phases illustrated in Execution Phases of an RPC Thread.
The execution phases of an RPC thread, as shown in Execution Phases of an RPC Thread include the following:
The RPC thread begins in the client process, as a client application thread makes an RPC to its stub; at this point, the client thread becomes part of the RPC thread.
The RPC thread extends across the network to the server.
The RPC thread extends into a call thread, where the remote procedure executes.
While a called remote procedure is executing, the call thread becomes part of the RPC thread. When the call finishes executing, the call thread ceases being part of the RPC thread.
The RPC thread then retracts across the network to the client.
When the RPC thread arrives at the calling client application thread, the RPC returns any call results and the client application +thread ceases to be part of the RPC thread.
Concurrent Call Threads Executing in Shared Execution Context shows a server executing remote procedures in its two call threads, while the server application thread listens.