From: Niklas Holsti <niklas.holsti@tidorum.invalid>
Subject: Re: How to terminate all running tasks?
Date: Wed, 10 Jun 2020 15:29:19 +0300
Date: 2020-06-10T15:29:19+03:00 [thread overview]
Message-ID: <hkc20vFgikuU1@mid.individual.net> (raw)
In-Reply-To: <hkc110FgbfgU1@mid.individual.net>
On 2020-06-10 15:12, Niklas Holsti wrote:
> and in the main subprogram, instead of the null statement and the
> exception handler:
>
> Ada.Synchronous_Task_Control.Suspend_Until_True (solution_found);
> abort p6p;
> abort p6m;
Just an addendum: to make sure that the main subprogram runs, and is not
starved by a child task that is still searching for a solution, you may
want to make the priorities of the child tasks lower than the priority
of the main subprogram (the environment task).
And a further note: generally one should avoid aborting tasks, as that
easily leads to messy race conditions. Better to have the tasks
terminate by themselves. For example, each of the search tasks could now
and then call Ada.Synchronous_Task_Control.Current_State
(solution_found) and terminate itself (exit the loop) if the result is True.
--
Niklas Holsti
niklas holsti tidorum fi
. @ .
next prev parent reply other threads:[~2020-06-10 12:29 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-10 11:14 How to terminate all running tasks? Gilbert Gosseyn
2020-06-10 12:12 ` Niklas Holsti
2020-06-10 12:29 ` Niklas Holsti [this message]
2020-06-10 16:26 ` Simon Wright
2020-06-11 6:04 ` J-P. Rosen
2020-06-10 13:49 ` Jeffrey R. Carter
2020-06-10 14:45 ` Jeffrey R. Carter
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox