1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<HTML>
<HEAD>
<TITLE>AARM95 - Abort of a Task - Abort of a Sequence of Statements</TITLE>
<META NAME="Author" CONTENT="JTC1/SC22/WG9/ARG, by Randall Brukardt, ARG Editor">
<META NAME="GENERATOR" CONTENT="Arm_Form.Exe, Ada Reference Manual generator">
<STYLE type="text/css">
DIV.paranum {position: absolute; font-family: Arial, Helvetica, sans-serif; left: 0.5 em; top: auto}
TT {font-family: "Courier New", monospace}
DT {display: compact}
DIV.Normal {font-family: "Times New Roman", Times, serif; margin-bottom: 0.6em}
DIV.Wide {font-family: "Times New Roman", Times, serif; margin-top: 0.6em; margin-bottom: 0.6em}
DIV.Annotations {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-bottom: 0.6em}
DIV.WideAnnotations {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-top: 0.6em; margin-bottom: 0.6em}
DIV.Index {font-family: "Times New Roman", Times, serif}
DIV.SyntaxSummary {font-family: "Times New Roman", Times, serif; margin-left: 2.0em; margin-bottom: 0.4em}
DIV.Notes {font-family: "Times New Roman", Times, serif; margin-left: 2.0em; margin-bottom: 0.6em}
DIV.NotesHeader {font-family: "Times New Roman", Times, serif; margin-left: 2.0em}
DIV.SyntaxIndented {font-family: "Times New Roman", Times, serif; margin-left: 2.0em; margin-bottom: 0.4em}
DIV.Indented {font-family: "Times New Roman", Times, serif; margin-left: 6.0em; margin-bottom: 0.6em}
DIV.CodeIndented {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-bottom: 0.6em}
DIV.SmallIndented {font-family: "Times New Roman", Times, serif; margin-left: 10.0em; margin-bottom: 0.6em}
DIV.SmallCodeIndented {font-family: "Times New Roman", Times, serif; margin-left: 8.0em; margin-bottom: 0.6em}
DIV.Examples {font-family: "Courier New", monospace; margin-left: 2.0em; margin-bottom: 0.6em}
DIV.SmallExamples {font-family: "Courier New", monospace; font-size: 80%; margin-left: 7.5em; margin-bottom: 0.6em}
DIV.IndentedExamples {font-family: "Courier New", monospace; margin-left: 8.0em; margin-bottom: 0.6em}
DIV.SmallIndentedExamples {font-family: "Courier New", monospace; font-size: 80%; margin-left: 15.0em; margin-bottom: 0.6em}
UL.Bulleted {font-family: "Times New Roman", Times, serif; margin-left: 2.0em; margin-right: 2.0em; margin-top: 0em; margin-bottom: 0.5em}
UL.SmallBulleted {font-family: "Times New Roman", Times, serif; margin-left: 6.0em; margin-right: 6.0em; margin-top: 0em; margin-bottom: 0.5em}
UL.NestedBulleted {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-right: 4.0em; margin-top: 0em; margin-bottom: 0.5em}
UL.SmallNestedBulleted {font-family: "Times New Roman", Times, serif; margin-left: 8.0em; margin-right: 8.0em; margin-top: 0em; margin-bottom: 0.5em}
UL.IndentedBulleted {font-family: "Times New Roman", Times, serif; margin-left: 8.0em; margin-right: 8.0em; margin-top: 0em; margin-bottom: 0.5em}
UL.CodeIndentedBulleted {font-family: "Times New Roman", Times, serif; margin-left: 6.0em; margin-right: 6.0em; margin-top: 0em; margin-bottom: 0.5em}
UL.CodeIndentedNestedBulleted {font-family: "Times New Roman", Times, serif; margin-left: 8.0em; margin-right: 8.0em; margin-top: 0em; margin-bottom: 0.5em}
UL.SyntaxIndentedBulleted {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-right: 4.0em; margin-top: 0em; margin-bottom: 0.5em}
UL.NotesBulleted {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-right: 4.0em; margin-top: 0em; margin-bottom: 0.5em}
UL.NotesNestedBulleted {font-family: "Times New Roman", Times, serif; margin-left: 6.0em; margin-right: 6.0em; margin-top: 0em; margin-bottom: 0.5em}
DL.Hanging {font-family: "Times New Roman", Times, serif; margin-top: 0em; margin-bottom: 0.6em}
DD.Hanging {margin-left: 6.0em}
DL.IndentedHanging {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-top: 0em; margin-bottom: 0.6em}
DD.IndentedHanging {margin-left: 2.0em}
DL.HangingInBulleted {font-family: "Times New Roman", Times, serif; margin-left: 2.0em; margin-right: 2.0em; margin-top: 0em; margin-bottom: 0.5em}
DD.HangingInBulleted {margin-left: 4.0em}
DL.SmallHanging {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-top: 0em; margin-bottom: 0.6em}
DD.SmallHanging {margin-left: 7.5em}
DL.SmallIndentedHanging {font-family: "Times New Roman", Times, serif; margin-left: 8.0em; margin-top: 0em; margin-bottom: 0.6em}
DD.SmallIndentedHanging {margin-left: 2.0em}
DL.SmallHangingInBulleted {font-family: "Times New Roman", Times, serif; margin-left: 6.0em; margin-right: 6.0em; margin-top: 0em; margin-bottom: 0.5em}
DD.SmallHangingInBulleted {margin-left: 5.0em}
DL.Enumerated {font-family: "Times New Roman", Times, serif; margin-right: 0.0em; margin-top: 0em; margin-bottom: 0.5em}
DD.Enumerated {margin-left: 2.0em}
DL.SmallEnumerated {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-right: 4.0em; margin-top: 0em; margin-bottom: 0.5em}
DD.SmallEnumerated {margin-left: 2.5em}
DL.NestedEnumerated {font-family: "Times New Roman", Times, serif; margin-left: 2.0em; margin-right: 2.0em; margin-top: 0em; margin-bottom: 0.5em}
DL.SmallNestedEnumerated {font-family: "Times New Roman", Times, serif; margin-left: 6.0em; margin-right: 6.0em; margin-top: 0em; margin-bottom: 0.5em}
</STYLE>
</HEAD>
<BODY TEXT="#000000" BGCOLOR="#FFFFF0" LINK="#0000FF" VLINK="#800080" ALINK="#FF0000">
<P><A HREF="AA-TOC.html">Contents</A> <A HREF="AA-0-29.html">Index</A> <A HREF="AA-9-7-4.html">Previous</A> <A HREF="AA-9-9.html">Next</A></P>
<HR>
<H1> 9.8 Abort of a Task - Abort of a Sequence of Statements</H1>
<DIV Class="Paranum"><FONT SIZE=-2>1</FONT></DIV>
<DIV Class="Normal"> [An <FONT FACE="Arial, Helvetica">abort_statement</FONT>
causes one or more tasks to become abnormal, thus preventing any further
interaction with such tasks. The completion of the <FONT FACE="Arial, Helvetica">triggering_statement</FONT>
of an <FONT FACE="Arial, Helvetica">asynchronous_select</FONT> causes
a <FONT FACE="Arial, Helvetica">sequence_of_statements</FONT> to be aborted.]
</DIV>
<H4 ALIGN=CENTER>Syntax</H4>
<DIV Class="Paranum"><FONT SIZE=-2>2</FONT></DIV>
<DIV Class="SyntaxIndented"><FONT FACE="Arial, Helvetica">abort_statement<A NAME="I3804"></A>
::= </FONT><B>abort</B> <I>task_</I><A NAME="I3805"></A><FONT FACE="Arial, Helvetica">name</FONT> {, <I>task_</I><A NAME="I3806"></A><FONT FACE="Arial, Helvetica">name</FONT>};</DIV>
<H4 ALIGN=CENTER>Name Resolution Rules</H4>
<DIV Class="Paranum"><FONT SIZE=-2>3</FONT></DIV>
<DIV Class="Normal"> <A NAME="I3807"></A>Each <I>task_</I><FONT FACE="Arial, Helvetica">name</FONT>
is expected to be of any task type[; they need not all be of the same
task type.]</DIV>
<H4 ALIGN=CENTER>Dynamic Semantics</H4>
<DIV Class="Paranum"><FONT SIZE=-2>4</FONT></DIV>
<DIV Class="Normal"> <A NAME="I3808"></A>For the execution of an <FONT FACE="Arial, Helvetica">abort_statement</FONT>,
the given <I>task_</I><FONT FACE="Arial, Helvetica">name</FONT>s are
evaluated in an arbitrary order. <A NAME="I3809"></A><A NAME="I3810"></A><A NAME="I3811"></A>Each
named task is then <I>aborted</I>, which consists of making the task
<I>abnormal</I> and aborting the execution of the corresponding <FONT FACE="Arial, Helvetica">task_body</FONT>,
unless it is already completed. </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>4.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Ramification: </B>Note that
aborting those tasks is not defined to be an abort-deferred operation.
Therefore, if one of the named tasks is the task executing the <FONT FACE="Arial, Helvetica">abort_statement</FONT>,
or if the task executing the <FONT FACE="Arial, Helvetica">abort_statement</FONT>
depends on one of the named tasks, then it is possible for the execution
of the <FONT FACE="Arial, Helvetica">abort_statement</FONT> to be aborted,
thus leaving some of the tasks unaborted. This allows the implementation
to use either a sequence of calls to an ``abort task'' RTS primitive,
or a single call to an ``abort list of tasks'' RTS primitive. </FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>5</FONT></DIV>
<DIV Class="Normal" Style="margin-bottom: 0.4em"> <A NAME="I3812"></A><A NAME="I3813"></A>When
the execution of a construct is <I>aborted</I> (including that of a <FONT FACE="Arial, Helvetica">task_body</FONT>
or of a <FONT FACE="Arial, Helvetica">sequence_of_statements</FONT>),
the execution of every construct included within the aborted execution
is also aborted, except for executions included within the execution
of an <I>abort-deferred</I> operation; the execution of an abort-deferred
operation continues to completion without being affected by the abort;
<A NAME="I3814"></A>the following are the abort-deferred operations:
</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>6</FONT></DIV>
<UL Class="Bulleted"><LI TYPE=DISC>a protected action;</LI></UL>
<DIV Class="Paranum"><FONT SIZE=-2>7</FONT></DIV>
<UL Class="Bulleted"><LI TYPE=DISC>waiting for an entry call to complete (after having initiated
the attempt to cancel it -- see below);</LI></UL>
<DIV Class="Paranum"><FONT SIZE=-2>8</FONT></DIV>
<UL Class="Bulleted"><LI TYPE=DISC>waiting for the termination of dependent tasks;</LI></UL>
<DIV Class="Paranum"><FONT SIZE=-2>9</FONT></DIV>
<UL Class="Bulleted"><LI TYPE=DISC>the execution of an Initialize procedure as the last step
of the default initialization of a controlled object;</LI></UL>
<DIV Class="Paranum"><FONT SIZE=-2>10</FONT></DIV>
<UL Class="Bulleted"><LI TYPE=DISC>the execution of a Finalize procedure as part of the finalization
of a controlled object;</LI></UL>
<DIV Class="Paranum"><FONT SIZE=-2>11</FONT></DIV>
<UL Class="Bulleted"><LI TYPE=DISC>an assignment operation to an object with a controlled
part. </LI></UL>
<DIV Class="Paranum"><FONT SIZE=-2>12</FONT></DIV>
<DIV Class="Normal"> [The last three of these are discussed further
in <A HREF="AA-7-6.html">7.6</A>.] </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>12.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Reason: </B>Deferring abort
during Initialize and finalization allows, for example, the result of
an allocator performed in an Initialize operation to be assigned into
an access object without being interrupted in the middle, which would
cause storage leaks. For an object with several controlled parts, each
individual Initialize is abort-deferred. Note that there is generally
no semantic difference between making each Finalize abort-deferred, versus
making a group of them abort-deferred, because if the task gets aborted,
the first thing it will do is complete any remaining finalizations. Individual
objects are finalized prior to an assignment operation (if nonlimited
controlled) and as part of Unchecked_Deallocation. </FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>12.b</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Ramification: </B>Abort is
deferred during the entire assignment operation to an object with a controlled
part, even if only some subcomponents are controlled. Note that this
says "assignment operation," not "<FONT FACE="Arial, Helvetica">assignment_statement</FONT>."
Explicit calls to Initialize, Finalize, or Adjust are not abort-deferred.
</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>13</FONT></DIV>
<DIV Class="Normal"> When a master is aborted, all tasks that depend
on that master are aborted.</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>14</FONT></DIV>
<DIV Class="Normal"> <A NAME="I3815"></A>The order in which tasks
become abnormal as the result of an <FONT FACE="Arial, Helvetica">abort_statement</FONT>
or the abort of a <FONT FACE="Arial, Helvetica">sequence_of_statements</FONT>
is not specified by the language.</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>15</FONT></DIV>
<DIV Class="Normal" Style="margin-bottom: 0.4em"> If the execution
of an entry call is aborted, an immediate attempt is made to cancel the
entry call (see <A HREF="AA-9-5-3.html">9.5.3</A>). If the execution
of a construct is aborted at a time when the execution is blocked, other
than for an entry call, at a point that is outside the execution of an
abort-deferred operation, then the execution of the construct completes
immediately. For an abort due to an <FONT FACE="Arial, Helvetica">abort_statement</FONT>,
these immediate effects occur before the execution of the <FONT FACE="Arial, Helvetica">abort_statement</FONT>
completes. Other than for these immediate cases, the execution of a construct
that is aborted does not necessarily complete before the <FONT FACE="Arial, Helvetica">abort_statement</FONT>
completes. However, the execution of the aborted construct completes
no later than its next <I>abort completion point</I> (if any) that occurs
outside of an abort-deferred operation; <A NAME="I3816"></A>the following
are abort completion points for an execution: </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>16</FONT></DIV>
<UL Class="Bulleted"><LI TYPE=DISC>the point where the execution initiates the activation
of another task;</LI></UL>
<DIV Class="Paranum"><FONT SIZE=-2>17</FONT></DIV>
<UL Class="Bulleted"><LI TYPE=DISC>the end of the activation of a task;</LI></UL>
<DIV Class="Paranum"><FONT SIZE=-2>18</FONT></DIV>
<UL Class="Bulleted"><LI TYPE=DISC>the start or end of the execution of an entry call, <FONT FACE="Arial, Helvetica">accept_statement</FONT>,
<FONT FACE="Arial, Helvetica">delay_statement</FONT>, or <FONT FACE="Arial, Helvetica">abort_statement</FONT>;
</LI></UL>
<DIV Class="Paranum"><FONT SIZE=-2>18.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Ramification: </B>Although
the abort completion point doesn't occur until the end of the entry call
or <FONT FACE="Arial, Helvetica">delay_statement</FONT>, these operations
might be cut short because an abort attempts to cancel them. </FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>19</FONT></DIV>
<UL Class="Bulleted"><LI TYPE=DISC>the start of the execution of a <FONT FACE="Arial, Helvetica">select_statement</FONT>,
or of the <FONT FACE="Arial, Helvetica">sequence_of_statements</FONT>
of an <FONT FACE="Arial, Helvetica">exception_handler</FONT>. </LI></UL>
<DIV Class="Paranum"><FONT SIZE=-2>19.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Reason: </B>The start of an
<FONT FACE="Arial, Helvetica">exception_handler</FONT> is considered
an abort completion point simply because it is easy for an implementation
to check at such points. </FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>19.b</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Implementation Note: </B>Implementations
may of course check for abort more often than at each abort completion
point; ideally, a fully preemptive implementation of abort will be provided.
If preemptive abort is not supported in a given environment, then supporting
the checking for abort as part of subprogram calls and loop iterations
might be a useful option. </FONT></DIV>
<H4 ALIGN=CENTER>Bounded (Run-Time) Errors</H4>
<DIV Class="Paranum"><FONT SIZE=-2>20</FONT></DIV>
<DIV Class="Normal"> <A NAME="I3817"></A>An attempt to execute an
<FONT FACE="Arial, Helvetica">asynchronous_select</FONT> as part of the
execution of an abort-deferred operation is a bounded error. Similarly,
an attempt to create a task that depends on a master that is included
entirely within the execution of an abort-deferred operation is a bounded
error. <A NAME="I3818"></A>In both cases, Program_Error is raised if
the error is detected by the implementation; otherwise the operations
proceed as they would outside an abort-deferred operation, except that
an abort of the <FONT FACE="Arial, Helvetica">abortable_part</FONT> or
the created task might or might not have an effect. </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>20.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Reason: </B>An <FONT FACE="Arial, Helvetica">asynchronous_select</FONT>
relies on an abort of the <FONT FACE="Arial, Helvetica">abortable_part</FONT>
to effect the asynchronous transfer of control. For an <FONT FACE="Arial, Helvetica">asynchronous_select</FONT>
within an abort-deferred operation, the abort might have no effect.</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>20.b</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1>Creating a task dependent on a
master included within an abort-deferred operation is considered an error,
because such tasks could be aborted while the abort-deferred operation
was still progressing, undermining the purpose of abort-deferral. Alternatively,
we could say that such tasks are abort-deferred for their entire execution,
but that seems too easy to abuse. Note that task creation is already
a bounded error in protected actions, so this additional rule only applies
to local task creation as part of Initialize, Finalize, or Adjust. </FONT></DIV>
<H4 ALIGN=CENTER>Erroneous Execution</H4>
<DIV Class="Paranum"><FONT SIZE=-2>21</FONT></DIV>
<DIV Class="Normal"> <A NAME="I3819"></A><A NAME="I3820"></A><A NAME="I3821"></A><A NAME="I3822"></A>If
an assignment operation completes prematurely due to an abort, the assignment
is said to be <I>disrupted</I>; the target of the assignment or its parts
can become abnormal, and certain subsequent uses of the object can be
erroneous, as explained in <A HREF="AA-13-9-1.html">13.9.1</A>. </DIV>
<DIV Class="NotesHeader"><FONT SIZE=-1>NOTES</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>22</FONT></DIV>
<DIV Class="Notes"><FONT SIZE=-1>38 An <FONT FACE="Arial, Helvetica">abort_statement</FONT>
should be used only in situations requiring unconditional termination.</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>23</FONT></DIV>
<DIV Class="Notes"><FONT SIZE=-1>39 A task is allowed to abort
any task it can name, including itself.</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>24</FONT></DIV>
<DIV Class="Notes"><FONT SIZE=-1>40 Additional requirements
associated with abort are given in <A HREF="AA-D-6.html">D.6</A>, ``<A HREF="AA-D-6.html">Preemptive
Abort</A>''. </FONT></DIV>
<H4 ALIGN=CENTER>Wording Changes from Ada 83</H4>
<DIV Class="Paranum"><FONT SIZE=-2>24.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1>This clause has been rewritten
to accommodate the concept of aborting the execution of a construct,
rather than just of a task. </FONT></DIV>
<HR>
<P><A HREF="AA-TOC.html">Contents</A> <A HREF="AA-0-29.html">Index</A> <A HREF="AA-9-7-4.html">Previous</A> <A HREF="AA-9-9.html">Next</A> <A HREF="AA-TTL.html">Legal</A></P>
</BODY>
</HTML>
|