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=-0.8 required=5.0 tests=BAYES_00,INVALID_DATE autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,d11f89f2e445c0a7 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 1993-03-10 10:23:51 PST Newsgroups: comp.lang.ada Path: sparky!uunet!pmafire!news.dell.com!natinst.com!cs.utexas.edu!zaphod.mps.ohio-state.edu!howland.reston.ans.net!agate!linus!linus.mitre.org!linus!mbunix!eachus From: eachus@goldfinger.mitre.org (Robert I. Eachus) Subject: Re: Activating tasks at global scope In-Reply-To: sdm@cs.brown.edu's message of Wed, 10 Mar 1993 03:32:56 GMT Message-ID: Sender: news@linus.mitre.org (News Service) Nntp-Posting-Host: goldfinger.mitre.org Organization: The Mitre Corp., Bedford, MA. References: <1993Mar10.033256.24718@cs.brown.edu> Date: Wed, 10 Mar 1993 17:11:15 GMT Date: 1993-03-10T17:11:15+00:00 List-Id: In article <1993Mar10.033256.24718@cs.brown.edu> sdm@cs.brown.edu (Scott Meyers) writes: > The code below implements a producer-consumer system containing one > producing task, two consuming tasks, and a bounded buffer task. I am only > interested in the tasking interactions, so I've omitted the actual buffer > manipulations. This code works fine under the Ada/ED compiler. However, I > would prefer to put the tasks at global scope rather than nest them inside > the producer_consumer procedure. I tried to do this by putting each task > inside a package, but then I couldn't figure out how to activate the tasks > when producer_consumer was invoked. What I'd like is an architecture where > the tasks are automatically started before or at the same time the the main > subprogram is invoked. You were doing fine, but got bitten by a very subtle feature of Ada. The tasks were all created and elaborated before the main program executed, but then the main program immediately exited. The language reference manual leaves it unspecifed what happens to library tasks in such a situation, but most implementations now terminate them all if they are quiescent. So your tasks disappeared from view before they could act. In any case try hanging your main program, either by putting in a delay statement or by waiting for input...the elegent final version should have a clean way of terminating the program, but this will do for testing. -- Robert I. Eachus with Standard_Disclaimer; use Standard_Disclaimer; function Message (Text: in Clever_Ideas) return Better_Ideas is...