What is RPC in Operating System?
Remote Procedure Call or RPC is a powerful technique for constructing distributed, client-server-based applications. It is also known as a function call or a subroutine call. A remote procedure call is when a computer program causes a procedure to execute in a different address space, coded as a local procedure call, without the programmer explicitly stating the details for the remote interaction. The programmer writes essentially the same code whether the subroutine is local to the executing program or remote. This is a form of client-server interaction implemented via a request-response message-passing system.
The RPC model implies location transparency that calling procedures are largely the same, whether local or remote. Usually, they are not identical, so that local calls can be distinguished from remote calls. Remote calls are usually orders of magnitude slower and less reliable than local calls, so distinguishing them is important.
RPCs are a form of inter-process communication (IPC), in that different processes have different address spaces. They have distinct virtual address spaces on the same host machine, even though the physical address space is the same. While if they are on different hosts, the physical address space is different.
How to Make a Remote Procedure Call
The calling environment is suspended, procedure parameters are transferred across the network to the environment where the procedure is to execute, and the procedure is executed there.
When the procedure finishes and produces its results, it is transferred back to the calling environment, where execution resumes as if returning from a regular procedure call.
NOTE: RPC is especially well suited for client-server (e.g., query-response) interaction in which the flow of control alternates between the caller and callee. Conceptually, the client and server do not execute simultaneously; instead, the thread of execution jumps from the caller to the callee and then back again.
Types of RPC
There are three types of remote procedure call (RPC) in an operating system, such as:
1. Callback RPC
This type of RPC enables a P2P paradigm between participating processes. It helps a process to be both client and server services. Callback RPC has the following functions, such as:
2. Broadcast RPC
Broadcast RPC is a client's request broadcast on the network, processed by all servers with the method for processing that request. Broadcast RPC has the following functions, such as:
3. Batch-mode RPC
Batch-mode RPC helps to queue, separate RPC requests, in a transmission buffer, on the client-side, and then send them on a network in one batch to the server. Batch-mode RPC has the following functions, such as:
What does RPC do?
When program statements using the RPC framework are compiled into an executable program, a stub is included in the compiled code representing the remote procedure code.
When the program is run and the procedure call is issued, the stub receives the request and forwards it to a client runtime program in the local computer. The first time the client stub is invoked, it contacts a name server to determine the transport address where the server resides.
The client runtime program knows how to address the remote computer and server application and sends the message across the network that requests the remote procedure. Similarly, the server includes a runtime program and stub that interface with the remote procedure itself, and Response-request protocols are returned the same way.
Features of RPC
In an operating system, remote procedure call (RPC) has the following features, such as:
How RPC works?
When a remote procedure call is invoked, the calling environment is suspended, the procedure parameters are transferred across the network to the environment where the procedure is to execute, and the procedure is then executed in that environment.
When the procedure finishes, the results are transferred back to the calling environment, where execution resumes as if returning from a regular procedure call.
A remote procedure call (RPC) works in the following steps in an operating system:
Step 1: The client, client stub, and RPC run time execute on the client machine.
Step 2: A client starts a client stub process by passing parameters in the usual way. The packing of the procedure parameters is called marshalling. The client stub stores within the client's own address space, and it also asks the local RPC Runtime to send back to the server stub.
Step 3: In this stage, the user can access RPC by making regular Local Procedural Call. RPC Runtime manages the transmission of messages between the network across client and server, and it also performs the job of retransmission, acknowledgment, routing, and encryption.
Step 4: After completing the server procedure, it returns to the server stub, which packs (marshalls) the return values into a message. The server stub then sends a message back to the transport layer.
Step 5: In this step, the transport layer sends back the result message to the client transport layer, which returns back a message to the client stub.
Step 6: In this stage, the client stub demarshalls (unpack) the return parameters in the resulting packet, and the execution process returns to the caller.
Issues of Remote Procedure Call (RPC)
In an operating system, Remote procedure call or RPC faced some issues that must be addressed, such as:
1. RPC Runtime
The RPC runtime system is a library of routines and services that handle the network communications that underlie the RPC mechanism. In the course of an RPC call, client-side and server-side runtime systems code handle binding, establish communications over an appropriate protocol, pass call data between the client and server, and handle communications errors.
The function of the stub is to provide transparency to the programmer-written application code.
How does the client know who to call and where the service resides?
The most flexible solution is to use dynamic binding and find the server at run time when the RPC is first made. The first time the client stub is invoked, it contacts a name server to determine the transport address at which the server resides. The binding consists of two parts:
4. The calling semantics associated with RPC
It is mainly classified into the following choices,
Characteristics of RPC
Here are the essential characteristics of remote procedure call:
Advantages of RPC
Here are some advantages or benefits of RPC, such as:
Disadvantages of RPC
Here are some disadvantages or drawbacks of using RPC, such as:
Next TopicC-SCAN vs SSTF Disk Scheduling Algorithm