From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail From: Simon Wright Newsgroups: comp.lang.ada Subject: Re: Task_Barriers Date: Fri, 26 Jul 2019 16:03:08 +0100 Organization: A noiseless patient Spider Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain Injection-Info: reader02.eternal-september.org; posting-host="5c170a9efc4470b4fd7cbf678b15527e"; logging-data="21282"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/Bt0k3TvrmgNNcBz6SLdGhnJUNK2TwSOE=" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (darwin) Cancel-Lock: sha1:0mZ9r+HjwMS+oBd6vNot4lCUsxY= sha1:P3G6YTMVS3QefuQuO0AmZWBykWQ= Xref: reader01.eternal-september.org comp.lang.ada:56956 Date: 2019-07-26T16:03:08+01:00 List-Id: Gilbert Gosseyn writes: > Ada 2012 provides a language-defined package to synchronously release > a group of tasks after the number of blocked tasks reaches a specified > 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. I see what you mean by the count value, but I don't understand what "it" it is that you think "should stop". The main program won't finish until both tasks have finished. Look at T1, for example: task body T1 is begin loop delay 1.0 ; Wait_For_Release (SB,Notified) ; X:=X+1; end loop ; end T1 ; when the number of tasks waiting on NT reaches 2, both the waiting tasks are released, and Notified is set True for the one that the runtime chooses (by the way, I think Notified should be a local variable here). So T1 wakes up, increments X, *and goes round the loop again*. Try putting in some trace statements: task body T1 is begin loop delay 1.0 ; Wait_For_Release (SB,Notified) ; X:=X+1; Put_Line ("t1 released, x:" & X'Image); ---------------- end loop ; end T1 ; and similar for Y.