9512.net
甜梦文库
当前位置:首页 >> >>

Coordination Among Mobile Objects


Coordination Among Mobile Objects
Luigia Petre Kaisa Sere
Turku Centre for Computer Science and Abo Akademi University, FIN-20520, Turku, Finland.

Department of Computer Science, Abo Akademi University and Turku Centre for Computer Science, FIN-20520, Turku, Finland

TUCS

Turku Centre for Computer Science TUCS Technical Report No 219 November 1998 ISBN 952-12-0332-3 ISSN 1239-1891

Abstract
When designing distributed object-based systems one is often faced with the problem of modeling the movement of objects from site to site in a distributed network. In order to model such an activity, some supervising or coordination mechanisms are needed, to insure correctness of both movement and communication in the network. In this paper we propose distributed object-based action systems as a basis for (coordinated) mobile computing. In order to model mobility and coordination we extend the action systems and OO-action systems formalisms with so called mobile objects and coordinator objects. The mobile objects move in some domain whereas the coordinator objects control the actions of the mobile objects within their respective domains. We show the applicability of the proposed framework with a small though nontrivial example.

Keywords: Object-orientation, action systems, mobile computing, coordination.

Programming Methodology Group

TUCS Research Group

1 Introduction
Action systems 5] and OO-action systems 9], their object-oriented extension, have proven their worth in the design of parallel and distributed systems 6, 9]. In the design of distributed object-based systems one is often faced with the problem of modeling the movement of objects from site to site in a distributed network. In describing mobility, the coordination mechanisms play an essential role, insuring the correct functionality of the system. In this paper we propose distributed object-based action systems 10] as a basis for (coordinated) mobile computing. Recently, several languages and models for coordinating the work of independent agents have been proposed in the literature 16, 19]. Linda 13] and Manifold 3] are examples of languages dedicated for coordination. LLinda 18] is a Linda-based coordination language extended with localities. We focus on languages where one can describe both coordination and computation aspects of a system. For Gamma programs 8], for instance, a coordination construct called scheduler is introduced 15]. Another construct is the rtsynchronizer 25] which is a special form of an actor 1]. Often there have been di culties in incorporating the new constructs into a formal framework. For example, there is no formal semantics given to the rtsynchronizers neither do they come with a methodology to reason about them or develop systems that involve them. For the Gamma approach, a separate framework is introduced for reasoning about the schedulers. MobileUNITY 23] is a recent extension of UNITY 14] towards mobility. One of the main novelties of MobileUNITY is the facility to coordinate mobility. In our earlier work 20] we have shown how coordination can be modeled within an existing formal framework, action systems, where both computation and coordination aspects are treated equally and uniformly without introducing new language constructs. One of the goals in this paper is to show how these concepts carry over to the coordination of objects and mobility within OOaction systems. OO-action systems model classes and instances of classes, i.e. objects, are created at run time. The objects themselves are typically active having a local state and autonomous actions. Communication between objects takes place via method invocations. An OO-action system thus models a set of distributed objects 10]. In order to model mobility and coordination we exted the OO-action systems formalism with special classes. One of the new forms of classes will stress the location and movement the instances of these classes are called mobile objects. A mobile object is the unit of mobility. It has a state of its own which it carries with it when moving from location to location. The range of values of the location models the domain in which the mobile object moves. As this set of values can be very large, it is divided into smaller sets, called cells, which form a partition of the initial domain. Every cell is managed by a coordinator object, produced by a coordinator class. The 1

coordinator object is responsible for scheduling events and supervising the mobile objects so they do nothing illegal within the cell of the coordinator. This is done in such a way that the mobile object is not aware of the coordination taken place. An important feature we have obtained by de ning such a structure is usually called location transparency: even if the mobile object is aware of its mobility and its location, it performs its operation as these issues would not matter at all. Thus, a modularity advantage can be used: we can develop separately the computation and the coordination aspects of our system, the coordination being taken care of by the coordinator objects. The new types of classes are also classes in the original sense of OO-action systems. Therefore within the architecture of an OO-action systems speci cation using this extended framework we have classes that model active (distributed) objects, others that model mobile objects, and separately classes modeling coordinator objects all within a single framework. Hence, we make the following contributions: We show how a formal framework for distributed object-based systems is extended to handle mobility of objects. We develop a method to coordinate distributed objects. We de ne a special form of a coordinator suitable for mobile environments. The rst model incorporating active objects was the actor model 21, 1]. Recently, several formalisms and languages that o er active objects have also been proposed, e.g. Java, POOL 2], and Oblique 11], which supports distributed object-oriented computation and allows mobile objects much the same way as our formalism. Oblique is, however, intended as a programming language whereas we consider OO-action systems more to be a speci cation language containing constructs that are not directly implementable. A somewhat similar view on objects as taken here is de ned for the DisCo speci cation language 22] as well as in 4]. In both of these action systems related works, objects are active and spend their lives participating in enabled actions. They do not, however, consider mobility nor do they support the idea of separating coordination and computation. More formal frameworks to model and reason about mobility are the -calculus 24], Mobile Ambients calculus 12], MobileUNITY 23], and COMMUNITY 27]. The rst two are event-based formalisms whereas the latter two are state-based like action systems. MobileUNITY uses temporal logic as its formal basis. The semantics of COMMUNITY is based on category theory. Action systems as well as OO-action systems are de ned using the predicate transformer semantic 17] and the re nement calculus 6, 7]. Therefore there is a notion of re nement for OO-action systems within the re nement 2

