RPC call in Operating System

Remote procedure calls come into play when we want processes that are residing in different systems connected over a network wants to communicate with each other so think of a scenario where one process that is residing in a system wants to communicate to another process that is residing physically in another system and these two systems are connected via a network. So in this kind of scenario, we need to use remote procedure calls and remote procedure calls will help us in communication between processes that are residing in different systems connected over a network. 

What is Remote Procedure Call?

So remote procedure call or RPC is a protocol that one program can use to request a service from a program located in another computer or a network without having to understand the network’s details so RPC is a protocol that helps one program to request a service from another program located in another computer on a network and it does so in such a way that the processes that are communicating do not need to understand the network’s details so the network’s details do not have to be understood by the processes that are communicating.

RPC and IPC 

RPC takes care of this now this RPC is similar in many respect to the IPC mechanism so we have studied about IPC which stands for inter process communication so RPC is similar to IPC in many ways however because we are dealing with an environment in which the processes are executing on separate systems we must use a messaged base communication scheme to provide remote service so though RPC is similar to IPC in many ways the difference is that since in RPC we are dealing with an environment in which processes are executed on separate systems we need to use a messaged based communication scheme so if you remember about the two communication schemes that we have studied we have studied about shared memory system and we have studied about message passing system so in shared memory system what happens is when the processors wants to communicate with each other there is a region or shared memory that they have and the process that wants to communicate just writes whatever it wants to communicate on the shared region and the other process just reads from that shared region but in case of RPC we are dealing with processes that are residing in two different systems that are connected by our network.

So in this kind of a system it may not be possible to have a shared region of memory so that shared memory system may not be possible so we have to use the other kind of communication scheme that we have studied which is the message passing system so in our PC we will be using a message based communication scheme so moving on let us see what are the other differences that our PC has as compared to IPC so in contrast to the IPC facility the messages exchanged in RPC communications are well-structured and are thus no longer just packets of data so in case of IPC whenever we use the message passing systems those messages were just packets of data and nothing else so if you remember when we studied about message passing system the process that wants to send the message just sends that message as a packet to the kernel and from the kernel it goes to the process to which that message was intended to so messages were just packets of data but in case of RPC it is not just happening in a single system it has to travel between one system to the other so we cannot just keep our messages as simple packets of data but they have to be well structured because they have to travel over a network. 

RPC and Function

RPC when the message is sent it is addressed to the RPC daemon which is listening to the port on the remote system and each of the message that is send it contains an identifier of the function to execute and the parameters to pass to that function now we are using the term function here so what is a function so when we study programming we know what are functions so function is a piece of code that is written which performs a specific task so what are the requirements that we need in a function the function needs parameters so based on the parameters the operation is performed on that parameters and something is returned so in case of RPC think of this function as a service which is going to be requested by one process from the other process so there is a process deciding in a system and this process wants a service which is provided by another process residing in another system so think of that service as a function so what do we do we have to pass the pattern meters of the function and we have to call the function and then the function will be executed so in the same way in this RPC we have to pass the identifier of the function which may be like a function name and then the parameters that we have to pass to the function then after that what happens the function is then executed as requested and any output is sent back to the requester in a separate message so let’s take the example of a simple function in programming again what happens when we call a function when we call a function we pass the parameters and when the function is called the function gets executed and after execution if there are anything to be returned that will be returned and where will it be returned it will be returned to the place where the function was called so in case of our RPC who is the one who called the function or the service it is the first process or the client so after the function is executed in the other system the things that has to be returned the return values has to be passed back to the client again and that will be done in a separate message using the message passing system so that is basically how the RPC functions so we have seen an overview of how the 

RPC and Semantics

RPC allow a client to invoke a procedure on a remote host as it would invoke a procedure locally so we already know how processes communicate in a local set up that means when they are residing in the same system so in case of RPC when the processes are residing in two different systems connected over a network let us see how does the communication take place so the RPC system hides the details that allow communication to take place by providing a stub on the client side and typically a separate stub exists for each separate remote procedure so as I already told you RPC system it hides the details that allow communication to take place by providing a stub on the client side so when we use this RPC the process does not have to be concerned about how the communication takes place RPC hides the details of that and how does it do by providing a stub on the client side and we will see what is a function of this stub as we move ahead and typically a stub exists for each separate remote procedure so let us move ahead and see what is a function of this stub what does it do and how does it proceed so when a client invokes a remote procedure the RPC system calls the appropriate stub passing it the parameters provided to the remote procedure and this stub locates the port on the server and marshals the parameters so when a client invokes a remote procedure that means when a client a process in one system wants to get the service of the process residing in another system what does it do it invokes that procedure the client invokes the remote procedure we use the term remote because it is residing in another system not in the same system so when the procedure is invoke what happens the RPC system it calls the appropriate stub and then it passes the parameters provided to the remote procedure so whenever we say remote procedure think of it as a function a function that we have written in a program what does it do it executes something it provides a certain service so what is required in a function we have to pass a parameters to a function so when the client invokes a remote procedure the RPC will call the appropriate stub and it will pass the required parameters that are provided to the remote procedure and then this stub locates the port on the server and marshall’s the parameters so the stuff will locate the port on the server so on the server there will be different kind of services that will be available and each service will be identified by a port number so we have discussed about port in the previous lecture where we studied about sockets so that specific port has to be found out so the stub will do that part it will locate the port on the server and it marshals the parameters that means it will combine.

Leave a Comment