### Specifying Multithreadedness

The application may also spawn an additional thread for a signal handler. An example follows:

if (pthread_create(&sigcatcher,
pthread_attr_default,
(pthread_startroutine_t)signal_handler,
(void*)0))
{
dce_svc_printf(NO_SIGNAL_CATCHER_MSG);
exit(1);
}

The max_calls_exec parameter to the rpc_server_listen( ) routine specifies the number of operations that the server can perform concurrently in response to client requests. The max_calls_exec parameter is also used to derive the size of a buffer (the call request buffer) for incoming client requests that cannot be immediately executed. max_calls_exec specifies the upper limit for the number of RPC threads that will be spawned by the RPC runtime to handle incoming remote procedure calls. Thus, an important side effect of rpc_server_listen( ), when the specified concurrency is greater than 1, is to create multiple threads of execution in the server.

The threads are automatically spawned to handle whatever operation is requested by the client. If the maximum number of manager threads is already active and more incoming calls arrive, the RPC runtime buffers them in a call request buffer. The size of the call request buffer depends on the max_calls_exec parameter; the larger the parameter, the bigger the buffer. Incoming calls beyond the call request buffer capacity are rejected (with an error code) by the RPC runtime.

Although the execution threads are automatically managed by the RPC runtime, the developer is responsible for coding the manager routines according to thread-safe guidelines so that the threads will execute properly. For further information on thread-safe programming practices, see Threads.

###