calculus 9] for reasoning about distributed objects. Even though the connection with the re nement calculus is out of the scope of the present paper, all the constructs we develop are such that they t into the re nement calculus framework. The re nement calculus provides us thus a solid mathematical foundation to work on. For example, distributed mobility classes can be stepwise developed from ordinary classes to their implementation, decentralised coordinators can be derived from centralised coordinators, and coordinators can be stepwise brough about 20]. The correctness of every step can be veri ed within the re nement calculus or performed by appealing to pre-proven transformation rules. We proceed as follows. In section 2 we give an overview of distributed OO-action systems. In section 3 we show how to specify movement and introduce the notion of a mobile object we also consider a rst approach of the example we will use throughout the paper. In section 4 we treat the notion of coordination in OO-action systems. Thereafter we develop a method of coordination in mobile environments. The example is now presented in a new form, pointing out the use of our constructs. We conclude in section 5 with some nal remarks.

2 Distributed OO-action systems
In this section we present the OO-action systems formalism, focusing on distribution. An OO-action system consists of a nite set of classes, each class specifying the behavior of objects that are dynamically created and executed in parallel. We start by presenting the language used for specifying classes and objects. Then we describe the OO-action systems approach and its suitability for distribution.

The language We will consider a xed set Attr of attributes (variables) and assume that each attribute is associated with a nonempty set of values. We consider the following language of statements de ned by the grammar
S ::= abort j skip j x := v j p j if b then S
else

S

jS

S:

Here x is a list of attributes, v a list of values (possibly resulting from the evaluation of a list of expressions), b is a predicate and p a procedure name. Intuitively, `abort ' is the statement which always deadlocks, `skip ' is the stuttering statement, `x := v ' is a multiple assignment, `p ' is a procedure call, `S1 S2 ' is the sequential composition of two statements `S1 ' and `S2 ' and `if b then S1 else S2 ' is the conditional composition of two statements `S1 ' and `S2 '. A procedure declaration p = P consists of a header p and of a body P . The semantics for this set of statements is well-de ned via the weakest precondition wp predicate transformer 17]. 3

Let further CName be a xed set of class names and OName a set of valid names for objects. We will also consider a xed set of object variables OVar assumed to be disjoint from Attr . The only valid values for object variables are the names for objects in OName . We extend the grammar above:
S ::= ::: j n := o j new (c ) j n := new (c ) j n :m :

Here n is an object variable, o is an object name (possibly resulting from the evaluation of an expression), c is a class name and m is a method name. The statement `n := o ' stores the object name o into the object variable n , `n :m ' is a call of the method m of the object the name of which is stored in the object variable n . Note that method calls are usually pre xed by an object variable. If such a pre x is missing, the called method should be declared in the calling object. There are two object constructors `new (c )' and `n := new (c )'. The latter assigns the name of the newly created instance of the class c to the object variable n . The semantics for this extended set is de ned within predicate transformers via a translation to the action systems formalism 9]. We further enrich our language by de ning a grammar of actions:
A ::= b ! S j x :2 V j ] I Ai :

Here b is a predicate and I an index set ranged over by i . The action `b ! S ' is a guarded statement that is executed only when the guard `b ' evaluates to true , i.e., when the action `b ! S ' is enabled. The action ` ] I Ai ' is the nondeterministic choice among actions `Ai ' for i 2 I . Given a nonempty set V of values and an attribute x , we denote by `x :2 V ' an abbreviation for the nondeterministic assignment ` ] v 2V true ! x := v '. The semantics for actions is also de ned using the weakest precondition predicate transformer in a standard way 6]. Compared to the original language of OO-action systems 9] the language with two syntactic categories, statements and actions, as de ned here is slightly restricted. This restriction is done due as we do not want to present the formal semantics of the language which would be needed for some of the more advanced constructs. This form of the language is, however, enough for our purposes in this paper.

Classes and objects A class is a pair hc Ci, where c 2 CName is the name of the class and C is its body, that is, a collection of data (attributes and object variables), services (procedures and methods) and behavior (a set of actions to be executed in object instances of the class):
4

C

=

j

]

attr x := x0 obj n := n0 meth m1 = M1 proc p1 = P1 do A od

mh = Mh pk = Pk

(1)

j

The class body consists of an action A = ] I Ai of the above grammar and of four declaration sections. The rst declaration is for the local attributes in the list x , that describe variables that are local to an object instance of the class this means they can only be used by the instance itself. The variables are initialized to the values x0 . The list n of object variables describes a special kind of variables local to an object instance of the class. They contain names of objects and are used for calling methods of other objects. The object variables are initialized to the values n0 . We assume that the lists x and n are pairwise disjoint. A method mi = Mi describes a procedure of an object instance of the class. They can be called by actions of the object itself or by actions of another object instance of possibly another class. A method consists of an header `m ' and a body `M '. The latter is a statement of the above grammar. A procedure pi = Pi describes a procedure that is local to the object instances of the class. It can be called only by actions of the object itself. Like a method, it consists of an header `p ' and a statement forming the body `P '. The action speci ed in the do ::: od loop of a class is a description of the autonomous behavior that an object instance of this class has at run time. An action can refer to the object variables and to the local attributes declared within the class itself. It can contain procedure calls only to procedures declared in the class and method calls of the form n :m to methods declared in another class or itself. Calls to methods of other objects are possible only if the calling object has a reference, i.e. an object variable, to the called object this models the encapsulation mechanism.

OO-action systems An OO-action system OO consists of a nite set of
classes
OO =
fhc1 C1 i ::: hcn Cn ig

(2)

such that actions in each Ci or bodies of methods and procedures declared in each Ci do not contain new statements referring to class names not used by classes in OO . There are some classes in OO , marked with an asterisk . Execution starts by the creation of one object instance of each of these classes. Every 5

object has a local state. An object, when created, chooses enabled actions and executes them. If there is more than one enabled action at any given state, say A1 A2 A3 , the choice between them is nondeterministic, i.e. A1 ] A2 ] A3 . There is no notion of fairness in this model. Hence, unlike in e.g. Unity 14], the actual execution of any single action cannot be guaranteed. Actions are taken to be atomic. Because of this, actions within an object operating on disjoint sets of attributes and object variables can be executed in parallel. They can also create other objects. Moreover, enabled actions of di erent objects can be executed in parallel as they are operating on disjoint sets of attributes. Objects interact by executing methods of other objects. The meaning of a call on a method is determined by the substitution principle: Let A be an action in an object o1 calling a method m in some object o2 . Upon the call, the body of the method is substituted for each method call. Hence, the action A becomes A o2 :M =n :m ] where n is the object variable in o1 containing the reference to o2 and M is the body of the method m in the object o2 . The action A is then executed jointly by the objects o1 and o2 in an atomic fashion. Joint actions between more than two objects are modeled similarly. Here we assumed that the method m is parameterless. For a similar principle including parameters, the reader is refered elsewhere 20]. tem is a parallel composition of many objects, each of them representing an instance of a class 9]. As decribed above, we can have parallel activity within an object as well as between di erent objects. Initially, only the objects generated from the classes marked with an asterisk are active, i.e. their actions are potentially enabled. These actions might make other objects active by executing a new statement. Let us assume that we have a network of nodes which model some processes and edges which model the communication links between the processes. Assume further that each object in an OO-action system is associated with one of the processes and that the processes execute the enabled actions nondeterministically respecting the atomicity requirement. Due to this requirement, two actions cannot interfere with each others execution.The joint execution of an action by two or more objects naturally requires a communication link between the processes via which the method calls are carried through. Hence, an OO-action system models a distributed object-based system 10].

Distributed OO-action systems Computationally, an OO-action sys-

3 Specifying movement
We argued above that a set of objects constitutes a distributed system provided that the di erent objects are associated with and executed by some 6

nodes in a network of processes. In this section we introduce the notion of a mobile object in our framework and describe how to model a system where objects move from node to node in a network. bitrary number of agents which can move freely in some domain and, in the same time, do whatever computation they desire. Besides, at every moment these agents might want to communicate with other agents. Comparing the situation with distributed systems above, we should note the main di erence: the objects are moving and their behaviour can vary from location to location. Depending on their current location they can or cannot communicate, i.e., invoke method calls, with other objects. Otherwise, they behave as normal distributed objects. Hence, they carry their local state with them. Moreover, when an object moves from one location to another in its domain, it becomes active in the new location and ceases to exist in the original location. Let OLoc denote the domain of mobility. We extend our language with two new statements:
S :: = : : : j move (OList Lexp ) j l : = move (OList Lexp )

Mobile objects The systems we want to model usually consist of an ar-

(3)

Here Lexp is an expression yielding as result a location within the domain OLoc and OList is a list of object names ( OName ). The statement move (OList Lexp ) evaluates the expression Lexp with the subsequent movement of the objects in OList to this location. The statement l : = move (OList Lexp ) stores the value of the evaluation (2 OLoc ) in a special attribute l . The predicate
at (OList Lexp )

is used to check whether the objects in OList are at a certain location obtained by the evaluation of Lexp . When the list OList is missing, the calling object is the target of the movement or of the predicate evaluation. Moreover, Lexp gives us a very general way to specify a location. Now we can make the following de nition: De nition 1 A mobility class hmc MCi, is a class of the form:
MC

=

j

]

loc l :R attr x := x0 obj n := n0 meth m1 = M1 proc p1 = P1 do A od
7

mh = Mh pk = Pk

(4)

j

where l is a local attribute and the action A, the bodies of methods, and the bodies of procedures contain statements in the extended language (3). A mobile object is an instance of this class. The location attribute l describes a special kind of variable local to a mobile object. It stores values of locations, representing the position of the object. The type R ( OLoc ) of the location attribute is obligatory and denotes the domain in which the mobile object moves. The location attribute can be initialised to some value denoting the initial location of the object. The domain OLoc of mobility is to be understood as a powerfull abstraction for the possible values a location can take. It can thus model sites in a network, roads, maps or aircraft trajectories. A similar abstraction is also made in MobileUNITY 26]. We base our approach on the fact that the type-engine for our formalism is higher order logic 7]. Hence any type for location can be described. Changes in the values of the location attribute as well as executing a move statement model the movement of object(s) to another position in their domain. The predicate at (OList l ) can be used in guards and other boolean expressions to determine whether the current location of the object(s) is l . When the predicate is used as part of a guard, we call the guard a location guard. The mobility class de ned by (4) is a class in the sense of De nition (1), because the location attribute is merely a new kind of local attribute and the new statements can be understood as assignments to this attribute. Thus, we have extended our language by showing that the concept of a mobile object can be embedded into our framework for distributed objects.

Mobile-oriented action systems (MOAS) We are now in a position
to make the following de nition:
MO

De nition 2 A mobile-oriented action system is a nite set of classes
=
fhci Ci ii 2f1 ::: n g hmcj MC j ij 2f1 ::: s g g

(5)

where every hci Ci i is a class in the sense of De nition (1) and every hmcj MC j i is a mobility class (4).

Observe that MO is an object-oriented action system in the sense of (2). Mobile objects cannot communicate, i.e., invoke method calls, with other objects unless they are in a certain vicinity. Hence, the reciprocal visibility of two objects, at least one of them being mobile, needs to be guarded by a location guard. Unless this guard is true, the two objects are reciprocal invisible, even though they have references to each other via the object variables. When the location guard becomes true the communication via 8

method calls can take place. The domain de ned by the location guard can be seen as the proximity of the object, where communication can take place. This mechanism resembles MobileUNITY's transient variable sharing and transient action synchronisation 23] in that the communication and the visibility of two entities are possible only in the proximity of the mobile entity. Action syncronisation is here modeled by method calls: when an action calls a method in another object, the two objects get synchronised. In a similar manner we can of course synchronise more than two objects. Mobile objects as de ned in this paper do not share variables. However, in the general OO-action systems framework the view of objects sharing attributes is supported 9] and hence, our model of mobility extends to this. to model mobile objects within OO-action systems, we consider a luggage distribution example where the task is to model the luggage transport and delivery in an airport station. On a given trajectory, one/many carts are moving forward or just wait for some service to be done for them. Carts are given pieces of luggage, here called bags, by some stations on the trajectory, called loaders. The task of the carts is to transport the bags to some destination on the trajectory, where another station (the unloader) takes the bags from the carts. After this, the unloaders give the carts a new destination to a loader. The cart is restricted to carry only one or zero bags at a time. The trajectory is circular and there are as many loaders and unloaders as needed. The cart moves itself as long as it has not reached its destination and, when reaching the destination, the loading or unloading can be performed. We focus on modeling the movement of one cart a system dealing with many carts is left for the next section. The example is modeled by the following mobile-oriented action system1 :
fhChief

An example: a luggage distribution system As an example of how

ch i hDevice dev i hCart cart ig

Our system contains three classes. The Chief class, which starts the execution, is responsible for creating the mobile object in the system, the cart, and also for creating as many loaders and unloaders as needed. This need is considered here an internal policy of the system, which we have modeled by the attributes ld need uld need .
entities with no speci ed initial value. When an initial value is speci ed, the type of the respective entity can be easily deduced from it. For convenience also, we allow initial values to be returned by some initialisation procedures, speci ed in the procedure declaration. Entities with no speci ed initial value get arbitrary initial values in their domains. For procedures with no special signi cance to our example we do not specify their bodies.
1 For simplicity, we show the types of attributes and object variables only for those

9

ch =

j

]

attr cart need ld need uld need := T T T obj ld uld :Device cart :Cart do ld need uld need : T F ] ld need ld := new (Device ) ld SetType (Loader ) ] uld need uld := new (Device ) uld SetType (Unloader ) ] cart need cart := new (Cart ) cart need := F cart SetCanMove (T ) od
2 f g ! : ! : ! :

j

Since the loader and unloader are very similar concepts, we model them by a single class, called Device, whose type attribute can have two values: Loader or Unloader. When the Chief creates devices, it calls the method SetType to properly set this attribute.
dev =
j

attr proc meth

loc :integer cargo :queue of integer type :fLoader Unloader g Destination (val bag :integer res dest :Device integer ) NextLoader (val ld :Device res dest :Device integer ) Load (res bagid :integer dest :Unloader destloc :integer ) = ( if cargo 6= then cargo bagid := cargo :tail cargo :head Destination (bagid (dest destloc )) else NextLoader ((dest destloc )) Unload (valres bagid :integer res dest :Unloader destloc :integer ) = (NextLoader ((dest destloc )) cargo bagid := cargo bagid 0) SetType (val newtype :fLoader Unloader g) = (type := newtype )

)

]

j

The device has a loc attribute, which models the location of the device. However, it is not modi ed, because the stations are not supposed to move. Hence it is not speci ed as location in the sense of (4). Still, the position is important for the system, because it represents part of the destination for carts modeling the address of the station. The cargo attribute stands for the set of bags to be loaded into carts, for loaders, or for the bags which are taken from the carts, for unloaders. The methods Load and Unload are used respectively by the loader and unloader. The procedures NextLoader and Destination are used internally in these methods. There is no autonomous activity within a device. The cart is our mobile object and its corresponding class, hCart cart i, stands for the mobility class in our mobile system. Its location is changed by 10

the cart itself as it moves forward. Incrementing the location attribute value is treated modulo the length of the circular trajectory. Therefore the type of the loc attribute is an interval of integers 0 ::: length ; 1]. The constant length represents the length of the trajectory. When the cart is created, its location is 0. Then, the cart keeps moving stepwise. The chief makes the cart to move using the method SetCanMove of the cart. As a result, the cart will all the time be able to move as the canmove attribute remains true . Thus, upon reaching its destination it can either stop for service or continue moving, as at this point both actions are enabled. The cart carries a bag if the attribute bagid is not zero.
cart =
j

loc attr obj proc meth do od

loc : 0 ::: length ; 1] loc := 0 bagid destloc canmove := 0 InitDest ():snd F dest :Device dest := InitDest ():fst InitDest (res dest :Device integer ) SetCanMove (val can :boolean ) = (canmove := can ) canmove ! loc := move (loc + 1) ] at (destloc ) ^ bagid 6= 0 ! dest :Unload (bagid dest destloc ) ] at (destloc ) ^ bagid = 0 ! dest :Load (bagid dest destloc )

]

