comp.lang.ada
 help / color / mirror / Atom feed
From: Gilbert Gosseyn <hnptz@yahoo.de>
Subject: Re: Task_Barriers
Date: Fri, 26 Jul 2019 03:38:36 -0700 (PDT)
Date: 2019-07-26T03:38:36-07:00	[thread overview]
Message-ID: <f1aefde4-371a-49f5-9e7b-4e8b0bc807a2@googlegroups.com> (raw)
In-Reply-To: <lyv9vpamxi.fsf@pushface.org>

On Thursday, July 25, 2019 at 10:17:47 PM UTC+2, Simon Wright wrote:
> 
> > although it should stop when reaching an internal count number
> 
> What internal count number is that?

1 with Ada . Text IO , Ada . Synchronous_Barriers ;
2 use Ada . Text IO , Ada . Synchronous_Barriers ;
4 procedure Task_Barriers  is
5 NT: constant :=2;
6 SB: Ada.Synchronous_Barriers.Synchronous_Barrier (NT) ;
7 Notified : Boolean:= False ;
8 task T1 ;
9 task T2 ;
10
11 X: I n t e g e r :=0;
12 Y: I n t e g e r :=1;
13
14 task body T1 is
15 begin
16 loop
17 delay 1.0 ;
18 Wait_For_Release (SB, Notified ) ;
19 X:=X+1;
20 end loop ;
21 end T1 ;
22
23 task body T2 i s
24 begin
25 loop
26 delay 1.0 ;
27 Wait_For_Release (SB, Notified ) ;
28 Y:=Y+1;
29 end loop ;
30 end T2 ;
31 begin
32 nul l ;
33 end Task_Ba r r i e r s ;

In this Task Barriers, procedure Task_Barriers is the parent of task T1 and task
T2. There are two synchronization channels about between two tasks. Line 18 is
sending a message that is meaning the number of blocked tasks associated with the
Synchronous Barrier object is equal to the threshold, to the line 28 that is receiving
this message and the statement is starting to execute. Here, the threshold is set to
2. In the same way, Line 27 is labeled with sending the message that the blocked
tasks are released, while Line 19 is receiving it and starting to execute.

Ada 2012 provides a language-de\ffined package to synchronously release a group of tasks after the number of blocked tasks reaches a specifi\fed count value. Each call to Wait_For_Release blocks the calling task until the number of blocked tasks associated with the Synchronous_Barrier object is
equal to Release_Threshold, at which time all blocked tasks are released. Barrier_release waiting is that tasks calling Wait_For_Release are blocked by other possible
tasks calling it until the number of blocked tasks associated with the Synchronous
Barrier object is equal to threshold. Therefore it should stop.

What may be wrong in my line of thinking?

  parent reply	other threads:[~2019-07-26 10:38 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-25 16:32 Task_Barriers Gilbert Gosseyn
2019-07-25 16:43 ` Task_Barriers Dmitry A. Kazakov
2019-07-25 18:56 ` Task_Barriers Dennis Lee Bieber
2019-07-25 20:11   ` Task_Barriers Jeffrey R. Carter
2019-07-25 20:17 ` Task_Barriers Simon Wright
2019-07-25 21:59   ` Task_Barriers Randy Brukardt
2019-07-26  7:52     ` Task_Barriers Simon Wright
2019-07-26 23:59       ` Task_Barriers Dennis Lee Bieber
2019-07-26 10:38   ` Gilbert Gosseyn [this message]
2019-07-26 11:09     ` Task_Barriers Dmitry A. Kazakov
2019-07-26 15:03     ` Task_Barriers Simon Wright
2019-07-27  0:10     ` Task_Barriers Dennis Lee Bieber
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox