|
SCT DAQ/DCS/Test SoftwareDemonstration and Overview of IPC:12 November 2002Since in the last meeting I claimed that it should be fairly straightforward to use IPC, I thought I had better prove it! Here is a brief overview of the test application, followed by a brief explanation of IPC, some pointers on how to design a class structure that can easily have IPC retro-fitted and finally some threading issues. Helloworld application:This is a simple HelloWorld set of applications that use IPC to do some simple communication. We have got them working at Cambridge with each application running on a different machine (note all have access to the same file system). The application consists of
It should be noted that the application requires a working installation of the Online Software, a general partition server and partition server for the partition be_test. This can be achieved by running: machine> ipc_server &
Overview of IPCIPC is a thin layer on top of ILU - a CORBA implementation from Xerox (Links). CORBA provides a language and platform independent mechanism for local and distributed inter-process communication. It achieves this by defining the communications protocols and also by using a language independent specification of the interface that objects (servers) present to clients. This interface is written in Interface Definition Language (IDL). IDL has many similarities with Object-Oriented (OO) syntax found in Java and C++. The principle components of IDL are:
It is also possible to define valuetypes which would correspond to a Java class of a C++ class with data members. It is probably a good idea to avoid these though in simple applications as it restricts the implementation. In IPC applications, your interfaces should derive from ipc::freeable. The implementation of this interface is provided by the IPCObject class. The IDL file is converted into code by a stubber. For instance, the C++ stubber creates a number of classes based on the IDL file. These provide the necessary code for making and receiving remote calls. Normally, you write a class that derives from the IPC base object, IPCObject and implements your interface. For a more clear and lucid explanation, see the Online Software website. Pointers for writing C++/Java classes for later retro-fitting IPC
Um, that's all I can think of. IPC is designed to make it easy to give external programs access to your class structure.
Threading issuesWhen writing a server (i.e. a program that provides an interface for clients to use), the IPC core can be initialized in single-threaded or multi-threaded modes. In multi-threaded mode, ILU (the underlying CORBA implementation) will spawn a new thread to deal with each incoming request. Thread safety in the external interface is therefore crucial. In single-threaded mode, each request is handled in order. However, there is still a threading issue if the server is also a client. If a server receives a request and whilst dealing with it, calls another server using IPC, then, whilst waiting for that call to return, requests will be dealt with. This behaviour is intended to prevent deadlocks. I think it is probably a good idea if code is made thread-safe so that a server can always be contacted and can provide status information.
|
Last modified 15 February 2003 . Maintained by Matthew Palmer |