j

The cart needs to know both the identity dest and the location destloc of its destination. This is because, on one hand, when it reaches the destination, it makes a method call to the device, dest.Load or dest.Unload, in order to be served, and, on the other hand, it moves as long as it has not reached its destination. Initial values to these attributes are given by the procedure InitDest(...), which chooses an arbitrary loader in the system and assigns its identity to dest and its address to destloc. The services to be performed for the cart are speci ed in the device's methods Load and Unload. If the cart arrives at a loader station that has no bag to give to it, the station serves the cart by delivering a new destination. If the loader has bags to deliver, it modi es the bagid attribute of the cart, as well as its destination. If the cart arrives at an unloader station, this one takes over the bag from the cart and gives the cart a new destination. It is important to note the communication strategy between our objects. The cart cannot communicate with loaders and unloaders unless it is close to them, i.e., when the location guards at (destloc ) ^ bagid = 0 or at (destloc ) ^ bagid 6= 0 hold.

4 Coordinators
The mobile-oriented action systems described so far have a nondeterministic model of execution. This is the most general paradigm one can assume at 11

the speci cation level. The coordination pattern we are considering here is essentially that of restricting the nondeterminism in a regulated manner. We de ne special coordinator classes that specify this coordination without a ecting the functionality of other classes in a system. A typical OO-action system to be coordinated has some autonomous activity, namely the actions de ned in the class bodies. The coordination is taken care of by the coordinator classes via method calls to the objects in need of coordination. When considering an object-based system the problem is how to coordinate a dynamic set of objects. In mobile-oriented action systems we additionally need coordinators that operate only in certain limited areas of the entire domain. The underlying execution model for OO-action systems is very nondeterministic. The scheduling of certain actions for execution cannot hence be guaranteed. However, when specifying coordinators we want to enforce the execution of speci c coordinator actions. The notion of coordination was previously de ned in terms of prioritizing composition for action systems 20] where the coordinator having higher priority can interrupt the computation of the system it is coordinating. Here we de ne a similar simple yet powerful composition operator on actions, objects, and classes suitable for object-oriented systems.

4.1 Coordination and object-orientation

Coordination between actions Consider two actions A = a ! S and
B = b ! T . Their prioritizing composition A = B is de ned as = A = B = (a ! S ) ] (:a ^ b ! T ) = b

(6)

We say that the action A coordinates the action B . Essentially, action A has a higher priority than action B so that A is executed if it is enabled, while B is potentially executed only when A is not enabled. With the above de nition we have extended our language of actions:
A ::= : : : j A = A : =

on objects. In order for an object o1 to in uence another object o2 the former needs a reference to the latter via an object variable, say n . Then o1 can call the methods of o2 . Assume that some action A in o1 calls some method m = M of o2 . When A is executed, it will be executed jointly with the two involved objects as A becomes A o2 :M =n :m ] following the substitution principle. For o1 to have in uence on o2 and enforce the execution of A we want A to coordinate the actions in o2 . Hence, we have the following de nition: 12

Coordination between objects Let us lift coordination of actions to act

De nition 3 Let o1 o2

OName be two objects. We say that object o1 coordinates object o2 , denoted by o1 = o2 , if o1 has a reference to o2 via = some object variable and the actions in o1 coordinate the actions in o2 . We call o1 the coordinator object and o2 the coordinated object.
2

Hence, according to the above de nition, o1 = o2 implies that every action = in o1 coordinates every action in o2 whenever o1 has a reference to o2 .

Coordination between classes We now lift the above de nition for classes and consider a distributed object-based system as described in section 2. We give the following de nition: De nition 4 A class hc1 C1i coordinates another class hc2 C2 i, denoted by hc1 C1 i = hc2 C2 i, if every object instance of c1 is the coordinator for every = object instance of c2 . We call c1 the coordinator class and c2 the coordinated class. As OO-action systems is a class-based formalism, we use this de nition when specifying systems in practice. Hence, we associate priorities to classes of objects rather than to single objects. Let us analyse the de nition more closely. Let A be an action in some object instance o1 of c1 and B and C the actions of object instances o21 and o22 of c2 , respectively. Because these objects are part of an OO-action system, their underlying model of execution is A ] B ] C where the scheduling is nondeterministic. However, following De nition 4, it is interpreted as A = (B ] C ) giving a higher priority to the action generated by c1 than to = those generated by c2 . Hence, we have that o1 = o21 and o1 = o22 . Further, = = from De nition 3 we have that the object o1 coordinates the other objects if and only if o1 has a reference to either o21 and o22 . Assume that o1 has a reference to o21 but not to o22 , i.e., the action A calls a method in object o21 . Then, following De nition 3, the object o1 coordinates the object o21 only and for the actions A B and C we obtain the model of execution described by (A = B ) ] C . Based on this observation, we have the following lemma: = Lemma 1 Let hc1 C1 i = hc1 C2 i. Then an object instance of c1 is a coordi= nator for an object instance of c2 if the former has a reference to the object instance of c2 . Hence, the coordinator object needs to have a reference to the coordinated object. The idea behind our approach is to split the computation and coordination aspects of objects in such a way the the coordinated object never makes references to its coordinator (even though this is not enforced by the formalism). This implies that the coordinated object is not aware of the presence of the coordinator. Our model of coordination for OO-action systems incorporates a referenced object-approach. This means that when a class of objects coordinates
13

