Version 1.2 of ais/ai-00178.txt
!standard 09.05.01 (18) 99-09-18 AI95-00178/01
!class binding interpretation 97-03-19
!status work item 99-09-18
!status received 97-03-19
!priority Low
!difficulty Medium
!subject Which I/O operations are potentially blocking?
!summary
All subprograms declared in the packages Ada.Stream_IO, Ada.Text_IO or
Ada.Text_IO.Text_Streams are potentially blocking.
All subprograms declared in an instantiation of the generic packages
Ada.Direct_IO or Ada.Sequential_IO are potentially blocking.
Consider the subprograms declared in an instantiation or a nongeneric equivalent
of the generic packages Ada.Text_IO.Complex_IO,
Ada.Wide_Text_IO.Wide_Complex_IO, or of the generic packages declared in the
specification of Ada.Text_IO and Ada.Wide_Text_IO. They are potentially
blocking unless their declaration starts with either:
procedure Put (To : out String; ...
or:
procedure Get (From : in String; ...
The subprograms declared in an instantiation of Ada.Storage_IO are not
potentially blocking.
!question
9.5.1(18) states that "the subprograms of the language-defined input-output
packages that manipulate files (implicitly or explicitly) are potentially
blocking." It is not clear what this means.
1. Is "that manipulate files" meant to modify "subprograms" (in which case
the versions of Put that write to strings are excluded) or "packages" (in
which case these versions of Put might be included, but see #2).
2. Is a subprogram provided by an instance of a generic package nested in
Ada.Text_IO considered a subprogram "of" Ada.Text_IO?
3. Which subprograms are considered to "manipulate files"? Is any
subprogram with a File_Type parameter, plus any counterpart that operates
in the same way on a default file, considered to "manuipulate files", or is
manipulation of files restricted to subprograms that perform what A.8.2
calls "File Management"? Indeed, are the file-management functions that
query properties of an internal file (Mode, Name, Form, Is_Open) considered
to manipulate files?
!recommendation
(See summary.)
!wording
(See summary.)
!discussion
It is clear that any subprogram that calls an operating system service to read
or modify an external file has to be considered potentially blocking, since it
can take an arbitrary amount of time to complete. This includes the file
management operations (Create, Open, Close, etc.) as well as the operation that
read or modify the contents of the file (Read, Write, Flush, etc.). In practice
it is likely that some buffering will take place, and therefore not all
read/write operations will call a system service, but we have to assume the
worst.
There are operations, like Form, Line_Length, etc., which probably don't need to
call any system service, but can merely be implemented by retrieving information
from some data structure associated with the File_Type object. However, for an
implementation that would support concurrent access to internal files, accessing
this data structure would require some synchronization (e.g., to ensure that any
file management operation in progress has completed), and the synchronization
itself would be potentially blocking (for instance it could be implemented by
entry calls).
We don't want to prevent an implementation from supporting concurrent access to
a given file object (although we don't require it; see RM95 A(3)). Moreover,
the capability of calling Form or Line_Length inside a protected operation
doesn't seem too useful. That why we state that all operations that involve
(explicitly or implicitly) File_Type objects are potentially blocking.
The Get and Put procedures that read from/write to a string are different in the
sense that they don't involve any File_Type object. In fact, they have no
relationship whatsoever with I/Os: they are just string manipulation operations.
So it seems that they should behave just like the operations from the string
packages (Ada.Strings.Fixed and the like), and therefore they should not be
potentially blocking.
Similarly, the operations of Ada.Storage_IO only affect in-memory byte strings,
so they should not be potentially blocking.
!appendix
!section 9.5.1(18)
!subject Which I/O operations are potentially blocking?
!reference RM95-9.5.1(18)
!from Norman Cohen
!reference 97-15708.a Norman H. Cohen 97-1-22>>
!discussion
9.5.1(18) states that "the subprograms of the language-defined input-output
packages that manipulate files (implicitly or explicitly) are potentially
blocking." It is not clear what this means.
1. Is "that manipulate files" meant to modify "subprograms" (in which case
the versions of Put that write to strings are excluded) or "packages" (in
which case these versions of Put might be included, but see #2).
2. Is a subprogram provided by an instance of a generic package nested in
Ada.Text_IO considered a subprogram "of" Ada.Text_IO?
3. Which subprograms are considered to "manipulate files"? Is any
subprogram with a File_Type parameter, plus any counterpart that operates
in the same way on a default file, considered to "manuipulate files", or is
manipulation of files restricted to subprograms that perform what A.8.2
calls "File Management"? Indeed, are the file-management functions that
query properties of an internal file (Mode, Name, Form, Is_Open) considered
to manipulate files?
****************************************************************
Questions? Ask the ACAA Technical Agent