• Keine Ergebnisse gefunden

Behaviour Primitives

Im Dokument Formal Semantics for SDL (Seite 130-135)

Part 4: RSDL Formal Definition

4.5 Special Abstract Machine Definition

4.5.4 Behaviour Primitives

In this section we present the behaviour primitives of the SAM using the macros defined in the previous section as a basis.

We define the domain ACTION for single steps as follows.

ACTION =def ANYORDER ∪ TASK ∪ OUTPUT ∪ CREATE ∪ SET ∪ RESET

∪ SKIP ∪ STOP ∪ DECISION ∪ VAR ∪ FUNCALL ∪ SYSTEMVALUE ∪ TIMERACTIVE

∪ CHECKINPUT ∪ CHECKCONTINUOUS

A static domain VALUELABEL represents labels in LABEL at which an RSDL agent can write or read a value. These values can be accessed by a dynamic, controlled function currentValue.

VALUELABEL =def LABEL CONTINUELABEL =def LABEL

controlled currentValue: VALUELABEL × AGENT → VALUE

The meaning of the evaluation of an action is defined with the macro EVAL. Note that the subdomains of ACTION are pairwise disjoint.

EVAL(a: ACTION) ≡

if a ∈ ANYORDER then EVALANYORDER(a) endif if a ∈ TASK then EVALTASK(a) endif

if a ∈ OUTPUT then EVALOUTPUT(a) endif if a ∈ CREATE then EVALCREATE(a) endif if a ∈ SET then EVALSET(a) endif if a ∈ RESET then EVALRESET(a) endif if a ∈ SKIP then EVALSKIP(a) endif if a ∈ STOP then EVALSTOP(a) endif

if a ∈ DECISION then EVALDECISION(a) endif if a ∈ VAR then EVALVAR(a) endif

if a ∈ FUNCALL then EVALFUNCALL(a) endif

if a ∈ SYSTEMVALUE then EVALSYSTEMVALUE(a) endif if a ∈ TIMERACTIVE then EVALTIMERACTIVE(a) endif if a ∈ CHECKINPUT then EVALINPUT(a) endif

if a ∈ CHECKCONTINUOUS then EVALCONTINUOUS(a) endif

4.5.4.1 Evaluation in Any Order

Explanation

The any order primitive is used for expressing that some steps can be performed in any order.

Representation

ANYORDER =def LABEL-set × CONTINUELABEL controlled stillToVisit: AGENT → LABEL-set

Behaviour

The function stillToVisit keeps track of all labels that have not been visited. After having visited all labels, this function is reset to undefined for a next call of ANYORDER. If there are still labels to be visited, one of those is chosen and becomes the next label.

EVALANYORDER(a: ANYORDER) ≡

if Self.stillToVisit = undefined then Self.stillToVisit:= a.s-LABEL-set elseif Self.stillToVisit = ∅ then

Self.label:= a.s-CONTINUELABEL Self.stillToVisit:= undefined else

choose l: l ∈ Self.stillToVisit Self.label:= l

Self.stillToVisit:= Self.stillToVisit \ { l }

4.5.4.2 Task

Explanation

The task primitive is used for expressing an assignment.

Representation

TASK =def VARIABLENAME × VALUELABEL × CONTINUELABEL Behaviour

EVALTASK(task: TASK) ≡

ASSIGN(task.s-VARIABLENAME, currentValue(task.s-VALUELABEL, Self), Self) Self.label:= task.s-CONTINUELABEL

4.5.4.3 Output

Explanation

The output primitive is used for expressing a signal output.

Representation

OUTPUT =def SIGNAL × VALUELABEL* × TOARGLABEL × CONTINUELABEL TOARGLABEL =def LABEL

Behaviour

EVALOUTPUT(o: OUTPUT) ≡

SIGNALOUTPUT(o.s-SIGNAL, < currentValue(v, Self) | v in o.s-VALUELABEL-seq >, value2agent(currentValue(o.s-TOARGLABEL, Self)) )

Self.label:= o.s-CONTINUELABEL Reference Sections

See also Section 4.5.3.3.

4.5.4.4 Create

Explanation

The create primitive is used for expressing dynamic creation of agent instances at system run time.

Note: There must be a lock that no two instances can be created at the same time (not shown here).

Representation

CREATE =def CREATEAGENTDEF × CONTINUELABEL CREATEAGENTDEF =def Agent-definition

Behaviour

EVALCREATE(c: CREATE) ≡

NEWAGENTINSTANCE(c.s-CREATEAGENTDEF) Self.label:= c.s-CONTINUELABEL

NEWAGENTINSTANCE(agentDesc: Agent-definition) ≡ choose a: a ∈ AGENT ∧ a.ref = agentDesc

let n = |{ inst ∈ AGENT: inst.owner = a }| in

if n < agentDesc.s-Number-of-instances.s-Maximum-number then a.offspring := Self // to avoid multiple creation in the same set CREATEAGENT(a, Self)

else Self.offspring:= nullAgent Reference Sections

See also Section 4.6.3.2.

4.5.4.5 Set

Explanation

The set primitive is used for expressing a timer set.

Representation

SET =def TIMELABEL × TIMERNAME × CONTINUELABEL TIMELABEL =def VALUELABEL

TIMERNAME =def TIMER Behaviour

EVALSET(s: SET) ≡

SETTIMER(s.s-TIMERNAME, value2time(currentValue(s.s-TIMELABEL, Self))) Self.label:= s.s-CONTINUELABEL

