|
YOUR FEEDBACK
|
TOP MICROSOFT .NET LINKS Web Services A New Approach to Remote Object Communication
A New Approach to Remote Object Communication
Feb. 26, 2003 12:00 AM
Object-oriented runtime models are extremely popular in local system
contexts, and considerable effort has been made to globalize the familiar
notions of software object and method call. Ironically, the resulting
technology of remote objects and remote method calls doesn't port well to an
environment of "real" hardware objects except in the most trivial cases. Two
immediate reasons are:
This article presents a project that is part of the ROTOR initiative and is partially funded by Microsoft Research. The final goal of the project is to enable the use of .NET as a cross-development platform for programmed "wearable" devices. In this context, we first present an interoperability framework for distributed hardware objects. We then show how the .NET Shared Source Common Language Infrastructure (SSCLI) has been used to upgrade the C# notion of objects and the C# compiler to support this framework optimally. With the aim of establishing an experimental simulation and development platform for distributed devices, we have implemented a suitable concept of remote objects in C#, based on ROTOR. Specifically, we have added two new member types of C# objects: activities and channels. Syntactically, both constructs resemble methods without parameters. Semantically, however, they are quite different.
Activities
Channels Note that in our remote object model formal grammars take the role of interfaces. The querying mechanism used is reminiscent of COM and presupposes some obligatory home protocol analogous to the infamous IUnknown interface.
Comparing our channel-based communication model with remote method
invocation, we recognize some obvious advantages.
Figure 1 shows two active objects, A and B, communicating with each other via channel C. Note that object B is simultaneously carrying out another dialogue with a third object. The examples in Table 1 are organized in ascending order of complexity and illustrate the versatility of formal grammars. The form of representation used is Extended BNF (Extended Backus-Naur Form). Return message traffic is highlighted in italics.
Mapping the New Constructs
class A {
Channels Let us now assume the following declaration of a channel C within class B:
class B {
Then, the mapping of this channel by the compiler results in the
following trio of features within B.
Another important aspect of this model is the mapping of the basic channel operations open, close, ! (send token), and ? (receive token), in which the first two occur in the client code only, while the latter two can be used in different variants by both the client and the server, as illustrated by the following code fragments. Token is an auxiliary class defining a universal set of tokens and is contained in a library named System.Channels.
Client code
using System.Channels
class B { The actual mapping of the different constructs outlined above is specified by Table 2. Note the methodological similarity between the channel accessors and the usual property accessors in the C#. This provides the ability to access channels from foreign languages within .NET. The two buffers bound to each channel are stored as data slots in the thread descriptor. This allows the use of the "?" and "!" operators without channel reference from anywhere within the channel thread. It also allows the generation of inline code for these operators.
Extending the SSCLI C# Compiler Visual Studio in particular its debugging facilities turned out to be a practical tool for getting a detailed understanding of the code. The easiest way to start the debugging environment is by typing: devenv /debugexe \sscli\build\v1.x86fstchk.rotor\csc.exe [source_file] The C# compiler basically proceeds in two passes. All metadata is handled during the first pass, while the method bodies are skipped. In the second pass, the previously skipped method implementations are further processed.
The most important data structures of the C# compiler are:
If new functionality is to be added to the compiler, the following modules are the most relevant ones: parser (CParser), class declaration routines (CLSDREC), binding step (FNCBIND), and code generator (ILGEN).
There are basically three different strategies for adding new
functionality to the compiler:
Method: Expand the new functionality into existing parse tree node types. Advantage: Easy and secure, nearly nothing can go wrong. Disadvantage: Proliferation of nodes even for very small extensions. Restricted possibilities. Overhead in subsequent compiler steps. Example: Implement activities by adding trees, as depicted by Figure 2.
Method: Derive new parse tree node type for the desired functionality and expand it into expression tree nodes. Advantage: Golden middle, easy, often recommended. Disadvantage: Burden of managing the symbol table manually.
Method: Derive a new expression tree node type for the desired functionality and expand it into a code sequence. Advantage: Flexible and efficient. Disadvantage: Can go wrong without warning. Burden of managing the symbol table manually. Example: Implementing activities by emitting IL code directly, as depicted in Listing 1. Listing 1 is available at www.sys-con.com/dotnet/sourcec.cfm.
Remote Channels Compared to the local case, the main difference is that clients do not open channels by invoking the desired server objects directly but by sending open requests to the channel manager. In detail, a client sends the specification of both the server object and the channel to the channel manager, which in turn locates the object, advises it to open the specified channel, and returns a reference to the remote channel to the client. Figure 3 shows both the architecture of the remote channel framework and the traffic flow. In particular, it shows the modeling of remote channel references in the form of local channels provided by the ChannelManager.
Conclusion and Outlook Our strategy for adding functionality to the compiler was to express it on the level of the code generator, with the aim of avoiding unnecessary overhead from building up and transforming data structures throughout the compilation process. Our next steps in this project will be to finish the implementation of the remote channel framework based on the SSCLI and to develop a downloading compiler back end for StrongARM-equipped embedded devices. Our final vision is a system that allows us to program ordinary C# objects upgraded by activities and channels, and then to download their full functionality to embedded devices simply by pressing a symbolic "burn" button.
Acknowledgement MICROSOFT .NET LATEST STORIES
SUBSCRIBE TO THE WORLD'S MOST POWERFUL NEWSLETTERS SUBSCRIBE TO OUR RSS FEEDS & GET YOUR SYS-CON NEWS LIVE!
|
SYS-CON FEATURED WHITEPAPERS MOST READ THIS WEEK BREAKING NEWS FROM THE WIRES
|
|||||||||||||||||||||||||||||||||||