Formal dialogues A new approach to remote object communication implemented as an extension to C# on ROTOR/.NET Raphael Güntensperger Jürg Gutknecht ETH Zürich.
Download
Report
Transcript Formal dialogues A new approach to remote object communication implemented as an extension to C# on ROTOR/.NET Raphael Güntensperger Jürg Gutknecht ETH Zürich.
Formal dialogues
A new approach to remote object
communication
implemented as an extension to C# on
ROTOR/.NET
Raphael Güntensperger
Jürg Gutknecht
ETH Zürich
Agenda
1.
2.
3.
4.
5.
Overview
Concepts
Model
Implementation
Development platform for tiny devices
(outlook)
Overview
Use .NET as a cross-development platform
for programmed ‘wearable’ devices.
Communication
model
Formal dialogues
Syntactic integration
in C#
1.
Development
environment for small
wearable devices
Burn-down of
programmed logic
2.
Concepts
Motivation
Autonomous behavior of hardware objects
• Independent activities
• Asynchronous execution
• Example: Clock
Concept: Activity
Rich interface to the environment
• More than only a set of methods
• Dialog-based interfaces
• Objects have a status
Concept: Channels
Concepts
A new
model for remote objects
Active Objects (activities)
Formal Dialogues (channels)
Universal encoding of syntactic Tokens
No: RPC, RMI, IDL, Proxies, Marshalling
Optimal
Support by C# and .NET runtime
Compiler integration
Small library (System.Channels)
Concepts
Activities
Separate thread of control
Member of a class
Started at instantiation time of the object
Defines an
Active Object
activity {
…
}
Concepts
More
about activities
No activity, one or more activities per class
Passive Object
Active Object
Derived classes can define their own activities
All activities are started at instantiation time
(incl. Base class activities) and run in parallel
class ActiveObj {
….
activity { … }
activity { … }
}
class DerivedActiveObj : ActiveObj {
…
activity { … }
…
}
Concepts
Channels
Vehicle for the implementation of formal
dialogues
• Channel type
formal dialogue
Interface
• Channel instance
dialogue in execution
• Channel implementation
syntax parser
channel MyChannel {
…
}
Parser code
Concepts
More
about channels
Remote Interface of an object
Set of implemented protocols
Channel instances run in separate threads
Opened and closed by a client
Member of a class
In contrast to activities:
• controlled by client
• one instance (thread) per connection
• communication capabilities (through accessors)
Concepts
Communication follows a formal dialogue
• Exchange of syntactic tokens
• Can be described by an EBNF syntax
• bi-directional definition
back direction
Example:
ParkingLot = GetFree freeList parkingLot success
freeList = { parkingLot }
Parser defines semantic actions
Strongly typed tokens
Dialogue has its own status
Partners do not
store the status
Intrinsic
activity of
object
Concepts
Client A
Channel
instance
Client B
Server
Concepts
Example:
d
A
exchange
syntactic
Channel
open
type
D D?tokens
[ACK]
B
Concepts
Advantages to Remote Method Invocation:
1.
Sender is not blocked
2.
State of the dialogue is completely captured by the channel
3.
Tokens are typed by the underlying grammar and encoded
according to universal rules.
Save precondition for programming language independency
Model
Components & data flow abstraction
Model
Channel
open
close
send
receive
put
get
accessors:
Instantiate channel, invoke parser
abort parser thread
Implemented as public static methods
pass token to buffer of remote channel
read token from buffer of remote channel
pass token to internal channel buffer
inline (private)
read token from internal channel buffer
Model
3 layer model for remote channels
Implemented by the parser of a
channel and the client which
opens the channel
Handling of channel instances.
Abstraction of the
communication technology
Separation: Independent implementation
Concrete example-implementation: TCP/IP
Implementation of the transport
technology.
Responsible to transmit data
blocks between destination.
Exchangeable for any
transport technology.
Model
{ c = new b.C }
Model
Gateway
channels
Abstraction of a remotely available channel in
the clients address space
ONE gateway (instead of proxies)
Implemented as member of channel manager
• ChannelManager.RemoteChannel
Buffer content is directly
sent to the remote
channel manager
and vice versa
Model
Transmit Buffer-Content by channel manager
• Channel Provider: Tracking buffers of channel instances
• Client: Tracking buffers of RemoteChannel instances
Channel instances are identified by GUID
Model
Home
Channel:
Query for implemented protocols
Implicitly implemented (by the compiler) for
any channel provider
Provides a query mechanism comparable to
COM (IUnknown)
Behaves exactly like any other channel
but follows a fixed syntax
Syntax
List names of implemented channels
“list” nOfChannels { “channel” ChannelTypeName }
Implementation (Compiler)
Channel
variable
syntax(reference)
Accessor
C#
IL mapping
open
c = new b.C
c = open_C()
close
close c
close_C()
send
c!t
send_C(c, t)
receive
c?t
t = receive_C(c)
put
!t
- inline -
get
?t
- inline -
Implementation (Compiler)
Threading
model
Thread represents channel instance
Buffer references stored relative to thread
context
Advantage: Possibility to call channel
Named thread slots
accessors outside the parser method
Thread is started by open accessor
Code
example
IL_001d:
IL_0022:
ldstr
call
IL_0027:
IL_0029:
ldloca.s
ldfld
IL_002e:
call
"$outBuf$“
class [mscorlib]System.LocalDataStoreSlot
[mscorlib]System.Threading.Thread::GetNamedDataSlot(string)
V_0
class System.Channels.Buffer
System.Channels.ChannelManager/RemoteChannel::$outBuf$
void [mscorlib]System.Threading.Thread::SetData(class
[mscorlib]System.LocalDataStoreSlot, object)
Implementation (Library)
Token
enumerations
Map a set of basic types:
char, int, long, float, double, keyword, string, bool, block, escape
Define their own encoding
• Basic Format: tagByte { dataByte }
• Shortest encoding for most frequently used types
• Use value bits in the tag byte (for small data types)
Buffer
Ring-buffer implementation
• enlarged automatically if the get full
Limit can be specified
Implementation (Library)
Channel
manager
GUID
Responsible to handle channel instances and
map their corresponding parts (local/remote)
Defines gateway channel
Channel manager messages:
•
•
•
•
Open/Close requests
Data transmission
Close enquiry
Acknowledgements
close
idle channels
Implementation (Library)
Transport
manager
Abstract class
• Must be implemented for a specific technology
• Current implementations: TCP/IP, Nullmodem
Must provide reliable transmission of encoded
data
Destination
Abstraction of the
communication
end-point
Implementation (Compiler/Library)
Implicit interface for channel providers
• Defined in library, implemented by compiler
public interface IChannel
{
ChannelNode OpenChannel(string name);
}
ChannelManager calls OpenChannel
method of specific channel implementation
OpenChannel method
• Implicitly generated by the compiler
• Maps channel names to channel types
• Returns buffer and thread references by
ChannelNode structure
Implementation (Example)
class ParkingService {
ParkingLot = GetFree freeList parkingLot success
bool[] freeList;
channel ParkingLot {
Token currentToken;
…
while(true) {
?currentToken;
if(currentToken is TokenKeyword &&
(Keywords) currentToken.Value == Keywords.GetFree) {
SendFreeList();
?currentToken;
success = Park((int) (currentToken.Value));
!Token.NewToken(success);
}
int number, chosed; bool parked;
}…}}
enum
// get free parking lots
myChannel!Token.NewToken(Keywords.GetFree);
myChannel?receivedToken;
while((int) receivedToken.Value != -1) {
Console.Write("{0} ", (int) receivedToken.Value);
myChannel?receivedToken; }
// chose one of the free parking lots
myChannel!Token.NewToken(chosed);
myChannel?receivedToken;
parked = (bool) receivedToken.Value;
Development platform for tiny
devices (outlook)
Cross
compiler: IL
StrongARM
Limited to the functionality demanded by tiny devices
Device
represents active object
Implement a specific transport technology
Bluetooth / Smart-Its (University of Karlsruhe)
‘Burn’ mechanism
invokes cross compiler
and builds operating system environment of
the small device
Reference
.NET Developer’s Journal, Volume 01, Issue 3
A New Approach to Remote Object Communication
• http://www.sys-con.com/dotnet/