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-Thread: 103376,9b794838d82ee7c3 X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII Path: g2news1.google.com!news2.google.com!news1.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!nx01.iad01.newshosting.com!newshosting.com!newsfeed.icl.net!newsfeed.fjserv.net!oleane.net!oleane!hunter.axlog.fr!nobody From: Jean-Pierre Rosen Newsgroups: comp.lang.ada Subject: Re: Task vs Protected Type Date: Fri, 30 May 2008 17:15:25 +0200 Organization: Adalog Message-ID: References: NNTP-Posting-Host: mailhost.axlog.fr Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit X-Trace: s1.news.oleane.net 1212160028 8875 195.25.228.57 (30 May 2008 15:07:08 GMT) X-Complaints-To: abuse@oleane.net NNTP-Posting-Date: Fri, 30 May 2008 15:07:08 +0000 (UTC) User-Agent: Thunderbird 2.0.0.14 (Windows/20080421) In-Reply-To: Xref: g2news1.google.com comp.lang.ada:484 Date: 2008-05-30T17:15:25+02:00 List-Id: S�bastien a �crit : [...] > The first one has the advantage to force the user to Initialize the task > because of the first entry, but there is no such mechanism in the > protected type. The value of the mutex is given by the discriminant, no initialization needed. > So in the wikibook, there is this sentence: > "Alternatively, semaphore functionality can be provided by a protected > object, with major efficiency gains." This is likely true on a bare board, I would be more careful when running under a conventional OS. > For example, you have a web application and want to develop an object > pool. You could use one of both example, since it's the same purpose > with some GetObject and ReleaseObject enties/procedure in a task or in a > protected. But which one is the better approach? > A task is a high level structure, a protected type is a low level synchronization mechanism. However, implementing a low level mechanism (like a semaphore) with a task is certainly abstraction inversion. OTOH, if you use rendezvous, you can avoid semaphores altogether (in general of course, YMMV). -- --------------------------------------------------------- J-P. Rosen (rosen@adalog.fr) Visit Adalog's web site at http://www.adalog.fr