Reference Sections See also Section 4.5.1.5.

4.5.4.6 Reset

Explanation

The reset primitive is used for expressing a timer reset.

Representation

RESET =def TIMERNAME × CONTINUELABEL Behaviour

EVALRESET(r: RESET) ≡

RESETTIMER(r.s-TIMERNAME) Self.label:= r.s-CONTINUELABEL Reference Sections

See also Section 4.5.1.5.

4.5.4.7 Skip

Explanation

The skip primitive is basically a no-op. It is used for instance to model joins.

Representation SKIP =def LABEL Behaviour

EVALSKIP(s: SKIP) ≡ Self.label:= s.s-LABEL

4.5.4.8 Stop

Explanation

The stop primitive is used for expressing the stop action.

Representation STOP =defstop Behaviour

EVALSTOP(s: STOP) ≡

Self.program:= undefined

4.5.4.9 Decision

Explanation

The decision primitive is used for expressing a control flow branching. If none of the alternatives applies, then the further behaviour is undefined.

Representation

DECISION =def VALUELABEL × ANSWER-set ANSWER =def ANSWERVALUE × ANSWERCONTINUE ANSWERVALUE =def LABEL

ANSWERCONTINUE =def LABEL Behaviour

EVALDECISION(d: DECISION) ≡

let dval = currentValue(d.s-VALUELABEL, Self) in

let avalues = { currentValue(a.s-ANSWERVALUE, Self) | a ∈ d.s-ANSWER-set } in if dval ∈ avalues then

choose a: a ∈ d.s-ANSWER-set ∧ currentValue(a.s-ANSWERVALUE, Self) = dval Self.label:= a.s-ANSWERCONTINUE

elseif undefined ∈ { a.s-ANSWERVALUE | a ∈ d.s-ANSWER-set } then choose a: a ∈ d.s-ANSWER-set ∧ a.s-ANSWERVALUE = undefined

Self.label:= a.s-ANSWERCONTINUE else UNDEFINEDBEHAVIOUR

4.5.4.10 Evaluation of Variables

Explanation

The VAR primitive is used for expressing the evaluation of a variable.

Representation

VAR =def VARIABLENAME × CONTINUELABEL Behaviour

The value of variableName in the state of the executing agent is determined by the function eval and stored at the current label for Self.

EVALVAR(var: VAR) ≡

currentValue(Self.label, Self) := eval(var.s-VARIABLENAME, Self.state) Self.label := var.s-CONTINUELABEL

4.5.4.11 Evaluation of System Values

Explanation

The system value primitive is used to compute the predefined values of RSDL agents.

Representation

SYSTEMVALUE =def VALUEKIND × CONTINUELABEL

VALUEKIND =def { nowKind, selfKind, parentKind, offspringKind, senderKind } Behaviour

EVALSYSTEMVALUE(sv: SYSTEMVALUE) ≡ let k = sv.s-VALUEKIND in

if k = nowKind then

currentValue(Self.label, Self):= selector-RSDLTIME(now) elseif k = selfKind then

currentValue(Self.label, Self):= agent2value(Self) elseif k = parentKind then

currentValue(Self.label, Self):= agent2value(Self.parent) elseif k = offspringKind then

currentValue(Self.label, Self):= agent2value(Self.offspring) elseif k = senderKind then

currentValue(Self.label, Self):= agent2value(Self.sender) endif

endlet

Self.label:= sv.s-CONTINUELABEL

4.5.4.12 Evaluation of Predefined Functions and Literals

Explanation

The function call primitive is used for evaluating predefined functions and literals.

Representation

FUNCALL =def FUNCTIONNAME × VALUELABEL* × CONTINUELABEL FUNCTIONNAME =def Name

Behaviour

EVALFUNCALL(f: FUNCALL) ≡

currentValue(Self.label, Self) :=

compute(f.s-FUNCTIONNAME, < currentValue(l, Self) | l in f.s-VALUELABEL-seq > ) Self.label := f.s-CONTINUELABEL

Reference Sections See also Section 4.4.4.

4.5.4.13 Evaluation of Timer Active Expressions

Explanation

The timer active primitive is used for expressing the evaluation of timer active expressions.

Representation

TIMERACTIVE =def TIMER × CONTINUELABEL Behaviour

EVALTIMERACTIVE(t: TIMERACTIVE) ≡

currentValue(Self.label, Self) := bool2value(Active(mk-TIMERINST(Self, t.s-TIMERNAME))) Self.label := t.s-CONTINUELABEL

Reference Sections See also Section 4.5.1.5.

4.5.4.14 Input Primitives

Explanation

The input primitives are used to model the behaviour of RSDL agents being in a state, i.e. waiting for signals to arrive or for conditions to become true.

Representation

CHECKINPUT =def INPUTDESC-set × SAVESIGNAL-set × CONTINUELABEL SAVESIGNAL =def SIGNAL

CHECKCONTINUOUS =def CONTINUOUSSIGNAL-set × CONTINUELABEL Behaviour

EVALINPUT(i: CHECKINPUT) ≡

CHECKINPUTSIGNAL(i.s-INPUTDESC-set, i.s-SAVESIGNAL-set, i.s-CONTINUELABEL) EVALCONTINUOUS(c: CHECKCONTINUOUS) ≡

DOCONTINUOUS(c.s-CONTINUOUSSIGNAL-set, c.s-CONTINUELABEL) Reference Sections

See also Section 4.5.3.1 and Section 4.5.3.2.

Im Dokument Formal Semantics for SDL (Seite 130-135)