Local procedure calls in Windows

The Local Procedure Call (LPC) facility in Windows is a message-passing mechanism designed for communication between two processes on the same machine. LPC is optimized specifically for Windows and serves as an efficient alternative to standard Remote Procedure Call (RPC) mechanisms. Windows uses port objects to establish and maintain connections between processes, similar to the Mach operating system.

Types of Ports

Windows employs two types of ports for LPC communication:

  • Connection ports − Used for establishing initial connections between client and server processes

  • Communication ports − Used for actual message exchange after the connection is established

How LPC Communication Works

LPC Communication Process Client Process Server Process Connection Port 1. Connect 2. Request Communication Channel (Pair of private ports) Small Messages (<256 bytes) Large Messages (Section Object) Very Large (Direct API)

The LPC communication process follows these steps:

  1. Server processes publish connection-port objects that are visible to all processes in the system.

  2. Client opens a handle to the server's connection-port object and sends a connection request to that port.

  3. Server creates a communication channel and returns a handle to the client. This channel consists of a pair of private communication ports: one for client-to-server messages and another for server-to-client messages.

  4. Bidirectional communication begins through the established channel, which also supports a callback mechanism for handling unexpected requests.

Message-Passing Techniques

When an LPC channel is created, one of three message-passing techniques is chosen based on message size:

Message Size Technique Method
Small (< 256 bytes) Message Queue Messages copied through port's message queue
Large Section Object Shared memory region associated with the channel
Very Large Direct API Server reads/writes directly into client's address space

Section Object Usage

For large messages, the client determines when setting up the channel whether it will need to send large messages and requests a section object (shared memory region) to be created. Similarly, if the server expects to send large replies, it creates a section object. A small message containing pointer and size information about the section object is sent, avoiding expensive data copying operations.

LPC in the Windows Architecture

The LPC facility is not part of the Windows API and is therefore not directly visible to application programmers. Instead, applications using the Windows API invoke standard Remote Procedure Calls (RPC). When an RPC is invoked on a process within the same system, the RPC runtime handles it indirectly through LPC, providing transparency to the application.

Additionally, many kernel services use LPC to communicate with client processes, making it a fundamental component of Windows inter-process communication infrastructure.

Conclusion

Local Procedure Calls provide an efficient, optimized message-passing mechanism for Windows inter-process communication. By using connection and communication ports with multiple message-passing techniques, LPC ensures optimal performance for different message sizes while remaining transparent to application developers through the RPC abstraction layer.

Updated on: 2026-03-17T09:01:38+05:30

2K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements