Tasking Event-B Overview: Difference between revisions
imported>Andy |
imported>Andy |
||
Line 24: | Line 24: | ||
|Parameter Type | |Parameter Type | ||
|ActualIn, ActualOut, FormalIn, FormalOut | |ActualIn, ActualOut, FormalIn, FormalOut | ||
|} | | | ||
|- | |||
|Addressed Variable | |||
|Address, Base | |||
} | |||
</center> | </center> | ||
Revision as of 15:57, 3 May 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, EventSynch | |
Task Type | Periodic(n), Triggered, Repeating, OneShot | |
Priority | - | |
Event Type | Branch, Loop, ProcedureDef, ProcedureSynch, Actuating, Sensing | |
Parameter Type | ActualIn, ActualOut, FormalIn, FormalOut | |
Addressed Variable | Address, Base
} Tasking DevelopmentsA Tasking Development is modelling component that is generated programmatically, at the direction of the user. The Tasking Development consists of a number of machines (and perhaps associated contexts). We make use of the Event-B EMF extension mechanism [1], which allows addition of new constructs to a model. The machines in the Tasking Development are extended with the constructs shown in the table, and may be viewed as keywords in a textual representation of the language. With extensions added, a Tasking Development can be translated to a common language model for mapping to implementation source code. There is also a translator that constructs new machines/contexts modelling the implementation, and these should refine/extend the existing elements of the Event-B project. Tasking MachinesThe following constructs relate only to Tasking Machines, and provide implementation details. Timing of periodic tasks is not modelled formally. Tasking Machines are related to the concept of an Ada task. These can be implemented in Ada using tasks, in C using the pthread library C, or in Java using threads.
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. A Shared Machine corresponds to the concept of a protected resource, such as a monitor. They may be implemented in Ada as a Protected Object, in C using mutex locking, or in Java as a monitor.
The Environ MachineAn Environ machine is a model of the environment. It can be used to generate code for use in a simulation, or discarded in the case that it is not required.
Implementation SpecificsAt the stage where we are considering how to implement the Event-B development we need to think about controlling the flow of execution, and how events should be implemented. The following section describes the constructs that we have introduced to facilitate this. Control ConstructsEach Tasking Machine has a task body which contains the flow control (algorithmic constructs).
Synchronization corresponds to:
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. Event wrappers:
Implementing EventsAn 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.
In an implementation, 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:
References |