comp.lang.ada
 help / color / mirror / Atom feed
From: nickroberts@ukf.net (Nick Roberts)
Subject: Re: Complexity of protected objects
Date: Thu, 28 Feb 2002 22:09:28 GMT
Date: 2002-02-28T22:09:28+00:00	[thread overview]
Message-ID: <3c7e7c60.8192226@news.cis.dfn.de> (raw)
In-Reply-To: 3C7A75F2.30503@worldnet.att.net

On Mon, 25 Feb 2002 17:35:45 GMT, Jim Rogers
<jimmaureenrogers@worldnet.att.net> strongly typed:

>Using a protected object to read and write files is a clear
>violation of the intention and recommendations for proctected
>objects. Protected objects should be non-blocking. I/O is
>always potentially blocking.

It's perhaps a little sweeping to say "I/O is always potentially blocking".
There may be certain rare cases where this is not so. But it will certainly
always be so for reading or writing files, in practice.

>You even have some potential blocking issues when storing an
>AVL tree. If you dynamically allocate your AVL tree nodes you
>have the possibility of running out of memory. This will either
>result in a blocking situation, or a potential loss of data
>in the AVL tree.

I would suggest this is being ultra-cautious. In practice, dynamic memory
allocation tends to be considered an 'honourary' non-blocking operation
(even though this does actually fly in the face of the reality). It is
certainly better to avoid any dynamic allocation in a protected subprogram
if you easily can.

Remember, you need to consider the practical consequences of a protected
subprogram being blocked; the RM95 can only say what behaviour is or isn't
guaranteed by all conforming Ada 95 implementations.

In the case of running out of memory (for dynamic allocation), you may
consider this to be a rare event, and a show-stopper anyway, and so not
worth worrying about (in terms of how badly it may obstruct other tasks). I
hasten to add that in some applications this attitude would be reckless.

Consider, for example, virtual memory. Depending on the peculiarities of
the Ada implementation and the target execution environment, it may be that
the execution of a protected subprogram could cause a virtual memory 'page
fault' at any point in its execution. Such page faults will typically cause
I/O activity to occur (to swap a page in, swap a page out, allocate a page
on secondary storage, or whatever). But I/O is 'potentially blocking'.
Disaster! Well no, not really; as long as the 'block' does not last too
long. Similar comments apply to pre-emptive scheduling environments and so
on.

>I would be inclined to use a simple protected buffer object to
>communicate with one or more tasks for the reading and writing,
>and another task to store the AVL tree. Protected operations allow
>you to design a degree of asynchronisity into your system. They are
>not expected to replace tasks for all uses.

Agreed.

Tony Gair wrote:
>>(is this an oxymoron?).

Well, I admire the shapeless solidity of the question.

;-)

-- 
Nick Roberts



  reply	other threads:[~2002-02-28 22:09 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-02-25 16:28 Complexity of protected objects tony gair
2002-02-25 16:45 ` Marin David Condic
2002-03-03  1:11   ` Robert Dewar
2002-03-03  4:13     ` Dale Stanbrough
2002-03-03 19:50       ` Robert Dewar
2002-02-25 17:35 ` Jim Rogers
2002-02-28 22:09   ` Nick Roberts [this message]
2002-02-28 23:32     ` Dale Stanbrough
2002-03-01  5:45       ` Jim Rogers
2002-03-03  0:59       ` Robert Dewar
2002-03-01 17:42     ` Jeffrey Carter
2002-03-03  1:06       ` Robert Dewar
2002-03-03  6:53         ` Jeffrey Carter
2002-03-03 19:36           ` Robert Dewar
2002-03-04 20:04             ` Jeffrey Carter
2002-03-03  0:54     ` Robert Dewar
2002-03-03  0:32   ` Robert Dewar
2002-02-25 22:01 ` Ted Dennison
2002-03-03  1:08   ` Robert Dewar
2002-03-04  9:33     ` Dmitry A. Kazakov
2002-03-04 16:44       ` Ted Dennison
replies disabled

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