• Keine Ergebnisse gefunden

System Initialisation

Im Dokument Formal Semantics for SDL (Seite 140-143)

Part 4: RSDL Formal Definition

4.6 RSDL Abstract Machine Programs

4.6.3 System Initialisation

Starting from S0, the initialisation rules describe a recursive unfolding of the specified system instance according to its hierarchical structure. Each initialisation step may create several object instances simultaneously.

During the initialisation phase, agents may operate in two different operation modes as stated by a static domain MODE,

MODE =def {initial, starting }

where a dynamic function mode defined on agents indicates the mode of an agent in a given abstract machine state.

controlled mode: AGENT → MODE

Furthermore, two derived function ingates and outgates are introduced that collect all input gates and all output gates of an agent. This is achieved using the link of the gates to their owning agent. This function is only defined for the RSDL agent sets, the RSDL agents use the gates of their agent sets.

ingates(a: AGENT): GATE-set =def

if a.ref ≠ undefined then { g ∈ GATE: g.myAgent = a ∧ g.direction = inDir } else Self.owner.ingates endif

outgates(a: AGENT): GATE-set =def

if a.ref ≠ undefined then { g ∈ GATE: g.myAgent = a ∧ g.direction = outDir } else Self.owner.outgates endif

A unary function ref defined on agents identifies for each agent an abstract syntax tree (sub-) definition to be processed during the initialisation phase. A similar reference to then definition is introduced for gates (gateRef).

A derived function myType refers to the type definition of the agent set.

controlled ref: AGENT → DefinitionAS1 controlled gateRef: GATE → DefinitionAS1 myType(a: AGENT): DefinitionAS1 =def

if a.ref ≠ undefined then a.ref.s-Agent-type-identifier.refersto1 else undefined endif

4.6.3.1 Agent Set Initialisation

The initialisation of agent sets (and hence also of systems) is defined by the macro below, where Self initially denotes the distinguished system agent system.

The rule below is performed once, afterwards the agent is not active any more, because its program is undefined.

However, the mode is set to starting because the internal agents have been created.

INIT-AGENT-SET-PROGRAM:

CREATEGATES(Self, Self.myType.s-Gate-definition-set)

do forall i: i ∈ 1 .. Self.ref.s-Number-of-instances.s-Initial-number CREATEAGENT(Self, nullAgent)

enddo

Self.program := undefined Self.mode := starting

4.6.3.2 Agent Creation

For the creation of an agent, the owner agent set has to be known as well as the creating parent. The predefined RSDL system variables are initialised to be “null” and an input port (a gate) for the agent is created. For agents also the same handling with the mode is used.

CREATEAGENT(Owner: AGENT, Parent: AGENT) ≡ extend AGENT with a

if Parent ≠ nullAgent then Parent.offspring := a endif a.owner := Owner

a.parent := Parent a.sender := nullAgent a.offspring := nullAgent extend GATE with g

g.schedule := empty a.inport := g endextend a.mode := initial

a.program := INIT-AGENT-PROGRAM

4.6.3.3 Agent Initialisation

In order to prevent the initialisation rule from being performed more than once, the mode-function is used. This function ensures in this case, that the rule below is executed exactly twice, namely once with the value of Self.mode = initial and the second time with Self.mode = starting. Within the second execution of the rule all sub agent sets are checked to be out of the initial mode. This is necessary for all gates to be created when the channels are created.

INIT-AGENT-PROGRAM: if Self.mode = initial then

// Execute this subrule only once Self.mode := starting

Self.label := Self.owner.myType.startLabel

Self.state:= initAgentState(Self.owner.myType.s-Variable-definition-set) do forall sas: sas ∈ Self.owner.myType.s-Agent-definition-set

CREATEAGENTSET (Self, sas)

else if initial ∉ { a.mode | a ∈ AGENT: a.owner = Self } then CREATECHANNELS(Self.owner.myType.s-Channel-definition-set) // switch to execution program

Self.program := EXECUTION-PROGRAM do forall g: g ∈ Self.owner.ingates

CREATELINK(g, Self.inport, undefined) enddo

endif

4.6.3.4 Agent Set Creation

The creation of an agent set is done like the creation of the initial system agent set.

CREATEAGENTSET(Owner: AGENT, AgentDefinition: DefinitionAS1) ≡ extend AGENT with sas

sas.ref := AgentDefinition sas.mode := initial sas.owner := Owner

sas.program := INIT-AGENT-SET-PROGRAM

4.6.3.5 Channel and Link Creation

Channels are modelled through unidirectional channel paths. Each channel path is represented by an agent of type LINK. Creation of channels is given by the creation of their channel paths.

CREATECHANNELS(ChannelDefSet: Channel-definition-set) ≡ do forall item: item ∈ ChannelDefSet

do forall path: path ∈ item.s-Channel-path-set CREATECHANNELPATH(path)

The creation of a channel path means to create a new LINK agent. the problem is to correctly set the input and the output gates. The detection of the correct gate is done by the properties of the gate. If all runs correctly, the choose runs over a set with exactly one element.

CREATECHANNELPATH(Path: Channel-path) ≡

choose gIn: gIn ∈ GATE ∧ gIn.gateRef = Path.s-Originating-gate ∧ ( OwnGate(gIn, inDir) ∨ EnclosedGate(gIn, outDir) )

choose gOut: gOut ∈ GATE ∧ gOut.gateRef = Path.s-Destination-gate ∧ ( OwnGate(gOut, outDir) ∨ EnclosedGate(gOut, inDir) )

CREATELINK(gIn, gOut, Path) where

OwnGate(g: GATE, dir: DIRECTION): BOOLEAN =def g.myAgent = Self.owner ∧ g.direction = dir EnclosedGate(g: GATE, dir: DIRECTION): BOOLEAN =def g.myAgent.owner = Self ∧ g.direction = dir endwhere

The creation of a link is given by creating a new LINK agent with the LINK-PROGRAM, the corresponding gates and the signal list for the function with. There are two places where links are created: for channel paths and for the connection of an agent to the gate of its parent.

CREATELINK(fromGate: GATE, toGate: GATE, path: CHANNEL) ≡ extend AGENT with l

l.program := LINK-PROGRAM l.from := fromGate

l.to := toGate l.channel := path

4.6.3.6 Gate Creation

The creation of a gate is split in two parts, namely creation of a gate for each of the two directions, if present.

CREATEGATES(Owner: AGENT, GateDefSet: Gate-definition-set) ≡ do forall item: item ∈ GateDefSet

if item.s-In-signal-identifier-set ≠ ∅ then extend GATE with g

g.myAgent:= Owner g.gateRef:= item g.direction:= inDir endif

if item.s-Out-signal-identifier-set ≠ ∅ then extend GATE with g

g.myAgent:= Owner g.gateRef:= item g.direction:= outDir endif

enddo

Im Dokument Formal Semantics for SDL (Seite 140-143)