• No se han encontrado resultados

los componentes con símbolos literales y subíndices.

compiler is the new task attributes and aspects. These attributes and associated aspects follow the same form as the existing Priority and CPU task attributes, making them trivial to incorporate by following these existing implementations. An exception lies with the Cyclic_Task aspect, which also requires the compiler

to check the appropriateness of the task’s body cyclic section.

Two different approaches exist for expanding cyclic task bodies. Since a task’s cyclic kind is static, one approach sees a task body expanded into the corre- sponding direct cyclic task implementation outlined in Implementing Cyclic Tasks in Ada on page 16. This tactic favours compilers providing only simple

cyclic tasks without deadlines and execution budgets. As Chapter 2 showed, these forms of cyclic tasks require little extra code to create the required cyclic task semantics from a sequential task.

A more balanced approach better supporting the Specification leverages the

essence of the cyclic task model: a cycle commences in response to a cycle event once a previous cycle has concluded. Here, the burden of implementa- tion falls onto the run-time: controlling when the task can commence a new cycle. Consequently, the expansion of a cyclic task can transform a task body’s

task_sequence_of_statement: sequential_sequence_of_statements [cycle cyclic_sequence_of_statements] [exception exception_handler {exception_handler}]

into a handled_sequeunce_of_statements which the compiler can already handle: sequence_of_statements [loop Wait_For_Cycle_Event; sequence_of_statements end loop] [exception exception_handler {exception_handler}]

The run-time provides the Wait_For_Cycle_Event procedure, blocking the task until the next cycle can commence. The procedure also signals to the run-time when the task completes a cycle, and manages cycle deadline and execution budget enforcement. The management of cycle events — the generation of periodic events and enforcement of MIT — can occur here or alternatively handled by the underlying operating system or kernel. How the run-time pro- vides these services is dependent on the existing services offered by run-time or its underlying system. Chapter 5 describes one such cyclic task run-time implementation for the real-time executive Acton.

For execution servers, the Specification requires run-times to determine them-

selves how to provide the appropriate representation within the execution server model. Run-times can choose to internally implement execution servers as, for example:

55 THE CYCLIC TASK SPECIFICATION

▶ like tasks, but dispatching their member tasks whenever the run-time selects the server for dispatch;

▶ using Ada 2012’s group execution time budgets (ARM D.14.2); ▶ using timers and asynchronous task control to resume and suspend

tasks as the server’s execution window opens and closes; or

▶ using operating system provided service like POSIX’s sporadic servers. Note a task-like representation within the run-time enables execution server implementations to be portable across different task dispatching policies.

The Ada Semantic Interface Specification (ASIS) standard (ISO/IEC, 1999) pro- vides a standardised library interface enabling access to the semantic and syn- tactic information of an Ada program (AdaCore, 2014). Its existence facilitates the development of code analysis tools independently from the underlying Ada environment and lowers the entry barrier for new code analysis tools. The interface consists of queries tools can perform on an Ada program’s abstract syntax tree.

Modifying the task body syntax and the introduction of the new_cycle_state- ment to support the cyclic task abstraction inside Ada necessitates changes to ASIS so tools can support and take advantage of the new syntax. The chang- es documented here affect the ASIS, ASIS.Declarations and ASIS.Statements

packages.

Within the ASIS package, the enumeration type Statement_Kinds (ASIS 3.9.20) expands to include a new enumeration literal A_New_Cycle_Statement, allow- ing identification of the new_cycle_statement:

--- -- 3.9.20 type Statement_Kinds

--- -- Statement_Kinds - classifications of Ada statements

-- Literals -- Reference Manual ---

type Statement_Kinds is (..., A_New_Cycle_Statement);

The ASIS.Declarations package provides the Body_Statement query to return the list of statements and pragmas for a given body declaration (ASIS 15.22). Body declarations are defined to include subprograms bodies, entry bodies, package bodies and, most relevantly, task bodies. While the Cyclic Task Spec- ification now defines two distinct sets of task body statements, for backwards

capability the Body_Statement query on task body declarations remains. The query will return a single set of statements (appending the cyclic statements

Ada Semantic Interface Specification

ASIS Listing 30 Amendment to ASIS.Statement_Kinds (asis.ads). ASIS.Declarations 56 CHAPTER 3

to the end of the sequential statements) but such a query is obsolescent and only for compilers not implementing cyclic tasks or supporting legacy tools: --- -- 15.22 function Body_Statements

---

function Body_Statements

(Declaration : Asis.Declaration; Include_Pragmas : Boolean := False) return Asis.Statement_List;

--- -- Declaration - Specifies the body declaration to query -- Include_Pragmas - Specifies whether pragmas are to be -- returned

--

-- Returns a list of the statements and pragmas for the body, in -- their order of appearance.

--

