<s>
Asynchronous	B-Operating_System
System	I-Operating_System
Trap	I-Operating_System
(	O
AST	O
)	O
refers	O
to	O
a	O
mechanism	O
used	O
in	O
several	O
computer	B-General_Concept
operating	I-General_Concept
systems	I-General_Concept
designed	O
by	O
the	O
former	O
Digital	O
Equipment	O
Corporation	O
(	O
DEC	O
)	O
of	O
Maynard	O
,	O
Massachusetts	O
.	O
</s>
<s>
Various	O
events	O
within	O
these	O
systems	O
can	O
be	O
optionally	O
signalled	B-Operating_System
back	O
to	O
the	O
user	O
processes	O
via	O
the	O
AST	O
mechanism	O
.	O
</s>
<s>
Otherwise	O
,	O
the	O
data	O
must	O
be	O
guarded	O
by	O
blocking	O
ASTs	O
during	O
critical	B-Operating_System
sections	I-Operating_System
.	O
</s>
<s>
ASTs	O
are	O
most	O
commonly	O
encountered	O
as	O
a	O
result	O
of	O
issuing	O
QIO	B-Operating_System
calls	O
to	O
the	O
kernel	B-Operating_System
.	O
</s>
<s>
Completion	O
of	O
the	O
I/O	O
can	O
be	O
signalled	B-Operating_System
by	O
the	O
issuance	O
of	O
an	O
AST	O
to	O
the	O
calling	O
process/task	O
.	O
</s>
<s>
Certain	O
runtime	O
errors	O
could	O
also	O
be	O
signalled	B-Operating_System
using	O
the	O
AST	O
mechanism	O
.	O
</s>
<s>
Within	O
OpenVMS	B-Operating_System
,	O
Special	O
Kernel-Mode	B-Operating_System
ASTs	O
are	O
used	O
as	O
the	O
standard	O
mechanism	O
for	O
getting	O
relatively	O
convenient	O
access	O
to	O
a	O
process	O
context	O
(	O
including	O
getting	O
the	O
process	O
paged	O
into	O
physical	O
memory	O
as	O
may	O
be	O
needed	O
)	O
.	O
</s>
<s>
The	O
following	O
operating	B-General_Concept
systems	I-General_Concept
implement	O
ASTs	O
:	O
</s>
<s>
ASTs	O
are	O
roughly	O
analogous	O
to	O
Unix	B-Operating_System
signals	I-Operating_System
.	O
</s>
<s>
ASTs	O
never	O
abort	B-Operating_System
any	I-Operating_System
system	I-Operating_System
call	I-Operating_System
in	I-Operating_System
progress	I-Operating_System
.	O
</s>
<s>
VAX/VMS	B-Operating_System
V4	O
and	O
later	O
implemented	O
an	O
interesting	O
optimization	O
to	O
the	O
problem	O
of	O
synchronizing	O
between	O
AST-level	O
and	O
non-AST-level	O
code	O
.	O
</s>
<s>
A	O
system	O
service	O
named	O
$SETAST	O
could	O
be	O
used	O
to	O
disable	O
or	O
enable	O
the	O
delivery	O
of	O
ASTs	O
for	O
the	O
current	O
and	O
all	O
less-privileged	O
access	O
modes	O
(	O
the	O
OpenVMS	B-Operating_System
term	O
for	O
ring-based	B-Operating_System
security	O
features	O
)	O
.	O
</s>
<s>
However	O
,	O
if	O
the	O
critical	B-Operating_System
section	I-Operating_System
needing	O
protection	O
from	O
ASTs	O
was	O
only	O
a	O
few	O
instructions	O
long	O
,	O
then	O
the	O
overhead	O
of	O
making	O
the	O
$SETAST	O
calls	O
could	O
far	O
outweigh	O
the	O
time	O
to	O
execute	O
those	O
instructions	O
.	O
</s>
<s>
Instead	O
of	O
the	O
usual	O
pair	O
of	O
$SETAST	O
calls	O
,	O
the	O
user-mode	B-Operating_System
code	O
would	O
set	O
the	O
first	O
flag	O
before	O
executing	O
the	O
sequence	O
of	O
instructions	O
during	O
which	O
ASTs	O
need	O
to	O
be	O
blocked	O
,	O
and	O
clear	O
it	O
after	O
the	O
sequence	O
.	O
</s>
<s>
Then	O
(	O
note	O
the	O
ordering	O
here	O
,	O
to	O
avoid	O
race	B-Operating_System
conditions	I-Operating_System
)	O
it	O
would	O
check	O
the	O
second	O
flag	O
to	O
see	O
if	O
it	O
had	O
become	O
set	O
during	O
this	O
time	O
:	O
if	O
so	O
,	O
then	O
ASTs	O
really	O
have	O
become	O
disabled	O
,	O
and	O
$SETAST	O
should	O
be	O
called	O
to	O
re-enable	O
them	O
.	O
</s>
<s>
The	O
kernel	B-Operating_System
AST	O
delivery	O
code	O
,	O
for	O
its	O
part	O
,	O
would	O
check	O
the	O
first	O
flag	O
before	O
trying	O
to	O
deliver	O
a	O
user-mode	B-Operating_System
AST	O
;	O
if	O
it	O
was	O
set	O
,	O
then	O
it	O
would	O
directly	O
set	O
the	O
ASTs-disabled	O
bit	O
in	O
the	O
process	B-Operating_System
control	I-Operating_System
block	I-Operating_System
(	O
the	O
same	O
bit	O
that	O
would	O
be	O
set	O
by	O
an	O
explicit	O
$SETAST	O
call	O
from	O
user	O
mode	O
)	O
,	O
and	O
also	O
set	O
the	O
second	O
flag	O
,	O
before	O
returning	O
and	O
leaving	O
the	O
AST	O
undelivered	O
.	O
</s>
<s>
The	O
asynchronous	B-Device
procedure	I-Device
call	I-Device
mechanism	O
in	O
the	O
Windows	B-Device
NT	I-Device
family	I-Device
of	O
operating	B-General_Concept
systems	I-General_Concept
is	O
a	O
similar	O
mechanism	O
.	O
</s>
