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,a046ce7f5ee1fa51 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-12-04 08:55:19 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!arclight.uoregon.edu!wn14feed!worldnet.att.net!207.217.77.102!newsfeed2.earthlink.net!newsfeed.earthlink.net!stamper.news.pas.earthlink.net!newsread2.prod.itd.earthlink.net.POSTED!not-for-mail Message-ID: <3DEE33A5.8080709@acm.org> From: Jeffrey Carter User-Agent: Mozilla/5.0 (Windows; U; Win98; en-US; rv:1.0.0) Gecko/20020530 X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: new_line in a put_line References: <1ec946d1.0212020657.2bd8b5c@posting.google.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Date: Wed, 04 Dec 2002 16:55:20 GMT NNTP-Posting-Host: 63.184.17.144 X-Complaints-To: abuse@earthlink.net X-Trace: newsread2.prod.itd.earthlink.net 1039020920 63.184.17.144 (Wed, 04 Dec 2002 08:55:20 PST) NNTP-Posting-Date: Wed, 04 Dec 2002 08:55:20 PST Organization: EarthLink Inc. -- http://www.EarthLink.net Xref: archiver1.google.com comp.lang.ada:31429 Date: 2002-12-04T16:55:20+00:00 List-Id: Stephen Leake wrote: > > Assuming Lock is a controlled type, that releases the lock in > Finalize, this [using a semaphore] is an excellent design. I would disagree. Using a high-level feature such as a protected type to implement a low-level construct such as a semaphore is abstraction inversion. Ada has high-level concurrency features, and it should be possible to solve this problem directly in terms of those features. Using a semaphore probably indicates a lack of familiarity with those features rather than a reasoned decision that a semaphore is the best solution. For a real-time system I designed a debug-output system based on a protected bounded queue of bounded strings with a very high ceiling priority (any task could make a debug-output call) and a task with a very low priority (it only ran when nothing else was running) to actually do the output. Some logic deleted the oldest message in the queue if new messages were added when the queue was full, though that never happened in practice. The idea was that calls to produce output never blocked the caller so the system had minimal impact on the timing of the system. Of course, that had more complex requirements than what is being discussed here. Apparently the OP doesn't mind if the tasks are blocked during output, so simply rendezvousing with a task that does the output would solve the problem and be simpler and clearer than the semaphore + protected type approach. -- Jeff Carter "Go and boil your bottoms." Monty Python & the Holy Grail