From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: Read-write mutex sometimes fails on deadlock
Date: Wed, 15 Nov 2017 17:05:02 -0600
Date: 2017-11-15T17:05:02-06:00 [thread overview]
Message-ID: <ouih6u$p3b$1@franka.jacob-sparre.dk> (raw)
In-Reply-To: ouigot$h8c$1@franka.jacob-sparre.dk
I wrote:
...
> If the new aspect Nonblocking is used, the delay is statically illegal.
> (That *really* should have been the default, but it took us 20 years to
> figure out the right set of rules -- too late to mandate.)
"New" here means Ada 2020; it was just approved at our most recent ARG
meeting and isn't yet in the draft RM. So it might not be in your favorite
compiler for a while.
The aspect is a big win for most things, as it makes turns the "potentially
nonblocking" rules into static checks, so the portability issues [can you
use Text_IO in a protected object or not?] and "tripping hazards"
(Program_Error being raised unexpectedly) are eliminated.
To show how this works, let's look at the Eachus example using the aspect
Nonblocking:
protected type Mutex
with Nonblocking is
entry Write(D: in Data):
function Read return Data;
private
The_Data: Data := No_Data;
end Mutex;
protected body Mutex is
entry Write (D: in Data) is
begin
The_Data := D;
Some_Data := True;
Print(D); -- Illegal unless Print is declared with Nonblocking = True.
delay 0.1; -- Illegal.
end Write;
function Read return Data is
return The_Data;
end Read;
end Mutex;
So this code only will compile if it is guarenteed to work on all
implementations. (The original code would have raised Program_Error on
Janus/Ada for the delay, Print may or may not have worked.)
Randy.
next prev parent reply other threads:[~2017-11-15 23:05 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-28 20:02 Read-write mutex sometimes fails on deadlock pascal.malaise
2017-11-06 18:24 ` Robert Eachus
2017-11-06 18:31 ` Simon Wright
2017-11-12 4:33 ` Robert Eachus
2017-11-12 5:21 ` J-P. Rosen
2017-11-15 22:57 ` Randy Brukardt
2017-11-15 23:05 ` Randy Brukardt [this message]
2017-11-06 21:01 ` Dmitry A. Kazakov
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox