<s>
The	O
elevator	B-Algorithm
algorithm	I-Algorithm
(	O
also	O
SCAN	O
)	O
is	O
a	O
disk-scheduling	O
algorithm	O
to	O
determine	O
the	O
motion	O
of	O
the	O
disk	B-Device
's	O
arm	O
and	O
head	O
in	O
servicing	O
read	O
and	O
write	O
requests	O
.	O
</s>
<s>
From	O
an	O
implementation	O
perspective	O
,	O
the	O
drive	B-Device
maintains	O
a	O
buffer	B-General_Concept
of	O
pending	O
read/write	O
requests	O
,	O
along	O
with	O
the	O
associated	O
cylinder	O
number	O
of	O
the	O
request	O
,	O
in	O
which	O
lower	O
cylinder	O
numbers	O
generally	O
indicate	O
that	O
the	O
cylinder	O
is	O
closer	O
to	O
the	O
spindle	O
,	O
and	O
higher	O
numbers	O
indicate	O
the	O
cylinder	O
is	O
farther	O
away	O
.	O
</s>
<s>
When	O
a	O
new	O
request	O
arrives	O
while	O
the	O
drive	B-Device
is	O
idle	O
,	O
the	O
initial	O
arm/head	O
movement	O
will	O
be	O
in	O
the	O
direction	O
of	O
the	O
cylinder	O
where	O
the	O
data	O
is	O
stored	O
,	O
either	O
in	O
or	O
out	O
.	O
</s>
<s>
As	O
additional	O
requests	O
arrive	O
,	O
requests	O
are	O
serviced	O
only	O
in	O
the	O
current	O
direction	O
of	O
arm	O
movement	O
until	O
the	O
arm	O
reaches	O
the	O
edge	O
of	O
the	O
disk	B-Device
.	O
</s>
<s>
One	O
variation	O
of	O
this	O
method	O
ensures	O
all	O
requests	O
are	O
serviced	O
in	O
only	O
one	O
direction	O
,	O
that	O
is	O
,	O
once	O
the	O
head	O
has	O
arrived	O
at	O
the	O
outer	O
edge	O
of	O
the	O
disk	B-Device
,	O
it	O
returns	O
to	O
the	O
beginning	O
and	O
services	O
the	O
new	O
requests	O
in	O
this	O
one	O
direction	O
only	O
(	O
or	O
vice	O
versa	O
)	O
.	O
</s>
<s>
This	O
is	O
known	O
as	O
the	O
"	O
Circular	B-Algorithm
Elevator	I-Algorithm
Algorithm	I-Algorithm
"	O
or	O
C-SCAN	B-Algorithm
.	O
</s>
<s>
Although	O
the	O
time	O
of	O
the	O
return	O
seek	O
is	O
wasted	O
,	O
this	O
results	O
in	O
more	O
equal	O
performance	O
for	O
all	O
head	O
positions	O
,	O
as	O
the	O
expected	O
distance	O
from	O
the	O
head	O
is	O
always	O
half	O
the	O
maximum	O
distance	O
,	O
unlike	O
in	O
the	O
standard	O
elevator	B-Algorithm
algorithm	I-Algorithm
where	O
cylinders	O
in	O
the	O
middle	O
will	O
be	O
serviced	O
as	O
much	O
as	O
twice	O
as	O
often	O
as	O
the	O
innermost	O
or	O
outermost	O
cylinders	O
.	O
</s>
<s>
The	O
following	O
is	O
an	O
example	O
of	O
how	O
to	O
calculate	O
average	O
disk	B-Device
seek	O
times	O
for	O
both	O
the	O
SCAN	O
and	O
C-SCAN	B-Algorithm
algorithms	O
.	O
</s>
<s>
Example	O
list	O
of	O
pending	O
disk	B-Device
requests	O
(	O
listed	O
by	O
track	O
number	O
)	O
:	O
100	O
,	O
50	O
,	O
10	O
,	O
20	O
,	O
75	O
.	O
</s>
<s>
Both	O
SCAN	O
and	O
C-SCAN	B-Algorithm
behave	O
in	O
the	O
same	O
manner	O
until	O
they	O
reach	O
the	O
last	O
track	O
queued	O
.	O
</s>
<s>
For	O
the	O
sake	O
of	O
this	O
example	O
let	O
us	O
assume	O
that	O
the	O
SCAN	O
algorithm	O
is	O
currently	O
going	O
from	O
a	O
lower	O
track	O
number	O
to	O
a	O
higher	O
track	O
number	O
(	O
like	O
the	O
C-SCAN	B-Algorithm
is	O
doing	O
)	O
.	O
</s>
<s>
SCAN	O
will	O
just	O
reverse	O
direction	O
and	O
service	O
the	O
next	O
closest	O
disk	B-Device
request	O
(	O
in	O
this	O
example	O
,	O
20	O
)	O
and	O
C-SCAN	B-Algorithm
will	O
always	O
go	O
back	O
to	O
track	O
0	O
and	O
start	O
going	O
to	O
higher	O
track	O
requests	O
.	O
</s>
<s>
Even	O
though	O
six	O
seeks	O
were	O
performed	O
using	O
the	O
C-SCAN	B-Algorithm
algorithm	O
,	O
only	O
five	O
I/Os	O
were	O
actually	O
done	O
.	O
</s>
<s>
For	O
both	O
versions	O
of	O
the	O
elevator	B-Algorithm
algorithm	I-Algorithm
,	O
the	O
arm	O
movement	O
is	O
less	O
than	O
twice	O
the	O
number	O
of	O
total	O
cylinders	O
and	O
produces	O
a	O
smaller	O
variance	O
in	O
response	O
time	O
.	O
</s>
<s>
The	O
elevator	B-Algorithm
algorithm	I-Algorithm
is	O
not	O
always	O
better	O
than	O
shortest	B-General_Concept
seek	I-General_Concept
first	I-General_Concept
,	O
which	O
is	O
slightly	O
closer	O
to	O
optimal	O
,	O
but	O
can	O
result	O
in	O
high	O
variance	O
in	O
response	O
time	O
and	O
even	O
in	O
starvation	B-Operating_System
when	O
new	O
requests	O
continually	O
get	O
serviced	O
prior	O
to	O
existing	O
requests	O
.	O
</s>
<s>
Anti-starvation	O
techniques	O
can	O
be	O
applied	O
to	O
the	O
shortest	B-General_Concept
seek	I-General_Concept
time	I-General_Concept
first	I-General_Concept
algorithm	O
to	O
guarantee	O
a	O
maximum	O
response	O
time	O
.	O
</s>
