Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding subsection on Tasking_Check #1183

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 54 additions & 8 deletions content/courses/advanced-ada/parts/control_flow/exceptions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,8 @@ This table shows all language-defined checks and the associated exceptions:
+-----------------------------+-------------------------+
| :ada:`Storage_Check` | :ada:`Storage_Error` |
+-----------------------------+-------------------------+
| :ada:`Tasking_Check` | :ada:`Tasking_Error` |
+-----------------------------+-------------------------+

In addition, we can use :ada:`All_Checks` to refer to all those checks above at
once.
Expand Down Expand Up @@ -966,20 +968,64 @@ checks fails and raises a :ada:`Storage_Error` exception.



..
TO BE DONE:

:ada:`Tasking_Check`
~~~~~~~~~~~~~~~~~~~~
.. _Adv_Ada_Tasking_Check:

.. admonition:: In the Ada Reference Manual
:ada:`Tasking_Check`
~~~~~~~~~~~~~~~~~~~~

- :arm22:`11.5 Suppressing Checks <11-5>`
The :ada:`Tasking_Check` ensures that all tasks have been activated
successfully and that no terminated task is called. If the check fails, a
:ada:`Tasking_Error` exception is raised.

.. todo::
.. note::

This concept was introduced in Ada 2022. It was created to group all checks
that might raise the :ada:`Tasking_Error` exception.

Let's look at a simple example:

.. code:: ada run_button project=Courses.Advanced_Ada.Control_Flow.Exceptions.Checks_And_Exceptions.Tasking_Check_Error
:class: ada-run-expect-failure

package Workers is

- Complete section!
task type Worker is
entry Start;
end Worker;

end Workers;

with Ada.Text_IO; use Ada.Text_IO;

package body Workers is

task body Worker is
begin
Put_Line ("Task has started.");
delay 1.0;
Put_Line ("Task has finished.");
end Worker;

end Workers;

with Ada.Text_IO; use Ada.Text_IO;
with Workers; use Workers;

procedure Show_Tasking_Check_Error is
W : Worker;
begin
Put_Line ("W.Start...");
W.Start;
Put_Line ("Finished");
end Show_Tasking_Check_Error;

In this example, the body of :ada:`Worker` doesn't have an :ada:`accept`.
Therefore, no rendezvous can happen for the :ada:`W.Start` call. Since the
task eventually terminates (as you can see in the user messages), the call
to :ada:`Start` constitutes a call to a terminated task. This condition is
checked by the :ada:`Tasking_Check`, which fails in this case, thereby
raising a :ada:`Tasking_Error`.



Expand Down
Loading