comp.lang.ada
 help / color / mirror / Atom feed
From: dennison@telepath.com (Ted Dennison)
Subject: Re: Are rendezvous dead?
Date: 15 Apr 2002 07:04:21 -0700
Date: 2002-04-15T14:04:21+00:00	[thread overview]
Message-ID: <4519e058.0204150604.2e65daca@posting.google.com> (raw)
In-Reply-To: 3CB940F7.4EC50CFD@yahoo.com

Anatoly Chernyshev <rhezusfactor@yahoo.com> wrote in message news:<3CB940F7.4EC50CFD@yahoo.com>...
> The question is: are there any practical instances (in Ada 95) when use
> of rendezvous is more advantageous than of protected types? In other
> words, is it worhty of trying to write the code using only protected
> types and completely ignoring rendezvous as possible solution (like the
> GOTO operator)?

I personally find them complementary, not competative with each other.

What you can now do in Ada 95 is use tasks *only* for those entities
that logically contain their own thread of control, without having to
create a lot of extra fluff tasks.

In a multi-threaded algorithm you generally want to have each task
designated as either a client or a server. There are some exceptions,
but it is usually a very bad idea to make a task that tries to be
both.

So what do you do when, as often happens, you have two servers or two
clients that need to communicate with each other? The obvious solution
is to create a "gender-bender" task that does nothing but act as a
client or server and pass the data along. But a whole new task seems a
bit heavy of a solution for such a simple problem, does it not? In
Ada83 there was no other way, so Ada83 tasking programs tended to have
oodles of tasks. But in Ada 95, all you have to do is create a
protected "buffer" or "queue" to handle the communications.

That brings us to the other issue in Ada83 that caused task explosion:
task-safe data types. To do it right, you'd essentially need a
different task too coordinate synchronization for each and every data
object. In a fairly complex system, that could work out to oodles of
synchronization tasks. With protected objects, we no longer need those
sync tasks.

So as a design issue, I think one should generally do the following:

1) Identify the threads of control in your system.
2) Work out which need to be servers and which need to be clients.
3) Identify your server-server and client-client communications (which
you should try to minimise in step 2), and place buffers/queues
between them.
4) Use tasks with rendezvous to implement your servers and clients,
and protected types to implement all buffers, queues, and other
complex data types that are accessed by more than one task.


-- 
T.E.D.
Home     -  mailto:dennison@telepath.com (Yahoo: Ted_Dennison)
Homepage -  http://www.telepath.com/dennison/Ted/TED.html



  parent reply	other threads:[~2002-04-15 14:04 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-04-14  8:42 Are rendezvous dead? Anatoly Chernyshev
2002-04-14 10:55 ` Dmitry A.Kazakov
2002-04-14 14:00 ` Pat Rogers
2002-04-15 13:38   ` Marin David Condic
2002-04-14 19:52 ` Robert Dewar
2002-04-16  8:48   ` John McCabe
2002-04-15 14:04 ` Ted Dennison [this message]
2002-04-15 16:09   ` Jim Rogers
2002-04-15 16:36     ` Jean-Pierre Rosen
replies disabled

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