Difference between pages "Rodin Workshop 2010" and "Tasking Event-B Overview"

From Event-B
(Difference between pages)
Jump to navigationJump to search
imported>Stefan
 
imported>Andy
 
Line 1: Line 1:
= Rodin User and Developer Workshop, University of Duesseldorf, 20-22 September 2010 =
+
=== Tasking Event-B ===
 +
Tasking Event-B can be viewed as an extension of the existing Event-B language. We use the existing approaches of refinement and decomposition to structure a project that is suitable for a Tasking Development. During the modelling phase parameters are introduced to facilitate decomposition. As a result of the decomposition process, parameters become part of the interface that enables event synchronization. We make use of this interface and add information (see [[#Implementing Events]]) to facilitate code generation. The tasking extension consists of the constructs in the following table.
  
 +
<center>
 +
{| border="1"
 +
!Construct
 +
!Options
 +
|-
 +
|Machine Type
 +
|DeclaredTask, [http://wiki.event-b.org/index.php/Tasking_Event-B_Overview#Tasking_Machines AutoTask], [http://wiki.event-b.org/index.php/Tasking_Event-B_Overview#Shared_Machines SharedMachine], [http://wiki.event-b.org/index.php/Tasking_Event-B_Overview#The_Environ_Machine Environ]
 +
|-
 +
|[http://wiki.event-b.org/index.php/Tasking_Event-B_Overview#Control_Constructs Control]
 +
|Sequence, Loop, Branch, Event, Output
 +
|-
 +
|[http://wiki.event-b.org/index.php/Tasking_Event-B_Overview#Tasking_Machines Task Type]
 +
|Periodic(n), Triggered, Repeating, OneShot
 +
|-
 +
|Priority
 +
| -
 +
|-
 +
|[http://wiki.event-b.org/index.php/Tasking_Event-B_Overview#Implementing_Events Event Role]
 +
| Actuating, Sensing
 +
|-
 +
|[http://wiki.event-b.org/index.php/Tasking_Event-B_Overview#Addressed_Variables Addressed Variable]
 +
|Address, Base
 +
|}
 +
</center>
  
 +
==== Tasking Machines ====
 +
The following constructs relate to Tasking and Environ Machines, and provide implementation details. Timing of periodic tasks is not modelled formally. Tasking and Environ Machines model Ada tasks, so they can be implemented easily in Ada; in C using the pthread library, or in Java using threads.
  
==Monday 20th September (Tutorial) ==
+
* Tasking Machines may be one of the following types:
Tutorial "How to extend Rodin?" for developers (by Systerel).
+
** AutoTasks - Anonymous Tasks running from start-up.
 +
** Declared tasks - (Not currently used) A task template relating to an Ada ''tasktype'' declaration.  
  
The tutorial will be interactive, so please bring your laptop and keep your development environment up-to-date (Eclipse 3.6, Java 1.6, current Rodin source files).
+
''Auto Tasks'' are tasks that will be declared and defined in the ''Main'' procedure of the implementation. The effect of this is that the ''Auto Tasks'' are created when the program first loads, and then activated (made ready to run) before the ''Main'' procedure body runs.
  
*09h00 - 10h30
+
* Tasking and Environ Machines options are:
:Creating a plug-in
+
** TaskType - Defines the scheduling, cycle and lifetime of a task. i.e. one-shot periodic or triggered. The period of a task is specified in milliseconds.
:Extending the database
+
** Priority - An integer value is supplied, the task with the highest value priority takes precedence when being scheduled. The default priority is 5.
:Extending the structured editor
 
*10h30 - 11h00
 
:Coffee break
 
*11h00 - 12h30
 
:Extending the pretty print page
 
:Providing help
 
:Extending the Event-B explorer
 
*12h30 - 14h00
 
:Lunch break
 
*14h00 - 15h30
 
:Extending the static checker
 
:Extending the proof obligation generator
 
*15h30 - 16h00
 
:Coffee break
 
*16h00 - 17h00
 
:Adding reasoners
 
  
==Tuesday 21st September (Workshop Day 1)==
+
==== Shared Machines ====
* 09h00 - 10h30 [http://wiki.event-b.org/images/Rodin2010-sld-salehi_butler.pdf ''Atomicity Decomposition a Technique for Structuring Refinement in Event-B''], Asieh Salehi Fathabadi, Michael Butler
+
A Shared Machine models a protected resource, such as a monitor. It may be implemented in Ada as a Protected Object, in C using mutex locking, or in Java as a monitor.
* 09h30 - 10h00 [http://wiki.event-b.org/images/Rodin2010-sld-milhau.pdf ''Integrating astd in the Rodin platform''], Paul Amar, Marc Frappier, Cecile Lartaud, and Jeremy Milhau
 
* 10h00 - 10h30 [http://wiki.event-b.org/images/Rodin2010-sld-russo_etal.pdf ''Potpourri of what? One year in a DA's life''], Aryldo G. Russo Jr., Thiago C. de Sousa, Haniel Barbosa, Paulo Muniz, and David Deharbe
 
* 10h30 - 11h00 Coffee break
 
* 11h00 - 11h30 [http://wiki.event-b.org/images/Rodin2010-sld-jastram.pdf ''The ProR Requirements Engineering Platform''], Michael Jastram
 
* 11h30 - 12h00 [http://wiki.event-b.org/images/Rodin2010-sld-nakajima.pdf ''A Refinement Planning Sheet''], Shin Nakajima
 
* 12h00 - 12h30 [http://wiki.event-b.org/images/Rodin2010-sld-llano_etal_1.pdf ''Refinement Plans for Reasoned Modelling''], Maria Teresa Llano, Andrew Ireland, and Gudmund Grov
 
* 12h30 - 14h00 Lunch break and tool demos
 
* 14h00 - 15h00 [http://wiki.event-b.org/images/Rodin2010-sld-abrial.pdf ''Invited Talk: Specification of the Automatic Prover P3''], Jean-Raymond Abrial
 
* 15h00 - 15h30 ''Reflections on the teaching of System Modelling and Design'', Ken Robinson
 
* 15h30 - 16h00 Coffee break
 
* 16h00 - 16h30 [http://wiki.event-b.org/images/Rodin2010-sld-ulbrich.pdf ''Verification of a Byzantine Agreement Protocol using Event-B''], Roman Krenicky and Mattias Ulbrich
 
* 16h30 - 17h00 [http://wiki.event-b.org/images/Rodin2010-sld-edmunds_butler.pdf ''Code Generation with the Event-B Tasking Extension (Tool Development)''], Andy Edmunds
 
* 17h00 - 17h30 [http://wiki.event-b.org/images/Rodin2010-sld-hallerstede.pdf ''Modelling Recursion in Event-B''], Stefan Hallerstede
 
  
==Wednesday 22nd September (Workshop Day 2)==
+
* A Shared Machine is identified using the ''Shared Machine'' annotation.
* 09h00 - 09h30 [http://wiki.event-b.org/images/Rodin2010-sld-llano_etal_2.pdf ''Using automated theory formation to discover invariants of Event-B models''], Maria Teresa Llano, Andrew Ireland, Alison Pease, Simon Colton, John Charnley
 
* 09h30 - 10h00 ''Specifying and Solving Constraint Satisfaction Problems in B'', Michael Leuschel and Daniel Plagge
 
* 10h00 - 10h30 [http://wiki.event-b.org/images/Rodin2010-sld-lopatkin_etal.pdf ''Fault Tolerance View in Event-B Development''], Ilya Lopatkin, Alexei Iliasov, Alexander Romanovsky
 
* 10h30 - 11h00 Coffee break
 
* 11h00 - 11h30 [http://wiki.event-b.org/images/Rodin2010-sld-turcanu.pdf ''Event-B models of P systems''], Florentin Ipate, Adrian Turcanu
 
* 11h30 - 11h45 [http://wiki.event-b.org/images/Rodin2010-sld-savicks_etal.pdf ''Records''], Vitaly Savicks, Colin Snook, Michael Butler
 
* 11h45 - 12h00 [http://wiki.event-b.org/images/Rodin2010-sld-silva.pdf ''Decomposition Tool: Development and Usage''], Renato Silva, Carine Pascal, T.S. Hoang, and Michael Butler
 
* 12h00 - 12h30 [http://wiki.event-b.org/images/Rodin2010-sld-iliasov.pdf ''Modularisation/Group Refinement/Views''], Alexei Iliasov
 
* 12h30 - 14h00 Lunch break and tool demos
 
* 14h00 - 15h00 ''Invited Talk: Ensuring Consistency between Classifiers and Classes'', Joe Kiniry
 
* 15h00 - 15h30 [http://wiki.event-b.org/images/Rodin2010-sld-grov_etal.pdf ''A small experiment in Event-B rippling''], Gudmund Grov, Alan Bundy & Lucas Dixon
 
* 15h30 - 16h00 Coffee break
 
* 16h00 - 16h30 [http://wiki.event-b.org/images/Dusseldorf_SM_Animation.pdf'' Animation of UML-B State-machines''], Vitaly Savicks, Colin Snook, Michael Butler
 
* 16h30 - 17h00 [http://wiki.event-b.org/images/Rodin2010-sld-maamria.pdf ''Addressing Extensibility Issues in Rodin and Event-B''], Issam Maamria and Michael Butler
 
* 17h00 - 17h15 [http://wiki.event-b.org/images/Rodin2010-sld-wright.pdf ''Modelling of the XCore Microprocessor with Rodin''], Steve Wright
 
  
=Registration=
+
==== The Environ Machine ====
[http://www.formal-methods.de/avocs10/registration.html Registration page]
+
An Environ machine is a model of the environment. It can be used to generate code for use in a simulation, or be discarded in the case that a simulated environment is not required.
 +
 
 +
* An Environ Machine is identified using the ''Environ Machine'' annotation.
 +
 
 +
=== Control of Program Flow ===
 +
At the implementation stage we need to think about controlling the flow of execution; and where interaction with the environment is concerned, how events should be implemented. The following section describes the constructs that we have introduced to facilitate this.
 +
==== Control Constructs ====
 +
Each Tasking Machine has a ''task body'' which contains the flow control (algorithmic constructs).
 +
 
 +
* We have the following constructs available in the Tasking Machine body:
 +
** Sequence - for imposing an order on events.
 +
** Branch - choice between a number of mutually exclusive events.
 +
** Loop - event repetition while it's guard remains true.
 +
** Event - a wrapper for the Event-B element (soon to be redundant). 
 +
** Text Output - writes textual output to the screen.
 +
 
 +
The syntax for task bodies, as used in the Rose TaskBody editor, is as follows:
 +
 
 +
<br/>
 +
[[Image:Syntax.png]]
 +
<br/>
 +
 
 +
The ''String'' will be an event name, a variable name, or a text fragment to be output to the screen. The concrete syntax is shown in bold red font. '*' indicates 0 or more; [] indicates 0 or 1.
 +
 
 +
===== Event Translation =====
 +
When an event, used in the task body, is translated to an implementation its translation depends on where it is used in the task body. The mappings are relatively simple for branch, loop, and sequence; but, in addition to the parent construct, the Event translation depends on whether it is part of a synchronization. Obviously the simplest translation is when no synchronization is involved. The translator checks the composed machine to see if the event is paired in a combined event. We say that events is a Tasking machine are local, and that events in a Shared or Environ machine, are remote. If there is no synchronization, then the actions of the local event are expanded in-line in the subroutine body.
 +
 
 +
'''NOTE''': As a result of the decomposition process, the tool can produce a remote event, without a corresponding local event. A local event, with no guards and skip action, must be added manually to the tasking machine, and composed machine in order to facilitate code generation. This will be automated in a pre-processing step in the near future tooling. It is not necessary to have a dummy remote event if a remote event does not exist.
 +
 
 +
===== Synchronization =====
 +
 
 +
Synchronization between local events (in AutoTasks) and remote events (in shared/Environ Machines) is determined using the composed machine. To use an event simply enter its name in the TaskBody editor. The translator will in-line any local actions, and add a call to perform remote updates, and obtain remote data.
 +
 
 +
Interim measure ......
 +
 
 +
Synchronization corresponds to:
 +
* a subroutine call from task to shared machine, or,
 +
* sensing or actuating of environment variables.
 +
 
 +
In the case of a subroutine call the subroutine is an atomic (with respect to an external viewer) update to state. The updates in the protected resource are implemented by a procedure call to a protected object, and tasks do no share state.  The synchronization construct also provides the means to specify parameter passing, both in and out of the task.
 +
 
 +
In the case of a sensing or actuating event, the updates of the action correspond to reads of monitored variables, and writes to controlled variables of the environment.
 +
 
 +
==== Implementing Events ====
 +
An event's role in the implementation is identified using the following extensions which are added to the event. Events used in task bodies are 'references' that make use of existing event definitions from the abstract development. The events are extended. to assist with translation, with a keyword indicating their role in the implementation.
 +
 
 +
* Event implementation role.
 +
** Branch - In essence a task's event is split in the implementation; guards are mapped to branch conditions and actions are mapped to the branch body. If the branch refers to a Shared Machine event (procedureDef) then this is mapped to a simple procedure call.
 +
** Loop - The task's event guard maps to the loop condition and actions to to loop body. If the loop refers to a Shared Machine event then it is mapped to a simple procedure call.
 +
** ProcedureSynch - This usually indicates to the translator that the event maps to a subroutine, but an event in a task may not require a subroutine implementation if its role is simply to provide parameters for a procedure call.
 +
** ProcedureDef - Identifies an event that maps to a (potentially blocking) subroutine definition. Event guards are implemented as a conditional wait; in Ada this is an entry barrier, and in C may use a pthread condition variable .
 +
** Sensing - Identifies an event that maps to a read from the environment. If the environment is simulated without address variables then the sensing event is similar to a ProcedureSynch event, in that it has an update action that models assignment of a return value from a subroutine call. The event parameters act like the ''actualIn'' parameters of a ProcedureSynch event. On the other hand, if the event has addressed variables associated with its event parameters, then they map to direct reads from memory mapped variables in the generated code.
 +
** Actuating - Identifies an event that maps to a write to the environment. If the environment is simulated without address variables then the actuating event has no update action, the parameters act like ''actualOut'' parameters of a ProcedureSynch event. If a sensing event has addressed variables associated with its parameters then they map to direct writes to memory mapped variables in the generated code.
 +
 
 +
Sensing (and actuating) can be viewed as a kind of synchronisation. Synchronisation between tasks and shared objects are represented as subroutine calls. The sensing/actuating synchronisations only occur between tasks and the environment. In implementable code, when an subroutine is defined, its formal parameters are replaced by actual parameter values at run-time. To assist the code generator we extend the Event-B parameters. We identify formal and actual parameters in the implementation, and add the following keywords to the event parameters, as follows:
 +
 
 +
* Event parameter types - Note: formal parameters are place-holders in a subroutine; they are replaced by the actual parameters at call time.
 +
** FormalIn or FormalOut - event parameters are extended with the ParameterType construct. Extension with formal parameters indicates a mapping to formal parameters in the implementation.
 +
** ActualIn or ActualOut - Extension with an actual parameter indicates a mapping to an actual parameter in the implementation.
 +
 
 +
===== Addressed Variables =====
 +
When sensing monitored variables, or actuating controlled variables in the environment, we may wish to use explicit memory addresses for use in the final implementation, or perhaps in the environment simulation too. We can link a task's event parameters, and an Environ machines variables, with specific addresses and use these in the generated code.
 +
 
 +
== References ==
 +
 
 +
<references/>
 +
 
 +
 
 +
[[Category:User documentation]]

Revision as of 09:27, 28 November 2011

Tasking Event-B

Tasking Event-B can be viewed as an extension of the existing Event-B language. We use the existing approaches of refinement and decomposition to structure a project that is suitable for a Tasking Development. During the modelling phase parameters are introduced to facilitate decomposition. As a result of the decomposition process, parameters become part of the interface that enables event synchronization. We make use of this interface and add information (see #Implementing Events) to facilitate code generation. The tasking extension consists of the constructs in the following table.

Construct Options
Machine Type DeclaredTask, AutoTask, SharedMachine, Environ
Control Sequence, Loop, Branch, Event, Output
Task Type Periodic(n), Triggered, Repeating, OneShot
Priority -
Event Role Actuating, Sensing
Addressed Variable Address, Base

Tasking Machines

The following constructs relate to Tasking and Environ Machines, and provide implementation details. Timing of periodic tasks is not modelled formally. Tasking and Environ Machines model Ada tasks, so they can be implemented easily in Ada; in C using the pthread library, or in Java using threads.

  • Tasking Machines may be one of the following types:
    • AutoTasks - Anonymous Tasks running from start-up.
    • Declared tasks - (Not currently used) A task template relating to an Ada tasktype declaration.

Auto Tasks are tasks that will be declared and defined in the Main procedure of the implementation. The effect of this is that the Auto Tasks are created when the program first loads, and then activated (made ready to run) before the Main procedure body runs.

  • Tasking and Environ Machines options are:
    • TaskType - Defines the scheduling, cycle and lifetime of a task. i.e. one-shot periodic or triggered. The period of a task is specified in milliseconds.
    • Priority - An integer value is supplied, the task with the highest value priority takes precedence when being scheduled. The default priority is 5.

Shared Machines

A Shared Machine models a protected resource, such as a monitor. It may be implemented in Ada as a Protected Object, in C using mutex locking, or in Java as a monitor.

  • A Shared Machine is identified using the Shared Machine annotation.

The Environ Machine

An Environ machine is a model of the environment. It can be used to generate code for use in a simulation, or be discarded in the case that a simulated environment is not required.

  • An Environ Machine is identified using the Environ Machine annotation.

Control of Program Flow

At the implementation stage we need to think about controlling the flow of execution; and where interaction with the environment is concerned, how events should be implemented. The following section describes the constructs that we have introduced to facilitate this.

Control Constructs

Each Tasking Machine has a task body which contains the flow control (algorithmic constructs).

  • We have the following constructs available in the Tasking Machine body:
    • Sequence - for imposing an order on events.
    • Branch - choice between a number of mutually exclusive events.
    • Loop - event repetition while it's guard remains true.
    • Event - a wrapper for the Event-B element (soon to be redundant).
    • Text Output - writes textual output to the screen.

The syntax for task bodies, as used in the Rose TaskBody editor, is as follows:


Syntax.png


The String will be an event name, a variable name, or a text fragment to be output to the screen. The concrete syntax is shown in bold red font. '*' indicates 0 or more; [] indicates 0 or 1.

Event Translation

When an event, used in the task body, is translated to an implementation its translation depends on where it is used in the task body. The mappings are relatively simple for branch, loop, and sequence; but, in addition to the parent construct, the Event translation depends on whether it is part of a synchronization. Obviously the simplest translation is when no synchronization is involved. The translator checks the composed machine to see if the event is paired in a combined event. We say that events is a Tasking machine are local, and that events in a Shared or Environ machine, are remote. If there is no synchronization, then the actions of the local event are expanded in-line in the subroutine body.

NOTE: As a result of the decomposition process, the tool can produce a remote event, without a corresponding local event. A local event, with no guards and skip action, must be added manually to the tasking machine, and composed machine in order to facilitate code generation. This will be automated in a pre-processing step in the near future tooling. It is not necessary to have a dummy remote event if a remote event does not exist.

Synchronization

Synchronization between local events (in AutoTasks) and remote events (in shared/Environ Machines) is determined using the composed machine. To use an event simply enter its name in the TaskBody editor. The translator will in-line any local actions, and add a call to perform remote updates, and obtain remote data.

Interim measure ......

Synchronization corresponds to:

  • a subroutine call from task to shared machine, or,
  • sensing or actuating of environment variables.

In the case of a subroutine call the subroutine is an atomic (with respect to an external viewer) update to state. The updates in the protected resource are implemented by a procedure call to a protected object, and tasks do no share state. The synchronization construct also provides the means to specify parameter passing, both in and out of the task.

In the case of a sensing or actuating event, the updates of the action correspond to reads of monitored variables, and writes to controlled variables of the environment.

Implementing Events

An event's role in the implementation is identified using the following extensions which are added to the event. Events used in task bodies are 'references' that make use of existing event definitions from the abstract development. The events are extended. to assist with translation, with a keyword indicating their role in the implementation.

  • Event implementation role.
    • Branch - In essence a task's event is split in the implementation; guards are mapped to branch conditions and actions are mapped to the branch body. If the branch refers to a Shared Machine event (procedureDef) then this is mapped to a simple procedure call.
    • Loop - The task's event guard maps to the loop condition and actions to to loop body. If the loop refers to a Shared Machine event then it is mapped to a simple procedure call.
    • ProcedureSynch - This usually indicates to the translator that the event maps to a subroutine, but an event in a task may not require a subroutine implementation if its role is simply to provide parameters for a procedure call.
    • ProcedureDef - Identifies an event that maps to a (potentially blocking) subroutine definition. Event guards are implemented as a conditional wait; in Ada this is an entry barrier, and in C may use a pthread condition variable .
    • Sensing - Identifies an event that maps to a read from the environment. If the environment is simulated without address variables then the sensing event is similar to a ProcedureSynch event, in that it has an update action that models assignment of a return value from a subroutine call. The event parameters act like the actualIn parameters of a ProcedureSynch event. On the other hand, if the event has addressed variables associated with its event parameters, then they map to direct reads from memory mapped variables in the generated code.
    • Actuating - Identifies an event that maps to a write to the environment. If the environment is simulated without address variables then the actuating event has no update action, the parameters act like actualOut parameters of a ProcedureSynch event. If a sensing event has addressed variables associated with its parameters then they map to direct writes to memory mapped variables in the generated code.

Sensing (and actuating) can be viewed as a kind of synchronisation. Synchronisation between tasks and shared objects are represented as subroutine calls. The sensing/actuating synchronisations only occur between tasks and the environment. In implementable code, when an subroutine is defined, its formal parameters are replaced by actual parameter values at run-time. To assist the code generator we extend the Event-B parameters. We identify formal and actual parameters in the implementation, and add the following keywords to the event parameters, as follows:

  • Event parameter types - Note: formal parameters are place-holders in a subroutine; they are replaced by the actual parameters at call time.
    • FormalIn or FormalOut - event parameters are extended with the ParameterType construct. Extension with formal parameters indicates a mapping to formal parameters in the implementation.
    • ActualIn or ActualOut - Extension with an actual parameter indicates a mapping to an actual parameter in the implementation.
Addressed Variables

When sensing monitored variables, or actuating controlled variables in the environment, we may wish to use explicit memory addresses for use in the final implementation, or perhaps in the environment simulation too. We can link a task's event parameters, and an Environ machines variables, with specific addresses and use these in the generated code.

References