From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.5-pre1 (2020-06-20) on ip-172-31-74-118.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-0.5 required=3.0 tests=BAYES_05 autolearn=ham autolearn_force=no version=3.4.5-pre1 Date: 16 Sep 93 17:11:58 GMT From: news.crd.ge.com!e7sa!groleau@uunet.uu.net (Wes Groleau x1240 C73-8) Subject: Re: Tasking in Ada Message-ID: List-Id: In article <1993Sep15.041622.17841@rat.csc.calpoly.edu> kgatlin@galaxy.csc.calp oly.edu (Kang Su Gatlin) writes: >I have hit a snag with Ada. I need to create dynamic tasks that know which >task they are. > >I can't seem to find a way to pass information to tasks efficiently. I want >all the tasks to run simultaneously so that the creation and execution of >the tasks can be done in t(1) time. Someone will undoubtedly post a better way, but here's one. I have left out a lot of the trivial stuff that most programmers can figure out in 20 minutes with a reference manual and an error message. (If you've ever written an Ada program you'll do it in one minute with no manual.) If you decide to use this, you can use my name if you wish, but I'd prefer nothing else (no e-mail address , company name, street address, phone number, etc., please) Wes Groleau task body SAMPLE is My_ID : ID_TYPE := No_ID; begin accept IDENTIFICATION ( ID : ID_TYPE ) do My_ID := ID; end IDENTIFICATION; -- the following loop is only necessary if you need them all -- to start at approximately the same time. There is no way -- to start all at EXACTLY the same time. I have a way to -- get a more accurate start time than this, but it's kludgey. while Global_Start_Flag /= Go loop delay Some_Small_Amount; end loop; -- do the task end SAMPLE; begin -- main program for I in Array_Of_Tasks'RANGE loop Array_Of_Tasks ( I ) . IDENTIFICATION ( I ); end loop; Global_Start_Flag := Go; end; -- main program -----------