Example program of a Remote Object Manager
		------------------------------------------

 A powerful and convenient way of designing a multitask system is to
use "Object oriented programming".  It means that for a data object, or physical object, you write a bunch of procedures for performing operations on that object.
Pretty simply, really.  You've probably done it.

 In a real-time system, as well as a bunch of procedures, you probably want
a controlling program which runs as an independent process, with overall
responsability for the object.  The smart step is to make some of
the operations on the object available to other processes by rpc.


	+---------------+
	|  Controlling	|
	|   program	|		+---------------+
	+---------------+		|  remote	|
		|			|    program	|
		| 			+---------------+
		|			    /
		|			   /
		|   ______________________/
		|  /		(RPC)
		| /
		|/
	+---------------+
	|  Access	|
	|   procedures	|
	+---------------+
		|
	    database
	  &/or physical
	     object



The access procedures are linked with the main program, and share its data
structures.  The main program also controls when external programs are
allowed to call the access routines.

	-	The remote program uses the acces routines like any other
		routine

	-	The control program can enable or disable access from outside
		for exclusive access to the object.

	-	The access routines may affect data structures, and
		synchonisation primitives, and so modify the main program
		behaves. (For instance, access routine can release
		the main program from a wait state).


In this example two instances of the same program communicate in this
way, to implement a simple game of battelships.  Each program manages
an object which is a fleet of ships.

	+---------------+		+---------------+
	|  Progam 1	|		|   Program 2	|
	+---------------+		+---------------+
		|\			      /	|
		| \			     /  |
		|  \__________		    /	|
		|	      \		   /	|
		|   ___________\__________/	|
		|  /	rpc	\		|
		| /		 \_____________	|
		|/		   rpc	       \|	
	+---------------+		+---------------+
	|  Access	|		|   Access	|
	|   procedures	|		|   procedures  |
	+---------------+		+---------------+
		|				|
		|				|
	      Fleet 1			     Fleet 2


The program provides two access functions for this object:

			o	"Declare war"
 			o	"Fire at me" 

which are accesible remotely.  This inter-module interface is described by the
declaration files MY_ARTILLERY.RPC and HIS_ARTILLERY.RPC.  [The local and
remote versions are named differently to avoid a clash of symbol names, so that
they can be distinguished in the program. The two interfaces are otherwise
identical, and are cross-coupled when the rpc addresses are defined]

The example is written in VAX/Pascal (to be easy to write) but should be
intelligible to those used to other langauges. (If you are not used to
Pascal, remember that it is best read backwards, as the main program is
at the bottom and the little routines at the top!).  The program is not
written to be portable.

FILES
	These are available on VXCERN::DISK$D1:[RPC.EXAMPLES.BATTLESHIPS]

	BATTLESHIPS.IPA		is the source code
	BATTLESHIPS.COM		is the command file to run it
	MY_ARTILLERY.RPC	}
	HIS_ARTILLERY.RPC	} are the RPC package definitions
	DESCRIP.MMS		describes how to build it under MMS


	BATTLESHIPS.EXE		is the executable image created by MMS


To Run the example, you need two Vt220 terminals, two processes and SYSNAM
privilege (which you don't get on VXCERN). Run the command file from each
terminal.


DISCLAIMER

The game is based on the one I used to play with my father when I was small,
with a few changes.  The main change is that you don't have to take it in turns
to fire, you can fire at will. This is less fair, but demonstrates the
asynchrounous, multithreaded nature of the system. The other change is that, to
save time, the program lays out your fleet for you in a random way rather than
giving you the chance to hide your ships in funny places. Complaints about the
rules of the game are not accepted: it is primarily a demonstration of RPC! 
Queries about RPC to VXCERN::TIMBL.