comp.lang.ada
 help / color / mirror / Atom feed
From: mazzanti@iei.pi.cnr.it (Franco Mazzanti)
Subject: Re: Unbounded strings (Was: Java vs Ada 95 (Was Re: Once again, Ada absent from DoD SBIR solicitation))
Date: 1996/11/25
Date: 1996-11-25T00:00:00+00:00	[thread overview]
Message-ID: <mazzanti-2511961115230001@131.114.200.115> (raw)


Robert A. Duff wrote:

">And of course it is quite clear that two writes to the same file using
 >Put_Line with a file argument are NOT covered by paragraph 3. So that's
 >mightly curious:
  >
 >    Put_Line (Standard_Output, "xxxx");
 >
 >appearing in two tasks is not covered, and could be erroneous, but
 >
 >    Put_Line ("xxxx");
 >
 >is OK. That seems quite weird to me, ...

 Agreed.  In my opinion, both of the above should be considered
 erroneous.  I said that in another article, and I also admitted that the
 RM doesn't clearly say so.  As you say, if one thinks the above should
 work, then one needs to worry about the granularity of interleaving."


I know I am an heretic for my views on this subject. 

However I think that it is quite incorrect to consider "Standard_Output"
as a shared variable. "Standard_Output" is a function call, and it very likely
to return an anonymous temporary object. AT least this is what one would
expect by reading the RM (unless File_Type is a "return-by-reference" type).

Only if we make use of the version of "Standard_Output" which returns a
"File_Access" object, then in two concurrent calls of

   Put_Line (Standard_Output.all, "xxxx"); 

we would really use a shared variable.

However, even in this case, the erroneousnees is not clearly implied by the
reference manual because the File_Type argument has mode IN. So, we have
sharing, but this sharing is safe because it is "read only".

The picture which the RM naturally provides (at least to a naive reader) is
the only two concurrent Close, Delete, Reset, Flush operations on the same
File_Type variable are erroneous for 9.10 (or the execution of any of
these
operations bin parallel with a Get_Line, Put_Line, ...) because these 
operations actually take a File_Type parameter of mode IN OUT.

I agree that some attributes associated to file objects are modified by get 
and put operations (file position information). However, this kind of data
is completely outside the user view, is part of the underlying implementation
of the I/O system and A(3) seem really to imply that concurrent calls of
Put_line should be thread-safe.

With the respect to the granularity of the interleaving, I do not think that
one needs to worry about it. 
Once it is stated clearly that the effects of Put_line need not be atomic 
(with respect to the externel effect and the update of the file position
attributes) it is perfectly acceptable that the EXTERNAL effect of two 
put_line operations results in some unspecified interleaving of the data.

But this is very different from allowing the concurrent execution of even 
the operations:

   Put_Line(My_file, "my-string");
   V:Count := Col(F);

to be erroneous and "thrash my hard disk".

Franco Mazzanti




             reply	other threads:[~1996-11-25  0:00 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-11-25  0:00 Franco Mazzanti [this message]
1996-11-25  0:00 ` Unbounded strings (Was: Java vs Ada 95 (Was Re: Once again, Ada absent from DoD SBIR solicitation)) Robert A Duff
  -- strict thread matches above, loose matches on Subject: below --
1996-10-09  0:00 Once again, Ada absent from DoD SBIR solicitation Stanley R. Allen
1996-11-14  0:00 ` Java vs Ada 95 (Was Re: Once again, Ada absent from DoD SBIR solicitation) Robert Dewar
1996-11-16  0:00   ` Robert A Duff
1996-11-16  0:00     ` Robert Dewar
1996-11-17  0:00       ` Unbounded strings (Was: Java vs Ada 95 (Was Re: Once again, Ada absent from DoD SBIR solicitation)) Robert A Duff
1996-11-18  0:00         ` Robert Dewar
1996-11-19  0:00           ` Robert A Duff
1996-11-23  0:00             ` Robert Dewar
1996-11-24  0:00               ` Robert A Duff
1996-11-25  0:00               ` Norman H. Cohen
1996-11-27  0:00                 ` Robert Dewar
1996-11-19  0:00           ` Joel VanLaven
1996-11-23  0:00             ` Robert Dewar
1996-11-21  0:00         ` Robert I. Eachus
1996-11-24  0:00           ` Robert Dewar
1996-11-24  0:00             ` Fergus Henderson
1996-11-24  0:00               ` Robert Dewar
1996-11-25  0:00             ` Kevin D. Heatwole
1996-11-25  0:00               ` Robert A Duff
1996-11-26  0:00                 ` Kevin D. Heatwole
1996-11-26  0:00                   ` Robert A Duff
1996-11-26  0:00                     ` Larry Kilgallen
1996-11-27  0:00                     ` Norman H. Cohen
1996-11-29  0:00                       ` Fergus Henderson
1996-11-29  0:00                       ` Robert A Duff
1996-11-27  0:00                     ` Robert Dewar
1996-11-26  0:00               ` Geert Bosch
1996-11-26  0:00                 ` Robert Dewar
1996-11-25  0:00         ` Robert I. Eachus
1996-11-20  0:00       ` Jon S Anthony
1996-11-24  0:00         ` Robert Dewar
replies disabled

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