comp.lang.ada
 help / color / mirror / Atom feed
From: bobduff@world.std.com (Robert A Duff)
Subject: Re: file locking in Ada
Date: 1997/03/29
Date: 1997-03-29T00:00:00+00:00	[thread overview]
Message-ID: <E7tuD6.4n7@world.std.com> (raw)
In-Reply-To: dewar.859565840@merv


In article <dewar.859565840@merv>, Robert Dewar <dewar@merv.cs.nyu.edu> wrote:
>If you want simulatneous reads and locked writes, an interesting possibility
>is to use a protected type, and use functions for the reads and procedures
>for the writes. Of course your implementation has to allow parallel function
>calls, which many implementations will not bother with.

Where does the RM allow implementations to not bother with parallel
protected function calls?  I know that the intent of the language
designers was to allow both -- one function locks out another, or one
function allows another to run in parallel.  But I don't see where the
RM says so.  It seems possible to write code that detects the difference
-- it might deadlock if a function grabs read/write access, when it
would not deadlock if it only grabs read-only access.  What am I
missing?

There's certainly no general permission to play games with lock.
E.g. if an implementation were to have only a single global lock, which
was used to protect all protected objects (or all PO's at the same
ceiling), that would be wrong.  No, each protected object is supposed to
have its own lock.

>Also, in some implementations, a file read/write might be declared a
>potentially blocking operation and not be permitted.
>
>It is a pity that protected records have these abstraction glitches :-)

This is another issue.  I must admit I have a lot of sympathy for
Robert's opinion on this point.  On the other hand, I can understand the
rationale, given that part of the reason for PO's in the first place,
was to allow extremely efficient implementation of the locking on
embedded no-OS systems.

By the way, the language defined I/O is potentially blocking -- no
implementation definedness about that (see 9.5.1(18)).  What's
implementation defined is whether or not the implementation chooses to
detect that error.  And of course the language doesn't specify anything
about I/O packages that aren't defined in the RM -- e.g. some user's I/O
package that interfaces to the OS directly.

- Bob




  reply	other threads:[~1997-03-29  0:00 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-03-28  0:00 file locking in Ada Neil Goodgame
1997-03-28  0:00 ` Michael F Brenner
1997-03-28  0:00   ` Robert Dewar
1997-03-29  0:00     ` Robert A Duff [this message]
1997-03-29  0:00       ` Robert Dewar
1997-04-01  0:00         ` Robert A Duff
1997-03-29  0:00       ` Robert Dewar
1997-04-01  0:00         ` Robert A Duff
1997-03-28  0:00   ` Larry Kilgallen
1997-03-30  0:00 ` Nick Roberts
replies disabled

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