YOUR FEEDBACK
udaykiran wrote: Really Excellent Information. But i have some doubts. initially i have some aver...

SYS-CON.TV
TOP MICROSOFT .NET LINKS


A New Approach to Remote Object Communication
A New Approach to Remote Object Communication

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:

  • Many hardware objects develop their own intrinsic activity. Rather than just waiting for the next stimulus, such objects act and behave autonomously. A good example of an "active" object is a clock.
  • Many hardware objects expose an interface to their environment that is richer and more sophisticated than simple tables of methods. For example, automatic teller and ticketing machines typically implement transaction interfaces.

    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
    An activity is a separate thread of control that is launched automatically when the object is created. Its domain of operation is the object state space. An object can have none, one, or more activities associated with it; the activities themselves are responsible for synchronizing properly among themselves and with method calls. Activities defined in an extended class run in parallel with activities defined in the corresponding base class. If an object has no activity, it is called passive. Shared resources are typical examples of passive objects.

    Channels
    In our context a channel is a vehicle for the support of syntax-controlled dialogues between objects. The idea is that a formal grammar underlies each channel type, thereby acting as a contract between the dialogue partners. A dialogue is then simply an exchange of syntactic tokens under control of the grammar, and both the sender and the receiver incorporate a parser for this grammar. In technical detail, this is what happens when object A intends to communicate with object B:

  • A queries B for the support of the desired dialogue d
  • If positive, A advises B to open a channel of type d
  • B creates a separate thread representing channel d
  • A and B exchange syntactic tokens over d
  • B's implementation of channel d ends

    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.
    1.   By concept, the sender is not blocked while the recipient is in action.
    2.   The state of the dialogue is completely captured by the channel, concerns are decoupled effectively, and programming is simplified considerably, in particular in scenarios with multiple simultaneous dialogue partners.
    3.   Tokens are typed implicitly by the underlying grammar and encoded explicitly according to universal rules, a safe precondition for an interoperability scheme that is inherently programming language independent.

    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
    Activities

    Because activities are supposed to control a separate thread that is created when the containing object is instantiated, activities declared by the following class A description are mapped into methods with synthetically generated names. In addition, the constructor of A is extended with code to create the new thread(s).

    class A {
    ...
    activity {
    // activity statements
    }
    ...
    }

    Channels
    Channels are again run as separate threads. However, in contrast to activities, channels are named and instantiated explicitly. As a consequence, multiple instances of the same channel can run simultaneously within the same object.

    Let us now assume the following declaration of a channel C within class B:

    class B {

    ...
    channel C {
    // parser statements
    }
    }

    Then, the mapping of this channel by the compiler results in the following trio of features within B.

  • Structure C, which defines the corresponding thread and two buffers
  • Method $parser$C, which contains the parser
  • Accessor methods open_C, close_C, send_C, receive_C

    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
    ...
    Token t;
    B b = new B();
    B.C c = open b.C;
    ...  c!t; ...  c?t; ... 
    ... 

    Server code

    class B {
    ...
    channel C { Token t;
    ...  ?t; ...; !t; ... 
    }
    }

    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
    In order to implement the constructs of activities and channels on the foundation of the SSCLI, it is important to have a good understanding of the C++ code of the C# compiler before applying any changes. After installing the SSCLI sources a full compile with the buildall command is necessary. Later, the build command in the respective directory can be used for creating partial builds. For example, calling build in \sscli\clr\src\ csharp\csharp merely creates the 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:

  • The parse tree: A tree representation of the source code, in which the nodes correspond to syntactic entities down to the finest granularity. Names are left unresolved at this stage.
  • The symbol table: Reflects the scope hierarchy of imported and locally declared objects after name resolution. The relevant part of the symbol table is mapped to the metadata table in the corresponding PE (portable executable) file, where symbols are represented as tokens that are synthetically generated by the compiler.
  • The expression tree: A semantically processed parse tree, in which the names are resolved and replaced with references to the symbol table.

    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:

  • At the parse tree level:
    ­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.

  • At the expression tree level:
    ­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.

  • At the code level:
    ­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
    Remembering our final goal of providing an environment for cross-developing programmed devices, we simulate such a device on .NET by an executable module in terms of three static classes (that is classes with static members only) called DistributedObject, ChannelManager, and TransportManager respectively, with tasks summarized by Table 3.

    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
    Although frighteningly huge (in terms of typical ETH software units), the SSCLI turned out to be surprisingly manageable, all in all. The .NET and SSCLI developer lists maintained by the University of Pisa, with their fast response times and helpful answers, were a big plus. Unfortunately, the C# compiler shipped with the SSCLI is not written in its own language but in C++ instead. The voluminous C++ code exacerbated some starting difficulties we had. Given the current implementation of the compiler, Visual Studio came in handy as a great tool both for understanding the technology in detail and for debugging the new code.

    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
    We gratefully acknowledge the opportunity to cooperate with Microsoft in a substantial project, along with the financial contribution provided by Microsoft Research.

    About Raphael Guntensperger
    Born 1975/02/20 in Switzerland, where I also grow up, near Zurich. Study in computer science at ETH Zurich. 2002 Practical training at Microsoft working in the field of .NET and ROTOR. Presently I do my diploma work, working in the group of Prof. Gutknecht.

  • MICROSOFT .NET LATEST STORIES
    VMware’s ESX hypervisor has become the first third-party hypervisor accredited under Microsoft’s months-old Server Virtualization Validation Program (SVVP). The validation applies to VMware ESX 3.5 update 2 (ESX 3.5u2) and means VMware customers who run Windows Server and Microsoft...
    We are seeing more being written about Cloud computing and cloud platforms today, and there is strong validation that the future of computing will include significant innovation and value in web/cloud platforms. Microsoft’s Cloud strategy is materializing, and as part of our overall ...
    Nth Penguin has released WW.DataServices to the public and is available for immediate download at: www.nthpenguin.com. WW.DataServices, the first system of the WebWidgetry engine, removes all the work from accessing your data. You simply point it to a database location, push a button,...
    Gizmox announced the release of a fully functional beta version of its Visual WebGui (VWG) with support for Microsoft Silverlight. For the first time, VWG enables Silverlight for enterprise applications by providing a RAD like Windows Forms development experience with drag & drop desig...
    Google will come out from behind the Firefox browser that it’s been pumping money into – and profiting royally from – and take direct aim at Microsoft with a browser of its very own. The widgetry is called Google Chrome and Google Chrome, like all of Google’s non-search widgetr...
    SUBSCRIBE TO THE WORLD'S MOST POWERFUL NEWSLETTERS
    SUBSCRIBE TO OUR RSS FEEDS & GET YOUR SYS-CON NEWS LIVE!
    Click to Add our RSS Feeds to the Service of Your Choice:
    Google Reader or Homepage Add to My Yahoo! Subscribe with Bloglines Subscribe in NewsGator Online
    myFeedster Add to My AOL Subscribe in Rojo Add 'Hugg' to Newsburst from CNET News.com Kinja Digest View Additional SYS-CON Feeds
    Publish Your Article! Please send it to editorial(at)sys-con.com!

    Advertise on this site! Contact advertising(at)sys-con.com! 201 802-3021


    SYS-CON FEATURED WHITEPAPERS

    ADS BY GOOGLE
    BREAKING NEWS FROM THE WIRES
    Neverfail, a leading global software company providing affordable continuous availability and disast...