another class, the actions of the instances of the former act with priority over all the actions of all referenced instances of the latter class. The objects that are not referenced can execute their actions independently of those of either class. Informally, we could say that the coordinator acts only over those objects it `knows' about. Observe that this set of known objects for a speci c object can vary during the execution. Hence, we actually have modeled a system with dynamic priorities. Let us now turn back to mobility classes and consider how to coordinate mobile objects where the dynamic set of known objects is a reality and it is not meaningfull for a coordinator to `see everywhere'. Hence, a coordinator can only know objects within a certain neighbourhood. class which focuses the range of mobility. De nition 5 Let hmc MCi be a mobility class. Let R be the type of the location attribute in MC and let
R = R1 R2 ::: Rk be a partition for R. A coordinator class hcc the form
CC

4.2 Coordination in mobile environments

The coordinator class We start by stating a format for the coordinator

CCi

for hmc

MCi

is a class of

=

j

]

cell c :R attr x := x0 obj n := n0 meth SetR m1 = M1 mh = Mh proc p1 = P1 pk = Pk do A od

(7)

j

where c is a constant local attribute, that can be used in actions A and bodies of methods and procedures. The latter ones contain statements in the extended language (3). The class has exactly k instances, called coordinator objects the type of the cell attribute of the j :th object instance is Rj j 2 f1 ::: k g set by the method SetR (Rj ) at construction. The cell attribute is interpreted as a local constant describing the visibility domain for the coordinator. It has as its type the type of the location attribute in the mobility class it is coordinating. However, every coordinator object has an element of the partition as the type for the cell attribute as given by the implicit subtyping. When a coordinator object is created, the cell attribute is initialised to the respective element of the partition via a

14

call to the method SetR . We assume this attribute to be unchanged during the lifetime of the object. The list n contains references to the coordinated objects, and possibly other needed references. The fact that the number of object instances of the coordinator class is limited to k should be interpreted as a constraint applied to the class constructor: it can be called only k times after which it becomes disabled. Note that the coordinator class de ned by (7) is a class in the sense given by De nition (1), so we have integrated the concept of a coordinator within our framework.

Mobile-coordinated action systems (MoCAS) One should note that
every coordinator class is associated with a single mobility class. We have the following de nition:
of classes
MCO

De nition 6 A mobile-coordinated action system consists of a nite set
=
fhci Ci ii 2f1 ::: n g hmcj MC j ij 2f1 ::: m g hccj CC j ij 2f1 ::: s g g

where s m and where hccj CC j i = hmcj MC j i 8j 2 f1 ::: s g: hci Ci i is a = class in the sense of De nition (1), hmcj MC j i is a mobility class (4), and hccj CC j i is a coordinator class (7). Every coordinator class coordinates a certain mobility class denoted by the where-clause. We usually denote MCO by
fhci Ci ii 2f1 ::: n g hmci MC i ii 2fs +1 ::: m g g fhccj CC j i = hmcj MC j igj 2f1 ::: s g =

A MoCAS is a more deterministic OO-action system than those de ned by (2) and (5) in that of enforcing coordinator's actions to always execute with priority over the respective mobility class's actions. We want to stress the importance of Lemma 1 in the mobile-coordinated framework. One coordinator object will execute its actions with priority only over those mobile objects it has a reference to, which are the objects that are in its vicinity or visibility domain or cell. As the mobile objects are moving all the time, the set of referenced mobile objects will vary dynamically providing us with a natural and intuitive model.

The luggage distribution example Let us return to the example. Our system of luggage distribution, which now manages more than one cart, is described by the following MoCAS
fhChief

ch i hDevice dev ig

fhCoord

coord i = hCart cart ig: =

We have many carts, instances of class Cart , that are moving on the given circular trajectory. They need to be coordinated in order for them not 15

to cause collisions. Therefore a new class, the Coord class, is added to our system. Thus we have one mobility class, Cart and its corresponding coordinator class, Coord . The domain on which the carts are moving is given by the trajectory whose type is 0 length ; 1]. We split the trajectory into length div 10 segments, which stand for the cells, each segment having ten units. Therefore, the length of the trajectory, modeled by the integer constant length , is to be divisible by 10. Moreover, the segments are numbered from 1 to length div 10. Let us rst consider the coordinator Coord.

coord =

j

]

cell seg :integer attr status := T obj crt cart :Cart next :Coord meth SetSeg (val newseg :integer ) GetStatus (resl status :boolean ) SetStatus (val status :boolean ) SetCart (val newcart :Cart ) SetNext (val newcoord :Coord ) do od
:::

j

Its seg attribute models the segment a coordinator object it manages. When a coordinator object is created, the attribute seg is set to a number between 1 and length div 10 using the method SetSeg. The attribute status re ects the status of the segment, being true if there is no cart on the segment. Initially all segments are free. For accessing this attribute the methods GetStatus and SetStatus are available in the coordinator class. A coordinator object has two object variables: one to the current cart it supervises, if any, and the second to the coordinator object responsible for the next segment along the trajectory. The latter reference is needed in order for the hando to be performed when a cart leaves a segment and enters the next one. These object variables are modi ed by the methods SetCart and SetNext. Below we consider the other three classes in the system. The action of coord above is explained later. 16

ch =

j

]

