comp.lang.ada
 help / color / mirror / Atom feed
From: Jean-Pierre Rosen <rosen@adalog.fr>
Subject: Re: Task vs Protected Type
Date: Fri, 30 May 2008 17:15:25 +0200
Date: 2008-05-30T17:15:25+02:00	[thread overview]
Message-ID: <nm5p1g.2c5.ln@hunter.axlog.fr> (raw)
In-Reply-To: <g1p214$296$1@registered.motzarella.org>

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



  parent reply	other threads:[~2008-05-30 15:15 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-05-30 14:12 Task vs Protected Type Sébastien
2008-05-30 14:33 ` Dmitry A. Kazakov
2008-05-30 16:09   ` Sébastien
2008-05-30 15:15 ` Jean-Pierre Rosen [this message]
2008-05-30 17:30 ` Jeffrey R. Carter
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox