DCE RPC provides an environment for RPC applications that create multiple application threads (multithreaded applications). The application threads of a multithreaded application share a common address space and much of the common environment. If a multithreaded application must be thread-safe (guarantee that multiple threads can execute simultaneously and correctly), the application is responsible for its own concurrency control. Concurrency control involves programming techniques such as controlling access to code that can share a data structure or other resource to prevent conflicting overlapping access by separate threads.
A multithreaded RPC application can have diverse activities going on simultaneously. A multithreaded client can make concurrent remote procedure calls and a multithreaded server can handle concurrent remote procedure calls. Using multiple threads allows an RPC client or server to support local application threads that continue processing independently of remote procedure calls. Also, multithreading enables the server application thread and the client application threads of an RPC application to share a single address space as a joint client/server instance. A multithreaded RPC application can also create local application threads that are uninvolved in the RPC activity of the application. The following figure shows an address space where application threads are executing concurrently.
The application threads in the following figure are performing the following activities:
· The server application thread is listening for calls.
· A call thread is available to execute an incoming remote procedure call.
· One client application thread has separated from an RPC thread and another is currently part of an RPC thread.
· A local application thread is engaging in non-RPC activity.
A Multithreaded RPC Application Acting as Both Server and Client