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 09:46:31 PST Message-ID: <3DEE3ED2.7070009@cogeco.ca> From: "Warren W. Gay VE3WWG" User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.0.1) Gecko/20020823 Netscape/7.0 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> <3DEE33A5.8080709@acm.org> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Date: Wed, 04 Dec 2002 12:43:46 -0500 NNTP-Posting-Host: 198.96.47.195 X-Complaints-To: abuse@sympatico.ca X-Trace: news20.bellglobal.com 1039023828 198.96.47.195 (Wed, 04 Dec 2002 12:43:48 EST) NNTP-Posting-Date: Wed, 04 Dec 2002 12:43:48 EST Organization: Bell Sympatico Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!canoe.uoregon.edu!logbridge.uoregon.edu!snoopy.risq.qc.ca!torn!webster!nf1.bellglobal.com!nf2.bellglobal.com!news20.bellglobal.com.POSTED!not-for-mail Xref: archiver1.google.com comp.lang.ada:31436 Date: 2002-12-04T12:43:46-05:00 List-Id: Jeffrey Carter wrote: > Stephen Leake wrote: >> Assuming Lock is a controlled type, that releases the lock in >> Finalize, this [using a semaphore] is an excellent design. > ... > 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. The Rendezvous has the benefit that the request to perform output is queued. This results in greater efficiency on most platforms because it avoids having threads wake up and test to see if they won out on the condition variable set (protected object). It also guarantees "order". With the protected object approach a "Johnnie come lately" task could gain access while already blocked tasks are waiting to gain access -- destroying the waiting line sequence. This may create some confusing to read "output". However, the mutex does have one advantage in this scenario. If you have to perform multiple calls to Text_IO then it makes more sense to lock, perform I/O and then unlock. For example: Lock; New_Line; Put_line("Hello World"); Unlock; You could implement Lock and Unlock using the Rendevous however. -- Warren W. Gay VE3WWG http://home.cogeco.ca/~ve3wwg Need to clean up your PATH or LD_LIBRARY_PATH? Try unique_path at http://home.cogeco.ca/~ve3wwg/unique_path (awk script)