Local procedure calls in Windows

The message-passing facility in Windows is called the local procedure call (LPC) facility. LPC is used for communication between two processes on the same machine. It is similar to the standard remote procedure call (RPC) mechanism that is widely used, but it is optimized for and specific to Windows. Windows uses a port object to establish and maintain a connection between two processes, like Mach. Two types of ports are used by Windows: connection ports and communication ports.

The communication works as follows −

  • Server processes publish connection-port objects that are visible to all processes.

  • When a client wants services from a subsystem, it opens a handle to the server’s connection-port object and sends a connection request to that port. The server then creates a channel and returns a handle to the client.

  • The channel consists of a pair of private communication ports: one for client-server messages, the other for server-client messages. Communication channels also support a callback mechanism that allows the client and server to accept requests when they would normally be expecting a reply

When an LPC channel is created, one of three message-passing techniques is chosen −

  • For small messages (up to 256 bytes), the port’s message queue is used as intermediate storage, and the messages are copied from one process to the other.

  • For Larger messages, they must be passed through a section object, which is a region of shared memory associated with the channel.

  • An API is available that allows server processes to read and write directly into the address space of a client, the amount of data is too large to fit into a section object.

It is decided by client when it sets up the channel whether it will need to send a large message. If It is determined by client that it does want to send large messages, it asks for a section object to be created. Like that, if the server decides that replies will be large, then it will create a section object. Now to use the section object, a small message is sent that contains a pointer and size information about the section object. This method is more complicated than the first method listed above, but it avoids data copying. It is important to note that the LPC facility in Windows is not part of the Windows API and hence is not visible to the application programmer. Rather, applications which are using the Windows API invoke standard remote procedure calls. When the RPC is being invoked on a process on the same system, the RPC is handled indirectly through an LPC. procedure call. Additionally, many kernel services use LPC to communicate with client processes. The structure of local procedure calls in Windows is shown in below Figure &inus;

Figure: Local procedure calls in windows

Published on 11-Oct-2019 15:59:39