attr cart need ld need uld need newcarts := T T T F obj cart :Cart ld uld :Device coord id :array 1 length div 10] of Coord coord id := Initially () proc SetNewCarts (val new :boolean ) = (newcarts := new ) Initially () = ( coord id i ] := new (Coord ) coord id i ] SetSeg (i )] for i 1 length div 10 coord id i ] SetNext (coord id i + 1])] for i 1 (length div 10) 1 coord id length div 10] SetNext (coord id 1]) do cart need ld need uld need : T F ] ld need ld := new (Device ) ld SetType (Loader ) ] uld need uld := new (Device ) uld SetType (Unloader ) ] cart need newcarts cart := new (Cart ) SetNewCarts (T ) ] newcarts coord id 1] GetStatus () (coord id 1] SetStatus (F ) coord id 1] SetCart (cart ) cart SetCanMove (T ) SetNewCarts (F )) od
:: : 2 f ::: g : 2 f ::: ; g : 2 f g ! : ! : ^ : ! ^ : ! : : :

j

The responsibilities of Chief are (1) to create loaders and unloaders in a nondeterministic fashion, (2) to create and initialise the coordinators, and (3) to create carts. The creation and initialisation of the coordinators is done using the procedure `Initially (:::)' in Chief: length div 10 objects of the class Coord are created corresponding to the length div 10 segments of the trajectory and then the coordinators are linked in a circular list. The object variables coord id 1] : : : coord id length div 10] are used as references to them. The for clause stands for the sequential repetition of the statement in square brakets, as many times as the predicate after for states. The creation of carts is conditioned by the need of carts in the system (cart need = T ) and by the availability of the chief to create a new cart (newcarts = F ). The latter attribute is modi ed by the procedure SetNewCarts . A reference to a newly created cart is communicated to the coordinator of the rst segment when its segment is free. Therefore, if the system needs carts and the chief is willing to create one, a new cart is generated. When the coordinator of the rst segment is free, the cart is given permission to move and the coordinator is set to having a cart on its segment. Observe that now the cart is allowed to move only after the coordinator takes over its supervision. The Device class is as before. The Cart class is also as before except 17

for a new method to be used by the coordinator: EnterNewSegment . By calling this method the coordinator checks whether the cart will leave its current segment:
EnterNewSegment (res enter :boolean ) = = (enter := ((loc + 1) mod 10 loc mod 10 ; 1))

Observe this small modi cation of the mobility class. Essentially the coordinator acts as a wrapper for the coordinated class, by adding to it only a service it will use. The coordination of the cart is speci ed by an action in Coord:
crt cart 6= null ^ crt cart :EnterNewSegment () ! if next :GetStatus then crt cart :SetCanMove (T ) next :SetStatus (F ) next :SetCart (crt cart ) self :SetStatus (T ) self :SetCart (null ) else crt cart :SetCanMove (F )

Thus, if the coordinator has a cart to supervise (crt cart 6= null ) and the cart is ready to enter a new segment, the coordinator checks the status of its next neighbour. Only if the next coordinator is free (next :GetStatus ), the cart is allowed to continue its movement, otherwise it has to wait. At the hando moment the next coordinator gets hold of a reference to the entering object and becomes occupied with the cart coming from its predecessor, while the previous coordinator becomes free. Hence, the coordinator knows about at most one mobile object at a time. Observe that the above action is a joint action by three objects, two coordinator objects and a mobile object. As the action has a higher priority than the actions of the mobile object, the movement can be controlled without delay, via a call to SetCanMove . Hence, if simultaneously both this action and the movement action in the cart are enabled, the former will be selected and, as a consequence, the latter might become disabled. The cart can still miss its destination though. This small example gives an intuitive reason for justifying the need of coordination in mobile systems. The basic computation of a mobile object is speci ed independently of the aspects related to the environment of mobility. No matter where they are, the mobile objects should perform correctly their operations, like loading/unloading/moving for our example, or communicating with other mobile objects etc. For this reason we need a certain infrastructure that `knows' about the domain of moving and can assist the mobile objects. This infrastructure is represented by the coordinators. 18

5 Concluding remarks
In this paper we have de ned the concepts needed to model coordination and mobility within the object-based OO-action systems formalism. Coordination can be data-driven like in Linda 13] or control-driven like in Manifold 3]. Action systems support both views to coordination 20]. We focused on control-driven coordination here, but the ideas carry over to datadriven coordination, too. Our approach to mobility is very abstract leaving space for designer to specialise the concepts to many di erent environments. We exempli ed the de ned concepts with a small yet nontrivial example also speci ed in MobileUNITY 26] as well as in COMMUNITY 27], neither of which supports object-orientation. In the former approach a centralised set of coordination rules is given in an interactions section that all participants of the system must obey. In our approach the coordination is decentralised among sets of coordinators supporting the idea of distribution. Category theory based COMMUNITY uses morphisms to model coordination. Sets of actions from interacting entities are put in a speci c relation, corresponding to the type of interaction between entities: inhibition, synchronisation and communication. All these interaction types are possible in our approach, too. The inhibition and synchronisation are modeled by the coordination while the communication is done via method calls. Finally, we want to stress the fact that in this paper we de ned the concepts needed to specify mobile object-oriented systems. The approach comes with a formal framework, the re nement calculus that was not discusses here, to formally derive systems from their high level abstract speci cations to detailed implementations. Hence, decentralised coordination can be formally derived from centralised coordination, mobile objects can be derived from objects without having this property, the communication structure can be further re ned to include e.g. broadcasting, and so on. The correctness argumentation of the derivations is carried out within the re nement calculus framework. Moreover, as our approach is object-oriented we can reuse our classes in a convenient manner, a feature also supported by the re nement calculus. The details of these concepts within mobile-coordinated action systems are left for future research.

