l
|
The DisCo Home Page |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Example: Distributed Exchange SortObjects of the class Process have an integer
attribute i. The relation adjacent arranges
the objects as a chain. The goal is to sort the
i-attributes of the objects into a non-descending order
by executing the action exchange repeatedly as long as
two objects (a and b) can be chosen so that
the guard expression (the line beginning with
when) evaluates to true. The || separator
denotes parallel assignment.
layer Distributed_sort is
class Process is
i: integer;
end Process;
relation adjacent (Process : Process) is 0..1 : 0..1;
action exchange(a:Process; b:Process) is
when adjacent(a, b) and a.i > b.i do
a.i := b.i || b.i := a.i;
end exchange;
end Distributed_sort;
Timo Aaltonen (tta@cs.tut.fi) Give feedback. |