A task unit is a program unit that is obeyed concurrently with the rest of an Ada program. The corresponding activity, a new locus of control, is called a task in Ada terminology, and is similar to a thread, for example in Java Threads. The execution of the main program is also a task, the anonymous environment task. A task unit has both a declaration and a body, which is mandatory. A task body may be compiled separately as a subunit, but a task may not be a library unit, nor may it be generic. Every task depends on a master, which is the immediately surrounding declarative region - a block, a subprogram, another task, or a package. The execution of a master does not complete until all its dependent tasks have terminated. The environment task is the master of all other tasks; it terminates only when all other tasks have terminated.
Task units are similar to packages in that a task declaration defines entities exported from the task, whereas its body contains local declarations and statements of the task.
A single task is declared as follows:
task Single is
declarations of exported identifiers
end Single;
...
task body Single is
local declarations and statements
end Single;
A task declaration can be simplified, if nothing is exported, thus:
task No_Exports;
procedure Housekeeping is
task Check_CPU;
task Backup_Disk;
task body Check_CPU is
...
end Check_CPU;
task body Backup_Disk is
...
end Backup_Disk;
begin
null;
end Housekeeping;
It is possible to declare task types, thus allowing task units to be created dynamically, and incorporated in data structures:
task type T is
...
end T;
...
Task_1, Task_2 : T;
...
task body T is
...
end T;
Task types are limited, i.e. they are restricted in the same way as limited private types, so assignment and comparison are not allowed.
Related
A task unit is a program unit that is obeyed concurrently with the rest of an Ada program. The corresponding activity, a new locus of control, is
April 18, 2024
A render of a 6-cube. Source: Wikipedia
April 18, 2024
An ornamental design of five alternately interlaced pentagons (a kind of five-fold counterpart to the three-fold Valknut). No two pentagons are
April 18, 2024
In mathematics and especially in combinatorics, a plane partition is a two-dimensional array of nonnegative integers $ n_{i,j}} n_{{i,j}} $ (with
April 18, 2024
The idea of code reuse arises from the necessity for constructing large software systems combining well-established building blocks. The reusability
April 18, 2024
The Möbius strip or Möbius band is a surface with only one side and only one boundary. The Möbius strip has the mathematical property of being
April 18, 2024
In mathematics, the Klein bottle /ˈklaɪn/ is an example of a non-orientable surface; it is a two-dimensional manifold against which a system for
April 18, 2024
Among basic expressions are literals, for example, decimal (real), enumeration, string, and access value literals: Involving many of those one can
April 18, 2024
In geometry, a torus (plural tori) is a surface of revolution generated by revolving a circle in three-dimensional space about an axis coplanar with
April 18, 2024
A polygon discovered by Robert Amman, formed from a regular hexagon by adding projections on two of its sides and matching indentations on three
April 18, 2024
The generic unit declares generic formal parameters, which can be: objects (of mode in or in out but never out) types subprograms instances of
April 18, 2024
The Gaussian integers are [complex numbers] of the form , where u and v are ordinary [integers] and i is the [square root of negative one]. By
April 18, 2024
A monochrome render of a Truncated dodecahedron by Olfa Wektoryzacja, 2007. Source: Wikipedia
April 18, 2024
You can define a new type with the following syntax: followed by the description of the type, as explained in detail in each category of type.
April 18, 2024
around a saddle point. Selfmade with Mathematica and Inkscape. Source: Wikipedia
April 18, 2024
The mpl colormaps: magma, inferno, plasma and viridis. I previously attempted to implement these in the Cubehelix color space, but the originals are
April 18, 2024
This map shows the graph distance of each county from the Pacific or Atlantic coast; it is a recreation of a map posted to /r/dataisbeautiful using
April 18, 2024
Un des 9 groupes non-abéliens d’ordre 16 est le produit semi-direct de C_2^2 par C_4. On peut dessiner le graphe de Cayley de cette présentation sur
April 18, 2024
A plot of the bowl function Source: Wikipedia
April 18, 2024