Acknowledgement The work of the second author is supported by the
Academy of Finland.

References
1] G. Agha. Actors: A Model of Concurrent Computation in Distributed Systems. MIT Press, Los Alamos, California, 1986. 19

2] P. America, J. W. de Bakker, J.N. Kok, and J.J.M.M. Rutten. Operational semantics of a parallel object-oriented language. In Proc. 13th ACM Symposium on Principles of Programming Languages, pages 194{208, 1986. 3] F. Arbab. The IWIM Model for coordination of concurrent activities. In 16]. 4] R.J.R. Back, M. Buchi, and E. Sekerinski. Action-based concurrence and synchronization for objects. In Proc. 4th AMAST Workshop on Real-Time Systems, Concurrent, and Distributed Software, SpringerVerlag, 1997. 5] R. J. R. Back and R. Kurki-Suonio. Decentralization of process nets with centralized control. In Proc. of the 2nd ACM SIGACT{SIGOPS Symp. on Principles of Distributed Computing, pages 131{142, 1983. 6] R. J. R. Back and K. Sere. Stepwise re nement of action systems. Structured Programming, 12:17-30, 1991. 7] R. J. R. Back and J. v. Wright. Re nement Calculus: A Systematic Introduction. Graduate Texts in Computer Science, Springer-Verlag (1998). 8] J.-P. Ban^tre and D. Le Metayer. Programming by multiset transfora mation. Communications of the ACM, 36(1):98{111, January 1993. 9] M. M. Bonsangue, J. N. Kok, and K. Sere. An approach to objectorientation in action systems. In Mathematics of Program Construction (MPC'98), Marstrand, Sweden, June 1998. Lecture Notes in Computer Science 1422, Springer{Verlag. 10] M. M. Bonsangue, J. N. Kok, and K. Sere. Developing Object-based Distributed Systems. In Proceedings of IFIP TC6/WG6 Third International Conference on Formal Methods for Open Object-Based Distributed Systems (FMOODS'99), Florence, Italy, February 1999. To appear. 11] L. Cardelli. A language with distributed scope. Computing Systems 8(1):27{29, 1995. 12] L. Cardelli and A. D. Gordon. Mobile Ambients. In Maurice Nivat (Ed.) Foundations of Software Science and Computational Structures , volume 1378 of Lecture Notes in Computer Science, 140-155. Springer{Verlag, 1998. 13] N. Carriero and D. Gelernter. Coordination languages and their signi cance. Communications of the ACM, 35(2):97{107, February 1992. 20

14] K. Chandy and J. Misra. Parallel Program Design: A Foundation. Addison{Wesley, 1988. 15] M. Chaudron and E. de Jong. Towards a Compositional Method for Coordinating Gamma Programs. In 16]. 16] P. Ciancarini and C. Hankin, editors. Coordination'96: Coordination Languages and Models, volume 1061 of Lecture Notes in Computer Science. Springer{Verlag, 1996. 17] E. W. Dijkstra. A Discipline of Programming. Prentice{Hall International, 1976. 18] R. De Nicola, G. L. Ferrari, and R. Pugliese. Coordinating Mobile Agents via Blackboards and Access Rights. In 19]. 19] D. Garlan and D. Le Metayer, editors. Coordination'97: Coordination Languages and Models, volume 1282 of Lecture Notes in Computer Science. Springer{Verlag, 1997. 20] E. Hedman, J. N. Kok, and K. Sere. Coordinating Action Systems. In 19]. 21] C. Hewitt. Viewing control structures as patterns of passing messages. Arti cial Intelligence 8(3), 1997. 22] H.-H. Jarvinen and R. Kurki-Suonio. DisCo speci cation language: marriage of actions and objects. In Proc. of the 11th International Conference on Distributed Computing Systems, IEEE Computer Society Press, pages 142-151, 1991. 23] P. J. McCann and G.-C. Roman. Compositional programming abstractions for mobile computing. IEEE Transactions on Software Engineering 24, 2(February 1998), pages 97{110. 24] R. Milner, J. Parrow, and D.J. Walker. A calculus of mobile processes. Information and Computation 100 1, pages 1{40, 1992. 25] S. Ren and G. Agha. A Modular Approach for Programming Distributed Real-Time Systems. In Hand-Out, European Educational Forum, School on Embedded Systems, November 1996, Veldhoven, NL. 26] G.-C. Roman and P. J. McCann and J. Y. Plun. Mobile UNITY: Reasoning and Speci cation in Mobile Computing. ACM TOSEM, VOL. 6, no. 3, pages 250-282, July 1997. 27] M. Wermelinger and J. L. Fiadeiro. Connectors for Mobile Programs. IEEE Transactions on Software Engineering, VOL. 24, No 5, pp. 331341, May 1998. 21

Turku Centre for Computer Science Lemminkaisenkatu 14 FIN-20520 Turku Finland
http://www.tucs.abo.

University of Turku Department of Mathematical Sciences

Abo Akademi University Department of Computer Science Institute for Advanced Management Systems Research

Turku School of Economics and Business Administration Institute of Information Systems Science


赞助商链接

更多相关文章:
更多相关标签:

All rights reserved Powered by 甜梦文库 9512.net

copyright ©right 2010-2021。
甜梦文库内容来自网络,如有侵犯请联系客服。zhit325@126.com|网站地图