From 7e579a0a21058d29855d82ebba10b3efed9a50c4 Mon Sep 17 00:00:00 2001 From: gusthoff Date: Sat, 8 Feb 2025 01:56:53 +0100 Subject: [PATCH 1/3] Editorial change: remove todo item --- .../advanced-ada/parts/control_flow/exceptions.rst | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/content/courses/advanced-ada/parts/control_flow/exceptions.rst b/content/courses/advanced-ada/parts/control_flow/exceptions.rst index fa4b6bb4e..1beff861e 100644 --- a/content/courses/advanced-ada/parts/control_flow/exceptions.rst +++ b/content/courses/advanced-ada/parts/control_flow/exceptions.rst @@ -966,19 +966,10 @@ checks fails and raises a :ada:`Storage_Error` exception. -.. - TO BE DONE: - :ada:`Tasking_Check` - ~~~~~~~~~~~~~~~~~~~~ - - .. admonition:: In the Ada Reference Manual - - - :arm22:`11.5 Suppressing Checks <11-5>` - - .. todo:: +:ada:`Tasking_Check` +~~~~~~~~~~~~~~~~~~~~ - - Complete section! From 51b2b17df34e5010bfa6ae0487d32f63ebb66c6c Mon Sep 17 00:00:00 2001 From: gusthoff Date: Sat, 8 Feb 2025 02:24:51 +0100 Subject: [PATCH 2/3] Adding subsection on `Tasking_Check` --- .../parts/control_flow/exceptions.rst | 53 +++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/content/courses/advanced-ada/parts/control_flow/exceptions.rst b/content/courses/advanced-ada/parts/control_flow/exceptions.rst index 1beff861e..abaab4649 100644 --- a/content/courses/advanced-ada/parts/control_flow/exceptions.rst +++ b/content/courses/advanced-ada/parts/control_flow/exceptions.rst @@ -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. @@ -970,7 +972,58 @@ checks fails and raises a :ada:`Storage_Error` exception. :ada:`Tasking_Check` ~~~~~~~~~~~~~~~~~~~~ +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. + +.. 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 + + 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`. From 804c672fd0f0f7e20fa85f8538e14e69e26ba437 Mon Sep 17 00:00:00 2001 From: gusthoff Date: Sat, 8 Feb 2025 02:25:04 +0100 Subject: [PATCH 3/3] Editorial change: adding anchor --- content/courses/advanced-ada/parts/control_flow/exceptions.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/content/courses/advanced-ada/parts/control_flow/exceptions.rst b/content/courses/advanced-ada/parts/control_flow/exceptions.rst index abaab4649..294fa3e23 100644 --- a/content/courses/advanced-ada/parts/control_flow/exceptions.rst +++ b/content/courses/advanced-ada/parts/control_flow/exceptions.rst @@ -969,6 +969,8 @@ checks fails and raises a :ada:`Storage_Error` exception. +.. _Adv_Ada_Tasking_Check: + :ada:`Tasking_Check` ~~~~~~~~~~~~~~~~~~~~