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=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,1c3d4536a687b7b0 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2000-09-01 12:44:44 PST Path: supernews.google.com!sn-xit-02!sn-east!supernews.com!news-feed.riddles.org.uk!arclight.uoregon.edu!newsfeed.mathworks.com!news-out.cwix.com!newsfeed.cwix.com!sjc-peer.news.verio.net!news.verio.net!easynews!cyclone-west.rr.com!news.rr.com!news-west.rr.com!newsfeed2.earthlink.net!newsfeed.earthlink.net!news.mindspring.net!firehose.mindspring.com!not-for-mail From: Richard Riehle Newsgroups: comp.lang.ada Subject: Re: Ada 95 tasking problems with Ada 83 code Date: Thu, 31 Aug 2000 21:17:48 -0700 Organization: MindSpring Enterprises Message-ID: <39AF2DEC.71D8B897@ix.netcom.com> References: <39ADAE51.30550667@mtws.visicom.com> <39ADD3A3.381DEF17@ix.netcom.com> <39AF20CE.FDBDFFFE@mtws.visicom.com> NNTP-Posting-Host: d1.8a.d1.a2 Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Server-Date: 1 Sep 2000 19:41:38 GMT X-Mailer: Mozilla 4.7 [en] (Win98; I) X-Accept-Language: en Xref: supernews.google.com comp.lang.ada:467 Date: 2000-09-01T19:41:38+00:00 List-Id: Wayne Lydecker wrote: > > > That's it! Turns out that the test program that starts the main > program creates a task that displays a menu and then uses a call to > text_io.get_line. Evidently, the get_line in a task blocks the main > program. > > I tried text_io.look_ahead, but end_of_line was always False. Do > I have to check each character for ? Text_IO.Get_Immediate > works fine for single characters, but again I would have to search > for . > > Would it work OK to reverse what is going on here and create a new task > to launch the main program and keep the test driver as a procedure? > Would the text_io.get_line still block the main program? > > Thanks again Richard, I was about to perform a major re-write. I > am almost complete with my task ;-) Wayne, It is often the case that the initial Get_Line is associated with an entry call in an Ada 83 task for task initialization. For example, the task needs to get its own name or some other kind of ID. This had to be done with an entry call in Ada 83 but can be accomplished in Ada 95 more easily and with less overhead. Simply create a task type with a discriminant and decclare or allocate the task with the actual parameter for the discriminant. If the information required is a composite type (String or record), simply use a access discriminant. This can save some time, eliminate start-up blocking, and is evaluated at elaboration time instead of during actual task execution. That is, there is no blocking and no context switching overhead. This technique becomes especially useful if you are doing dynamic allocation of the task at different stages of the life of a program. Reminder: you still need to take a look at RMA if you have 100 concurrent tasks. Richard Riehle richard@adaworks.com