ONC+ Developer's Guide

MT Auto Mode

MT Auto mode enables RPC servers to automatically use Solaris threads to process client requests concurrently. Use the -A option to generate RPC code in MT Auto mode. The -A option also has the effect of turning on the -M option, so -M does not need to be explicitly specified. The -M option is necessary because any code generated has to be multithread safe.

Further discussion on multithreaded RPC begins on "Multithreaded RPC Programming"; see also "MT Auto Mode".

Here is an example of an Auto mode program generated by rpcgen. The rpcgen protocol filetime.x is shown in Example 3-21. A string is passed to the remote procedure, which prints it and returns the length of the string to the client. The MT-safe stubs are generated with:


Example 3-21 MT Auto Mode: time.x

		program TIMEPROG {
			version TIMEVERS {
				unsigned int TIMEGET(void) = 1;
				void TIMESET(unsigned) = 2;
			} = 1;
		} = 0x20000044;

% rpcgen -A time.x


Note -

When the -A option is used, the generated server code will contain instructions for enabling MT Auto mode for the server.

When compiling a server that uses MT Auto mode, you must link in the threads library. To do this, specify the -lthread option in the compile command.