-- Returns a Nil_Element_List if there are no statements or -- pragmas. -- -- Appropriate Declaration_Kinds: -- A_Function_Body_Declaration -- A_Procedure_Body_Declaration -- A_Package_Body_Declaration

-- A_Task_Body_Declaration - obsolescent, not recommended -- An_Entry_Body_Declaration -- -- Returns Element_Kinds: -- A_Pragma -- A_Statement --

-- --|AN Application Note: -- --|AN

-- --|AN This function is an obsolete feature when provided an -- --|AN A_Task_Body_Declaration. Use Sequential_Body_Statements -- --|AN and Cyclic_Body_Statements instead.

Replacing the Body_Statement query is the new Sequential_Body_Statements

and Cyclic_Body_Statements queries, returning the list of statements and prag- mas for the task’s sequential and cyclic sections respectively (Listing 32 on page 58). Tasks without a cyclic section will return Nil_Element_List in response to the Cyclic_Body_Statements query.

The final change to ASIS sees the introduction of a new statement query: New_ Cycle_Tasks, allowing an ASIS tool gather the tasks referred to in a new_cy- cle_statement (Listing 33 on page 59).

Listing 31 Amendment to ASIS.Declarations.Body_State- ment interface (asis-declarations.ads). ASIS.Statements 57 THE CYCLIC TASK SPECIFICATION

--- -- 15.?? function Sequential_Body_Statements

---

function Sequential_Body_Statements (Declaration : Asis.Declaration; Include_Pragmas : Boolean := False) return Asis.Statement_List;

--- -- Declaration - Specifies the body declaration to query -- Include_Pragmas - Specifies whether pragmas are to be -- returned

--

-- Returns a list of the statements and pragmas for the -- sequential body section of a task, in their order of -- appearance.

--

-- Returns a Nil_Element_List if there are no statements or -- pragmas. -- -- Appropriate Declaration_Kinds: -- A_Task_Body_Declaration -- -- Returns Element_Kinds: -- A_Pragma -- A_Statement --- -- 15.?? function Cyclic_Body_Statements --- function Cyclic_Body_Statements (Declaration : Asis.Declaration; Include_Pragmas : Boolean := False) return Asis.Statement_List;

--- -- Declaration - Specifies the body declaration to query -- Include_Pragmas - Specifies whether pragmas are to be -- returned

--

-- Returns a list of the statements and pragmas for the

-- cyclic body section of a task, in their order of appearance. --

-- Returns a Nil_Element_List if there are no statements or -- pragmas. -- -- Appropriate Declaration_Kinds: -- A_Task_Body_Declaration -- -- Returns Element_Kinds: -- A_Pragma -- A_Statement Listing 32 Additions to ASIS.Declarations.interface (asis-declarations.ads). 58 CHAPTER 3

The Cyclic Task Specification’s initial benefit to users is easy to author cyclic

tasks that are simple to understand: achieved by reducing the amount of code required to express a cyclic task and presenting it in a standardised approach. With the changes to ASIS, the benefits also apply to Ada code analysis tools. Code analysis tools can now extract cyclic task information right from a pro- gram’s code because of the standardised attributes. The utility of the Specifica- tion increases when using static cyclic attributes, because they appear as aspects

on the definition of task types. While more challenging, analysis of tasks with dynamic attributes is still possible due to the standardised library procedures that change the cyclic attributes.

Since code analysis tools can now extract cyclic task properties direct from Ada programs, a new class of tools can now help ease the development of reli- able and maintainable software. For example, current schedulability analysis tools require users to either manually enter cyclic task attributes or provide them through specially annotated code. Now a schedulability analysis tool can examine an Ada program directly and perform its analysis using the task attributes the analyser pulled from the program’s code; all without user input. In this scenario, the user has greater confidence in the analysis because the analyser will be using the exact same task attribute values as the program will at run-time. Mistakes introduced during the transfer of attributes between code

and analyser can no long occur because the analyser has access to the same information the compiler uses.

Similarly, WCET tools can now identify the cyclic section of a task themselves. When combined with the programs object code, analysis becomes more auto- mated because the user no longer has to explicitly tell the tool where the cyclic task sections are situated. However, the real benefit for WCET tools lies in the ability for them to directly write their results back into the program’s code in the form of execution budgets and have them enforced at run-time.

ASIS Tools and Cyclic Tasks

--- -- 18.?? function New_Cycle_Tasks --- function New_Cycle_Tasks (Statement : Asis.Statement) return Asis.Expression_List; --- -- Statement - Specifies the new cycle statement to query --

-- Returns a list of the task names from the NEW CYCLE statement, -- in their order of appearance.

-- -- Appropriate Statement_Kinds: -- A_New_Cycle_Statement -- -- Returns Element_Kinds: -- An_Expression Listing 33 Additions to ASIS.Statements.interface (asis-statements.ads). 59 THE CYCLIC TASK SPECIFICATION

Documento similar