<s>
This	O
article	O
covers	O
the	O
specific	O
instruction	O
on	O
the	O
IBM	B-Application
System/360	I-Application
and	O
successor	O
mainframe	B-Architecture
computers	I-Architecture
,	O
and	O
compatible	O
machines	O
.	O
</s>
<s>
For	O
the	O
general	O
concept	O
of	O
an	O
instruction	O
for	O
issuing	O
calls	O
to	O
an	O
operating	B-General_Concept
system	I-General_Concept
,	O
see	O
System	B-Operating_System
call	I-Operating_System
.	O
</s>
<s>
A	O
Supervisor	B-Operating_System
Call	I-Operating_System
instruction	I-Operating_System
(	O
SVC	O
)	O
is	O
a	O
hardware	O
instruction	O
used	O
by	O
the	O
System/360	B-Application
family	O
of	O
IBM	B-Device
mainframe	I-Device
computers	O
up	O
to	O
contemporary	O
zSeries	O
,	O
the	O
Amdahl	O
470V/5	O
,	O
470V/6	O
,	O
470V/7	O
,	O
470V/8	O
,	O
580	O
,	O
5880	O
,	O
5990M	O
,	O
and	O
5990A	O
,	O
and	O
others	O
;	O
Univac	B-Device
90/60	I-Device
,	O
90/70	O
and	O
90/80	O
,	O
and	O
possibly	O
others	O
;	O
the	O
Fujitsu	O
M180	O
(	O
UP	O
)	O
and	O
M200	O
(	O
MP	O
)	O
,	O
and	O
others	O
;	O
and	O
is	O
also	O
used	O
in	O
the	O
Hercules	B-Application
open	O
source	O
mainframe	B-Architecture
emulation	O
software	O
.	O
</s>
<s>
It	O
causes	O
an	O
interrupt	O
to	O
request	O
a	O
service	O
from	O
the	O
operating	B-General_Concept
system	I-General_Concept
.	O
</s>
<s>
SVC	O
is	O
a	O
system	B-Operating_System
call	I-Operating_System
.	O
</s>
<s>
IBM	B-Device
mainframes	I-Device
in	O
the	O
System/360	B-Application
and	O
successor	O
families	O
operate	O
in	O
one	O
of	O
two	O
states	O
:	O
problem	O
state	O
or	O
supervisor	O
state	O
and	O
in	O
one	O
of	O
sixteen	O
storage	O
access	O
keys	O
(	O
0	O
to	O
15	O
)	O
.	O
</s>
<s>
A	O
program	O
is	O
only	O
allowed	O
to	O
access	O
specific	O
supervisory	O
functions	O
after	O
thorough	O
authorization	O
checking	O
by	O
the	O
operating	B-General_Concept
system	I-General_Concept
:	O
DEBCHK	O
(	O
SVC	O
117	O
)	O
,	O
TESTAUTH	O
(	O
SVC	O
119	O
)	O
,	O
and	O
possibly	O
additional	O
tests	O
.	O
</s>
<s>
Some	O
of	O
these	O
tests	O
were	O
not	O
available	O
in	O
OS/360	B-Application
,	O
but	O
were	O
added	O
in	O
OS/VS1	B-Application
,	O
SVS	B-Application
or	O
MVS/370	O
,	O
but	O
all	O
were	O
available	O
in	O
MVS/370	O
or	O
subsequent	O
releases	O
,	O
and	O
are	O
still	O
available	O
to	O
this	O
day	O
.	O
</s>
<s>
In	O
OS/VS1	B-Application
,	O
OS/VS2	B-Application
(	O
SVS	B-Application
)	O
,	O
MVS/370	O
and	O
subsequent	O
versions	O
of	O
the	O
OS	O
,	O
the	O
MODESET	O
function	O
(	O
SVC	O
107	O
)	O
obviated	O
the	O
need	O
for	O
many	O
user-written	O
SVCs	O
as	O
this	O
system	O
SVC	O
accommodated	O
both	O
changes	O
in	O
mode	O
(	O
problem	O
state	O
to	O
supervisor	O
state	O
)	O
and	O
key	O
(	O
8-15	O
[	O
user	O
]	O
to	O
0-7	O
[	O
system	O
]	O
)	O
in	O
a	O
single	O
operation	O
,	O
and	O
many	O
user-written	O
SVCs	O
were	O
originally	O
intended	O
for	O
simple	O
mode	O
and	O
key	O
changes	O
,	O
anyway	O
,	O
and	O
subsequently	O
the	O
only	O
special	O
requirement	O
was	O
that	O
the	O
jobstep	O
be	O
APF	O
authorized	O
and	O
that	O
the	O
MODESET-invoking	O
program	O
be	O
resident	O
in	O
a	O
concatenation	O
of	O
libraries	O
all	O
of	O
which	O
were	O
identified	O
as	O
authorized	O
,	O
and	O
this	O
secure	O
approach	O
was	O
completely	O
under	O
the	O
installation	O
's	O
control	O
.	O
</s>
<s>
Although	O
mainframe	B-Architecture
applications	O
are	O
typically	O
synchronous	O
processes	O
,	O
the	O
operating	B-General_Concept
system	I-General_Concept
itself	O
is	O
naturally	O
asynchronous	O
,	O
although	O
the	O
system	O
also	O
supports	O
many	O
processes	O
which	O
are	O
naturally	O
synchronous	O
.	O
</s>
<s>
When	O
an	O
application	O
requests	O
a	O
system	O
service	O
which	O
is	O
naturally	O
asynchronous	O
,	O
such	O
as	O
input/output	O
processing	O
,	O
a	O
mechanism	O
for	O
synchronizing	O
the	O
application	O
and	O
the	O
operating	B-General_Concept
system	I-General_Concept
must	O
be	O
employed	O
.	O
</s>
<s>
This	O
essential	O
mechanism	O
is	O
through	O
functions	O
which	O
are	O
built	O
into	O
the	O
operating	B-General_Concept
system	I-General_Concept
,	O
or	O
are	O
specifically	O
supported	O
by	O
it	O
,	O
including	O
:	O
WAIT	O
(	O
temporarily	O
halt	O
application	O
processing	O
until	O
an	O
external	O
event	O
has	O
occurred	O
)	O
;	O
POST	O
(	O
indicate	O
occurrence	O
of	O
an	O
external	O
event	O
so	O
application	O
processing	O
may	O
continue	O
)	O
;	O
and	O
SYNCH	O
(	O
change	O
system	O
processing	O
mode	O
—	O
supervisor	O
to	O
user	O
and	O
system	O
key	O
to	O
user	O
key	O
—	O
while	O
preserving	O
system	O
integrity	O
,	O
and	O
synchronously	O
perform	O
a	O
function	O
on	O
behalf	O
of	O
the	O
application	O
,	O
after	O
which	O
supervisor	O
processing	O
may	O
continue	O
)	O
.	O
</s>
<s>
The	O
OS/360	B-Application
SVCs	O
table	O
below	O
indicates	O
the	O
conditions	O
under	O
which	O
these	O
synchronizing	O
facilities	O
may	O
be	O
employed	O
.	O
</s>
<s>
SVC	O
is	O
a	O
two	O
byte	O
instruction	O
with	O
the	O
hexadecimal	O
operation	B-Language
code	I-Language
;	O
the	O
second	O
byte	O
of	O
the	O
instruction	O
,	O
the	O
SVC	O
number	O
,	O
indicates	O
the	O
specific	O
request	O
.	O
</s>
<s>
The	O
SVC	O
number	O
can	O
be	O
any	O
value	O
from	O
0	O
to	O
255	O
,	O
with	O
the	O
particular	O
SVC	O
number	O
being	O
up	O
to	O
the	O
implementer	O
of	O
the	O
operating	B-General_Concept
system	I-General_Concept
,	O
e.g.	O
</s>
<s>
on	O
IBM	O
's	O
MVS	O
,	O
SVC	O
3	O
is	O
used	O
to	O
terminate	O
a	O
program	O
,	O
while	O
on	O
the	O
UNIVAC	O
VS/9	O
and	O
Fujitsu	O
BS2000	O
operating	B-General_Concept
systems	I-General_Concept
,	O
SVC	O
9	O
was	O
used	O
for	O
the	O
same	O
purpose	O
.	O
</s>
<s>
The	O
PSW	O
,	O
an	O
8-byte	O
(	O
on	O
the	O
System	B-Application
360	I-Application
and	O
S/370	O
)	O
or	O
16	O
byte	O
(	O
on	O
the	O
z/System	O
)	O
,	O
privileged	O
register	O
containing	O
,	O
among	O
other	O
things	O
,	O
the	O
current	O
address	O
of	O
the	O
instruction	O
to	O
be	O
executed	O
,	O
the	O
privilege	O
bit	O
(	O
1	O
if	O
privileged	O
)	O
,	O
and	O
storage	O
key	O
,	O
is	O
saved	O
at	O
a	O
real	O
address	O
.	O
</s>
<s>
Bits	O
24-31	O
of	O
the	O
saved	O
PSW	O
(	O
real	O
address	O
35	O
on	O
the	O
360	O
and	O
370	O
,	O
323	O
on	O
the	O
z/System	O
)	O
contain	O
the	O
Supervisor	B-Operating_System
call	I-Operating_System
number	O
.	O
</s>
<s>
SVC	O
invokes	O
a	O
supervisory	O
functionusually	O
implemented	O
as	O
a	O
"	O
closed	O
subroutine	O
"	O
of	O
the	O
system	O
's	O
SVC	O
interrupt	B-General_Concept
handler	I-General_Concept
.	O
</s>
<s>
Information	O
passed	O
to	O
and	O
from	O
the	O
SVC	O
routines	O
is	O
passed	O
in	O
general	B-General_Concept
purpose	I-General_Concept
registers	I-General_Concept
or	O
in	O
memory	O
.	O
</s>
<s>
Under	O
OS/360	B-Application
and	I-Application
successors	I-Application
,	O
return	O
from	O
an	O
SVC	O
routine	O
is	O
,	O
for	O
type	O
2	O
,	O
3	O
and	O
4	O
SVC	O
routines	O
,	O
via	O
an	O
SVC	O
3	O
(	O
EXIT	O
)	O
invocation	O
,	O
and	O
for	O
other	O
SVC	O
types	O
by	O
the	O
privileged	O
Load	O
PSW	O
(	O
LPSW	O
)	O
instruction	O
,	O
and	O
which	O
is	O
executed	O
on	O
behalf	O
of	O
the	O
SVC	O
routine	O
by	O
the	O
control	O
program	O
's	O
dispatcher	O
or	O
SVC	O
interrupt	B-General_Concept
handler	I-General_Concept
.	O
</s>
<s>
On	O
non-IBM	O
developed	O
operating	B-General_Concept
systems	I-General_Concept
such	O
as	O
MUSIC/SP	B-Application
developed	O
by	O
McGill	O
University	O
in	O
Montreal	O
,	O
Canada	O
for	O
IBM	B-Device
mainframes	I-Device
,	O
and	O
for	O
non-IBM	O
mainframes	B-Architecture
,	O
VS/9	O
,	O
developed	O
by	O
Univac	O
(	O
from	O
the	O
TSOS	B-Operating_System
operating	B-General_Concept
system	I-General_Concept
for	O
the	O
RCA	B-Device
Spectra	I-Device
70	I-Device
series	O
computers	O
)	O
for	O
the	O
UNIVAC	B-Device
Series	I-Device
90	I-Device
mainframe	B-Architecture
line	O
,	O
and	O
the	O
B800	O
operating	B-General_Concept
system	I-General_Concept
(	O
also	O
developed	O
from	O
the	O
TSOS	B-Operating_System
operating	B-General_Concept
system	I-General_Concept
)	O
for	O
Fujitsu	O
's	O
mainframes	B-Architecture
,	O
all	O
use	O
the	O
LPSW	O
instruction	O
to	O
exit	O
from	O
a	O
Supervisor	B-Operating_System
Call	I-Operating_System
.	O
</s>
<s>
The	O
choice	O
on	O
whether	O
to	O
have	O
a	O
supervisor	B-Operating_System
call	I-Operating_System
return	O
to	O
the	O
calling	O
program	O
directly	O
through	O
an	O
LPSW	O
instruction	O
or	O
through	O
some	O
other	O
means	O
such	O
as	O
a	O
subroutine	O
return	O
instruction	O
or	O
a	O
supervisor	B-Operating_System
call	I-Operating_System
itself	O
,	O
is	O
a	O
matter	O
of	O
design	O
.	O
</s>
<s>
Using	O
an	O
LPSW	O
instruction	O
to	O
exit	O
an	O
SVC	O
routine	O
allows	O
for	O
faster	O
execution	O
,	O
but	O
means	O
actual	O
testing	O
of	O
the	O
routine	O
has	O
to	O
be	O
done	O
on	O
a	O
dedicated	O
machine	O
running	O
the	O
code	O
as	O
part	O
of	O
an	O
actual	O
operating	B-General_Concept
system	I-General_Concept
supervisor	O
.	O
</s>
<s>
It	O
also	O
would	O
allow	O
metrics	O
to	O
be	O
measured	O
,	O
as	O
to	O
how	O
long	O
a	O
supervisor	B-Operating_System
call	I-Operating_System
routine	O
took	O
to	O
complete	O
its	O
task	O
,	O
allowing	O
for	O
analysis	O
of	O
routines	O
that	O
are	O
excessively	O
long	O
in	O
execution	O
time	O
(	O
or	O
,	O
ones	O
that	O
are	O
very	O
fast	O
)	O
.	O
</s>
<s>
In	O
OS/360	B-Application
and	O
later	O
incarnations	O
of	O
the	O
OS	O
,	O
branch	O
and	O
link	O
entry	O
points	O
are	O
alternatives	O
to	O
SVC	O
invocations	O
for	O
some	O
supervisor	O
mode	O
routines	O
.	O
</s>
<s>
STARTIO	B-Application
.	O
</s>
<s>
(	O
This	O
also	O
has	O
the	O
advantage	O
of	O
preventing	O
IBM	O
operating	B-General_Concept
systems	I-General_Concept
from	O
being	O
run	O
on	O
non-IBM	O
hardware	O
.	O
)	O
</s>
<s>
Different	O
IBM	O
operating	B-General_Concept
systems	I-General_Concept
have	O
little	O
compatibility	O
in	O
the	O
specific	O
codes	O
used	O
or	O
in	O
the	O
supervisor	O
services	O
which	O
may	O
be	O
invoked	O
.	O
</s>
<s>
VM/370	B-Application
and	I-Application
z/VM	I-Application
systems	O
use	O
the	O
DIAG	O
instruction	O
in	O
a	O
similar	O
manner	O
,	O
and	O
leave	O
SVC	O
for	O
the	O
use	O
by	O
operating	B-General_Concept
systems	I-General_Concept
running	O
in	O
virtual	O
machines	O
.	O
</s>
<s>
Most	O
OS/360	B-Application
SVCs	O
have	O
been	O
maintained	O
for	O
"	O
legacy	O
"	O
programs	O
,	O
but	O
some	O
SVCs	O
have	O
been	O
"	O
extended	O
"	O
over	O
the	O
passage	O
of	O
time	O
.	O
</s>
<s>
In	O
OS/360	B-Application
and	O
successor	O
systems	O
SVC	O
numbers	O
0	O
through	O
approximately	O
127	O
are	O
defined	O
by	O
IBM	O
,	O
and	O
255	O
downwards	O
are	O
available	O
for	O
use	O
by	O
an	O
installation	O
's	O
systems	O
programming	O
staff	O
.	O
</s>
<s>
OS/360	B-Application
defined	O
four	O
types	O
of	O
SVC	O
routines	O
,	O
called	O
"	O
Type	O
1	O
"	O
through	O
"	O
Type	O
4	O
"	O
;	O
MVS/370	O
added	O
an	O
additional	O
"	O
Type	O
6	O
"	O
,	O
which	O
is	O
similar	O
to	O
"	O
Type	O
1	O
"	O
except	O
that	O
the	O
SVC	O
routine	O
is	O
physically	O
disabled	O
.	O
</s>
<s>
The	O
following	O
information	O
,	O
part	O
of	O
a	O
table	O
for	O
OS/360	B-Application
,	O
augmented	O
for	O
MVS/370	O
and	O
successor	O
systems	O
,	O
gives	O
an	O
idea	O
of	O
the	O
considerations	O
involved	O
in	O
writing	O
an	O
SVC	O
routine	O
.	O
</s>
<s>
Conventions	O
Type	O
1/Type	O
6	O
Type	O
2	O
Type	O
3	O
Type	O
4	O
Part	O
of	O
resident	O
control	O
program	O
Size	O
of	O
routine	O
(	O
OS/360	B-Application
)	O
Single	O
load	O
module≤	O
1024	O
bytes	O
Each	O
load	O
module≤	O
1024	O
bytes	O
Size	O
of	O
routine	O
(	O
OS/VS1	B-Application
)	O
Single	O
load	O
module≤	O
2048	O
bytes	O
Each	O
load	O
module≤	O
2048	O
bytes	O
Size	O
of	O
routine	O
(	O
SVS	B-Application
,	O
MVS	O
)	O
Refreshable	O
Reenterable	O
routine	O
,	O
but	O
must	O
be	O
serially	O
reusable	O
May	O
allow	O
interruptions	O
Register	O
contents	O
at	O
entry	O
Registers	O
3	O
,	O
4	O
,	O
5	O
,	O
6	O
,	O
7	O
and	O
14	O
contain	O
communication	O
pointers	O
;	O
registers	O
0	O
,	O
1	O
and	O
15	O
are	O
parameter	O
registers	O
.	O
</s>
<s>
SVC	O
10	O
is	O
known	O
informally	O
as	O
"	O
REGMAIN	O
"	O
as	O
it	O
exchanges	O
parameters	O
through	O
general	B-General_Concept
purpose	I-General_Concept
registers	I-General_Concept
,	O
only	O
,	O
and	O
can	O
both	O
GET	O
and	O
FREE	O
storage	O
.	O
</s>
<s>
An	O
example	O
of	O
a	O
Type	O
4	O
is	O
SVC	O
19	O
,	O
OPEN	O
,	O
used	O
to	O
make	O
a	O
dataset	O
available	O
for	O
use	O
by	O
a	O
user	O
program	O
,	O
which	O
includes	O
modules	O
common	O
to	O
all	O
access	B-Application
methods	I-Application
and	O
calls	O
additional	O
modules	O
specific	O
to	O
each	O
access	B-Application
method	I-Application
.	O
</s>
<s>
OPEN	O
also	O
supports	O
datasets	O
which	O
are	O
to	O
be	O
operated	O
on	O
by	O
a	O
"	O
roll	O
your	O
own	O
"	O
access	B-Application
method	I-Application
,	O
such	O
as	O
those	O
which	O
are	O
accessed	O
using	O
EXCP	B-Application
.	O
</s>
<s>
OS/360	B-Application
did	O
not	O
,	O
in	O
general	O
,	O
have	O
any	O
way	O
of	O
restricting	O
the	O
use	O
of	O
SVCs	O
.	O
</s>
<s>
By	O
Release	O
3.7	O
of	O
MVS/370	O
in	O
1977	O
nearly	O
every	O
such	O
exposure	O
had	O
indeed	O
been	O
identified	O
and	O
closed	O
,	O
at	O
the	O
cost	O
of	O
100,000	O
Authorized	O
Program	O
Analysis	O
Reports	O
(	O
APARs	O
)	O
and	O
related	O
Program	B-Application
temporary	I-Application
fixes	I-Application
(	O
PTFs	O
)	O
.	O
</s>
