<s>
In	O
computing	O
,	O
scheduling	B-Application
is	O
the	O
action	O
of	O
assigning	O
resources	O
to	O
perform	O
tasks	O
.	O
</s>
<s>
The	O
resources	O
may	O
be	O
processors	B-General_Concept
,	O
network	O
links	O
or	O
expansion	B-Device
cards	I-Device
.	O
</s>
<s>
The	O
tasks	O
may	O
be	O
threads	B-Operating_System
,	O
processes	B-Operating_System
or	O
data	O
flows	B-Operating_System
.	O
</s>
<s>
The	O
scheduling	B-Application
activity	O
is	O
carried	O
out	O
by	O
a	O
process	B-Operating_System
called	O
scheduler	O
.	O
</s>
<s>
Schedulers	O
are	O
often	O
designed	O
so	O
as	O
to	O
keep	O
all	O
computer	O
resources	O
busy	O
(	O
as	O
in	O
load	B-Application
balancing	I-Application
)	O
,	O
allow	O
multiple	O
users	O
to	O
share	O
system	O
resources	O
effectively	O
,	O
or	O
to	O
achieve	O
a	O
target	O
quality-of-service	O
.	O
</s>
<s>
Scheduling	B-Application
is	O
fundamental	O
to	O
computation	O
itself	O
,	O
and	O
an	O
intrinsic	O
part	O
of	O
the	O
execution	B-Device
model	I-Device
of	O
a	O
computer	O
system	O
;	O
the	O
concept	O
of	O
scheduling	B-Application
makes	O
it	O
possible	O
to	O
have	O
computer	B-Operating_System
multitasking	I-Operating_System
with	O
a	O
single	O
central	B-General_Concept
processing	I-General_Concept
unit	I-General_Concept
(	O
CPU	O
)	O
.	O
</s>
<s>
maximizing	O
fairness	O
(	O
equal	O
CPU	O
time	O
to	O
each	O
process	B-Operating_System
,	O
or	O
more	O
generally	O
appropriate	O
times	O
according	O
to	O
the	O
priority	O
and	O
workload	O
of	O
each	O
process	B-Operating_System
)	O
.	O
</s>
<s>
In	O
real-time	B-General_Concept
environments	O
,	O
such	O
as	O
embedded	B-Architecture
systems	I-Architecture
for	O
automatic	O
control	O
in	O
industry	O
(	O
for	O
example	O
robotics	O
)	O
,	O
the	O
scheduler	O
also	O
must	O
ensure	O
that	O
processes	B-Operating_System
can	O
meet	O
deadlines	O
;	O
this	O
is	O
crucial	O
for	O
keeping	O
the	O
system	O
stable	O
.	O
</s>
<s>
The	O
scheduler	O
is	O
an	O
operating	B-General_Concept
system	I-General_Concept
module	O
that	O
selects	O
the	O
next	O
jobs	O
to	O
be	O
admitted	O
into	O
the	O
system	O
and	O
the	O
next	O
process	B-Operating_System
to	O
run	O
.	O
</s>
<s>
Operating	B-General_Concept
systems	I-General_Concept
may	O
feature	O
up	O
to	O
three	O
distinct	O
scheduler	O
types	O
:	O
a	O
long-term	O
scheduler	O
(	O
also	O
known	O
as	O
an	O
admission	O
scheduler	O
or	O
high-level	O
scheduler	O
)	O
,	O
a	O
mid-term	O
or	O
medium-term	O
scheduler	O
,	O
and	O
a	O
short-term	O
scheduler	O
.	O
</s>
<s>
The	O
process	B-Operating_System
scheduler	O
is	O
a	O
part	O
of	O
the	O
operating	B-General_Concept
system	I-General_Concept
that	O
decides	O
which	O
process	B-Operating_System
runs	O
at	O
a	O
certain	O
point	O
in	O
time	O
.	O
</s>
<s>
It	O
usually	O
has	O
the	O
ability	O
to	O
pause	O
a	O
running	O
process	B-Operating_System
,	O
move	O
it	O
to	O
the	O
back	O
of	O
the	O
running	O
queue	B-Device
and	O
start	O
a	O
new	O
process	B-Operating_System
;	O
such	O
a	O
scheduler	O
is	O
known	O
as	O
a	O
preemptive	B-Operating_System
scheduler	I-Operating_System
,	O
otherwise	O
it	O
is	O
a	O
cooperative	B-Operating_System
scheduler	I-Operating_System
.	O
</s>
<s>
We	O
distinguish	O
between	O
"	O
long-term	O
scheduling	B-Application
"	O
,	O
"	O
medium-term	O
scheduling	B-Application
"	O
,	O
and	O
"	O
short-term	O
scheduling	B-Application
"	O
based	O
on	O
how	O
often	O
decisions	O
must	O
be	O
made	O
.	O
</s>
<s>
The	O
long-term	O
scheduler	O
,	O
or	O
admission	O
scheduler	O
,	O
decides	O
which	O
jobs	O
or	O
processes	B-Operating_System
are	O
to	O
be	O
admitted	O
to	O
the	O
ready	O
queue	B-Device
(	O
in	O
main	O
memory	O
)	O
;	O
that	O
is	O
,	O
when	O
an	O
attempt	O
is	O
made	O
to	O
execute	O
a	O
program	O
,	O
its	O
admission	O
to	O
the	O
set	O
of	O
currently	O
executing	O
processes	B-Operating_System
is	O
either	O
authorized	O
or	O
delayed	O
by	O
the	O
long-term	O
scheduler	O
.	O
</s>
<s>
Thus	O
,	O
this	O
scheduler	O
dictates	O
what	O
processes	B-Operating_System
are	O
to	O
run	O
on	O
a	O
system	O
,	O
and	O
the	O
degree	O
of	O
concurrency	B-Architecture
to	O
be	O
supported	O
at	O
any	O
one	O
time	O
whether	O
many	O
or	O
few	O
processes	B-Operating_System
are	O
to	O
be	O
executed	O
concurrently	O
,	O
and	O
how	O
the	O
split	O
between	O
I/O	O
-intensive	O
and	O
CPU-intensive	O
processes	B-Operating_System
is	O
to	O
be	O
handled	O
.	O
</s>
<s>
In	O
general	O
,	O
most	O
processes	B-Operating_System
can	O
be	O
described	O
as	O
either	O
I/O	B-General_Concept
-bound	I-General_Concept
or	O
CPU-bound	O
.	O
</s>
<s>
An	O
I/O	B-General_Concept
-bound	I-General_Concept
process	B-Operating_System
is	O
one	O
that	O
spends	O
more	O
of	O
its	O
time	O
doing	O
I/O	O
than	O
it	O
spends	O
doing	O
computations	O
.	O
</s>
<s>
A	O
CPU-bound	O
process	B-Operating_System
,	O
in	O
contrast	O
,	O
generates	O
I/O	O
requests	O
infrequently	O
,	O
using	O
more	O
of	O
its	O
time	O
doing	O
computations	O
.	O
</s>
<s>
It	O
is	O
important	O
that	O
a	O
long-term	O
scheduler	O
selects	O
a	O
good	O
process	B-Operating_System
mix	O
of	O
I/O	B-General_Concept
-bound	I-General_Concept
and	O
CPU-bound	O
processes	B-Operating_System
.	O
</s>
<s>
If	O
all	O
processes	B-Operating_System
are	O
I/O	B-General_Concept
-bound	I-General_Concept
,	O
the	O
ready	O
queue	B-Device
will	O
almost	O
always	O
be	O
empty	O
,	O
and	O
the	O
short-term	O
scheduler	O
will	O
have	O
little	O
to	O
do	O
.	O
</s>
<s>
On	O
the	O
other	O
hand	O
,	O
if	O
all	O
processes	B-Operating_System
are	O
CPU-bound	O
,	O
the	O
I/O	O
waiting	O
queue	B-Device
will	O
almost	O
always	O
be	O
empty	O
,	O
devices	O
will	O
go	O
unused	O
,	O
and	O
again	O
the	O
system	O
will	O
be	O
unbalanced	O
.	O
</s>
<s>
The	O
system	O
with	O
the	O
best	O
performance	O
will	O
thus	O
have	O
a	O
combination	O
of	O
CPU-bound	O
and	O
I/O	B-General_Concept
-bound	I-General_Concept
processes	B-Operating_System
.	O
</s>
<s>
In	O
modern	O
operating	B-General_Concept
systems	I-General_Concept
,	O
this	O
is	O
used	O
to	O
make	O
sure	O
that	O
real-time	B-General_Concept
processes	B-Operating_System
get	O
enough	O
CPU	O
time	O
to	O
finish	O
their	O
tasks	O
.	O
</s>
<s>
Long-term	O
scheduling	B-Application
is	O
also	O
important	O
in	O
large-scale	O
systems	O
such	O
as	O
batch	B-General_Concept
processing	I-General_Concept
systems	O
,	O
computer	B-Architecture
clusters	I-Architecture
,	O
supercomputers	B-Architecture
,	O
and	O
render	B-Operating_System
farms	I-Operating_System
.	O
</s>
<s>
For	O
example	O
,	O
in	O
concurrent	B-Architecture
systems	I-Architecture
,	O
coscheduling	B-Operating_System
of	O
interacting	O
processes	B-Operating_System
is	O
often	O
required	O
to	O
prevent	O
them	O
from	O
blocking	O
due	O
to	O
waiting	O
on	O
each	O
other	O
.	O
</s>
<s>
In	O
these	O
cases	O
,	O
special-purpose	O
job	B-General_Concept
scheduler	I-General_Concept
software	O
is	O
typically	O
used	O
to	O
assist	O
these	O
functions	O
,	O
in	O
addition	O
to	O
any	O
underlying	O
admission	O
scheduling	B-Application
support	O
in	O
the	O
operating	B-General_Concept
system	I-General_Concept
.	O
</s>
<s>
Some	O
operating	B-General_Concept
systems	I-General_Concept
only	O
allow	O
new	O
tasks	O
to	O
be	O
added	O
if	O
it	O
is	O
sure	O
all	O
real-time	B-General_Concept
deadlines	O
can	O
still	O
be	O
met	O
.	O
</s>
<s>
The	O
specific	O
heuristic	O
algorithm	O
used	O
by	O
an	O
operating	B-General_Concept
system	I-General_Concept
to	O
accept	O
or	O
reject	O
new	O
tasks	O
is	O
the	O
admission	O
control	O
mechanism	O
.	O
</s>
<s>
The	O
medium-term	O
scheduler	O
temporarily	O
removes	O
processes	B-Operating_System
from	O
main	O
memory	O
and	O
places	O
them	O
in	O
secondary	O
memory	O
(	O
such	O
as	O
a	O
hard	B-Device
disk	I-Device
drive	I-Device
)	O
or	O
vice	O
versa	O
,	O
which	O
is	O
commonly	O
referred	O
to	O
as	O
"	O
swapping	O
out	O
"	O
or	O
"	O
swapping	O
in	O
"	O
(	O
also	O
incorrectly	O
as	O
"	O
paging	B-Architecture
out	O
"	O
or	O
"	O
paging	B-Architecture
in	O
"	O
)	O
.	O
</s>
<s>
The	O
medium-term	O
scheduler	O
may	O
decide	O
to	O
swap	O
out	O
a	O
process	B-Operating_System
which	O
has	O
not	O
been	O
active	O
for	O
some	O
time	O
,	O
or	O
a	O
process	B-Operating_System
which	O
has	O
a	O
low	O
priority	O
,	O
or	O
a	O
process	B-Operating_System
which	O
is	O
page	O
faulting	O
frequently	O
,	O
or	O
a	O
process	B-Operating_System
which	O
is	O
taking	O
up	O
a	O
large	O
amount	O
of	O
memory	O
in	O
order	O
to	O
free	O
up	O
main	O
memory	O
for	O
other	O
processes	B-Operating_System
,	O
swapping	O
the	O
process	B-Operating_System
back	O
in	O
later	O
when	O
more	O
memory	O
is	O
available	O
,	O
or	O
when	O
the	O
process	B-Operating_System
has	O
been	O
unblocked	O
and	O
is	O
no	O
longer	O
waiting	O
for	O
a	O
resource	O
.	O
</s>
<s>
In	O
many	O
systems	O
today	O
(	O
those	O
that	O
support	O
mapping	O
virtual	O
address	O
space	O
to	O
secondary	O
storage	O
other	O
than	O
the	O
swap	O
file	O
)	O
,	O
the	O
medium-term	O
scheduler	O
may	O
actually	O
perform	O
the	O
role	O
of	O
the	O
long-term	O
scheduler	O
,	O
by	O
treating	O
binaries	O
as	O
"	O
swapped	O
out	O
processes	B-Operating_System
"	O
upon	O
their	O
execution	O
.	O
</s>
<s>
In	O
this	O
way	O
,	O
when	O
a	O
segment	O
of	O
the	O
binary	O
is	O
required	O
it	O
can	O
be	O
swapped	O
in	O
on	O
demand	O
,	O
or	O
"	O
lazy	O
loaded	O
"	O
,	O
[	O
Stallings	O
,	O
394 ]	O
also	O
called	O
demand	B-General_Concept
paging	I-General_Concept
.	O
</s>
<s>
The	O
short-term	O
scheduler	O
(	O
also	O
known	O
as	O
the	O
CPU	O
scheduler	O
)	O
decides	O
which	O
of	O
the	O
ready	O
,	O
in-memory	O
processes	B-Operating_System
is	O
to	O
be	O
executed	O
(	O
allocated	O
a	O
CPU	O
)	O
after	O
a	O
clock	O
interrupt	B-Application
,	O
an	O
I/O	O
interrupt	B-Application
,	O
an	O
operating	B-General_Concept
system	I-General_Concept
call	O
or	O
another	O
form	O
of	O
signal	B-Application
.	O
</s>
<s>
Thus	O
the	O
short-term	O
scheduler	O
makes	O
scheduling	B-Application
decisions	O
much	O
more	O
frequently	O
than	O
the	O
long-term	O
or	O
mid-term	O
schedulersa	O
scheduling	B-Application
decision	O
will	O
at	O
a	O
minimum	O
have	O
to	O
be	O
made	O
after	O
every	O
time	O
slice	O
,	O
and	O
these	O
are	O
very	O
short	O
.	O
</s>
<s>
This	O
scheduler	O
can	O
be	O
preemptive	B-Operating_System
,	O
implying	O
that	O
it	O
is	O
capable	O
of	O
forcibly	O
removing	O
processes	B-Operating_System
from	O
a	O
CPU	O
when	O
it	O
decides	O
to	O
allocate	O
that	O
CPU	O
to	O
another	O
process	B-Operating_System
,	O
or	O
non-preemptive	O
(	O
also	O
known	O
as	O
"	O
voluntary	O
"	O
or	O
"	O
co-operative	O
"	O
)	O
,	O
in	O
which	O
case	O
the	O
scheduler	O
is	O
unable	O
to	O
"	O
force	O
"	O
processes	B-Operating_System
off	O
the	O
CPU	O
.	O
</s>
<s>
A	O
preemptive	B-Operating_System
scheduler	I-Operating_System
relies	O
upon	O
a	O
programmable	B-Device
interval	I-Device
timer	I-Device
which	O
invokes	O
an	O
interrupt	B-General_Concept
handler	I-General_Concept
that	O
runs	O
in	O
kernel	B-Operating_System
mode	O
and	O
implements	O
the	O
scheduling	B-Application
function	O
.	O
</s>
<s>
Another	O
component	O
that	O
is	O
involved	O
in	O
the	O
CPU-scheduling	O
function	O
is	O
the	O
dispatcher	O
,	O
which	O
is	O
the	O
module	O
that	O
gives	O
control	O
of	O
the	O
CPU	O
to	O
the	O
process	B-Operating_System
selected	O
by	O
the	O
short-term	O
scheduler	O
.	O
</s>
<s>
It	O
receives	O
control	O
in	O
kernel	B-Operating_System
mode	O
as	O
the	O
result	O
of	O
an	O
interrupt	B-Application
or	O
system	B-Operating_System
call	I-Operating_System
.	O
</s>
<s>
Context	B-Operating_System
switches	I-Operating_System
,	O
in	O
which	O
the	O
dispatcher	O
saves	O
the	O
state	B-Application
(	O
also	O
known	O
as	O
context	B-Operating_System
)	O
of	O
the	O
process	B-Operating_System
or	O
thread	B-Operating_System
that	O
was	O
previously	O
running	O
;	O
the	O
dispatcher	O
then	O
loads	O
the	O
initial	O
or	O
previously	O
saved	O
state	B-Application
of	O
the	O
new	O
process	B-Operating_System
.	O
</s>
<s>
Switching	O
to	O
user	B-Operating_System
mode	I-Operating_System
.	O
</s>
<s>
Jumping	O
to	O
the	O
proper	O
location	O
in	O
the	O
user	O
program	O
to	O
restart	O
that	O
program	O
indicated	O
by	O
its	O
new	O
state	B-Application
.	O
</s>
<s>
The	O
dispatcher	O
should	O
be	O
as	O
fast	O
as	O
possible	O
,	O
since	O
it	O
is	O
invoked	O
during	O
every	O
process	B-Operating_System
switch	I-Operating_System
.	O
</s>
<s>
During	O
the	O
context	B-Operating_System
switches	I-Operating_System
,	O
the	O
processor	O
is	O
virtually	O
idle	O
for	O
a	O
fraction	O
of	O
time	O
,	O
thus	O
unnecessary	O
context	B-Operating_System
switches	I-Operating_System
should	O
be	O
avoided	O
.	O
</s>
<s>
The	O
time	O
it	O
takes	O
for	O
the	O
dispatcher	O
to	O
stop	O
one	O
process	B-Operating_System
and	O
start	O
another	O
is	O
known	O
as	O
the	O
dispatch	O
latency	O
.	O
</s>
<s>
A	O
scheduling	B-Application
discipline	O
(	O
also	O
called	O
scheduling	B-Application
policy	O
or	O
scheduling	B-Application
algorithm	O
)	O
is	O
an	O
algorithm	O
used	O
for	O
distributing	O
resources	O
among	O
parties	O
which	O
simultaneously	O
and	O
asynchronously	O
request	O
them	O
.	O
</s>
<s>
Scheduling	B-Application
disciplines	O
are	O
used	O
in	O
routers	B-Protocol
(	O
to	O
handle	O
packet	O
traffic	O
)	O
as	O
well	O
as	O
in	O
operating	B-General_Concept
systems	I-General_Concept
(	O
to	O
share	O
CPU	O
time	O
among	O
both	O
threads	B-Operating_System
and	O
processes	B-Operating_System
)	O
,	O
disk	O
drives	O
(	O
I/O	B-General_Concept
scheduling	I-General_Concept
)	O
,	O
printers	O
(	O
print	B-Device
spooler	I-Device
)	O
,	O
most	O
embedded	B-Architecture
systems	I-Architecture
,	O
etc	O
.	O
</s>
<s>
The	O
main	O
purposes	O
of	O
scheduling	B-Application
algorithms	O
are	O
to	O
minimize	O
resource	B-Operating_System
starvation	I-Operating_System
and	O
to	O
ensure	O
fairness	O
amongst	O
the	O
parties	O
utilizing	O
the	O
resources	O
.	O
</s>
<s>
Scheduling	B-Application
deals	O
with	O
the	O
problem	O
of	O
deciding	O
which	O
of	O
the	O
outstanding	O
requests	O
is	O
to	O
be	O
allocated	O
resources	O
.	O
</s>
<s>
There	O
are	O
many	O
different	O
scheduling	B-Application
algorithms	O
.	O
</s>
<s>
In	O
packet-switched	B-Protocol
computer	I-Protocol
networks	I-Protocol
and	O
other	O
statistical	B-Algorithm
multiplexing	I-Algorithm
,	O
the	O
notion	O
of	O
a	O
scheduling	B-Application
algorithm	O
is	O
used	O
as	O
an	O
alternative	O
to	O
first-come	B-Operating_System
first-served	I-Operating_System
queuing	O
of	O
data	O
packets	O
.	O
</s>
<s>
The	O
simplest	O
best-effort	O
scheduling	B-Application
algorithms	O
are	O
round-robin	B-Algorithm
,	O
fair	B-Algorithm
queuing	I-Algorithm
(	O
a	O
max-min	B-Algorithm
fair	I-Algorithm
scheduling	I-Algorithm
algorithm	O
)	O
,	O
proportional-fair	B-Algorithm
scheduling	I-Algorithm
and	O
maximum	B-Algorithm
throughput	I-Algorithm
.	O
</s>
<s>
If	O
differentiated	O
or	O
guaranteed	O
quality	O
of	O
service	O
is	O
offered	O
,	O
as	O
opposed	O
to	O
best-effort	O
communication	O
,	O
weighted	B-Algorithm
fair	I-Algorithm
queuing	I-Algorithm
may	O
be	O
utilized	O
.	O
</s>
<s>
In	O
advanced	O
packet	O
radio	O
wireless	O
networks	O
such	O
as	O
HSDPA	O
(	O
High-Speed	O
Downlink	O
Packet	O
Access	O
)	O
3.5G	O
cellular	O
system	O
,	O
channel-dependent	B-Protocol
scheduling	I-Protocol
may	O
be	O
used	O
to	O
take	O
advantage	O
of	O
channel	O
state	B-Application
information	O
.	O
</s>
<s>
In	O
even	O
more	O
advanced	O
systems	O
such	O
as	O
LTE	O
,	O
the	O
scheduling	B-Application
is	O
combined	O
by	O
channel-dependent	O
packet-by-packet	O
dynamic	B-Protocol
channel	I-Protocol
allocation	I-Protocol
,	O
or	O
by	O
assigning	O
OFDMA	O
multi-carriers	O
or	O
other	O
frequency-domain	O
equalization	O
components	O
to	O
the	O
users	O
that	O
best	O
can	O
utilize	O
them	O
.	O
</s>
<s>
First	B-Operating_System
in	I-Operating_System
,	I-Operating_System
first	I-Operating_System
out	I-Operating_System
(	O
FIFO	B-Operating_System
)	O
,	O
also	O
known	O
as	O
first	O
come	O
,	O
first	O
served	O
(	O
FCFS	B-Operating_System
)	O
,	O
is	O
the	O
simplest	O
scheduling	B-Application
algorithm	O
.	O
</s>
<s>
FIFO	B-Operating_System
simply	O
queues	B-Device
processes	B-Operating_System
in	O
the	O
order	O
that	O
they	O
arrive	O
in	O
the	O
ready	O
queue	B-Device
.	O
</s>
<s>
Since	O
context	B-Operating_System
switches	I-Operating_System
only	O
occur	O
upon	O
process	B-Operating_System
termination	O
,	O
and	O
no	O
reorganization	O
of	O
the	O
process	B-Operating_System
queue	B-Device
is	O
required	O
,	O
scheduling	B-Application
overhead	O
is	O
minimal	O
.	O
</s>
<s>
Throughput	O
can	O
be	O
low	O
,	O
because	O
long	O
processes	B-Operating_System
can	O
be	O
holding	O
the	O
CPU	O
,	O
causing	O
the	O
short	O
processes	B-Operating_System
to	O
wait	O
for	O
a	O
long	O
time	O
(	O
known	O
as	O
the	O
convoy	O
effect	O
)	O
.	O
</s>
<s>
No	O
starvation	B-Operating_System
,	O
because	O
each	O
process	B-Operating_System
gets	O
chance	O
to	O
be	O
executed	O
after	O
a	O
definite	O
time	O
.	O
</s>
<s>
Turnaround	B-General_Concept
time	I-General_Concept
,	O
waiting	O
time	O
and	O
response	O
time	O
depend	O
on	O
the	O
order	O
of	O
their	O
arrival	O
and	O
can	O
be	O
high	O
for	O
the	O
same	O
reasons	O
above	O
.	O
</s>
<s>
No	O
prioritization	O
occurs	O
,	O
thus	O
this	O
system	O
has	O
trouble	O
meeting	O
process	B-Operating_System
deadlines	O
.	O
</s>
<s>
The	O
lack	O
of	O
prioritization	O
means	O
that	O
as	O
long	O
as	O
every	O
process	B-Operating_System
eventually	O
completes	O
,	O
there	O
is	O
no	O
starvation	B-Operating_System
.	O
</s>
<s>
In	O
an	O
environment	O
where	O
some	O
processes	B-Operating_System
might	O
not	O
complete	O
,	O
there	O
can	O
be	O
starvation	B-Operating_System
.	O
</s>
<s>
Earliest	O
deadline	O
first	O
(	O
EDF	O
)	O
or	O
least	O
time	O
to	O
go	O
is	O
a	O
dynamic	O
scheduling	B-Application
algorithm	O
used	O
in	O
real-time	B-General_Concept
operating	B-General_Concept
systems	I-General_Concept
to	O
place	O
processes	B-Operating_System
in	O
a	O
priority	O
queue	B-Device
.	O
</s>
<s>
Whenever	O
a	O
scheduling	B-Application
event	O
occurs	O
(	O
a	O
task	O
finishes	O
,	O
new	O
task	O
is	O
released	O
,	O
etc	O
.	O
</s>
<s>
)	O
,	O
the	O
queue	B-Device
will	O
be	O
searched	O
for	O
the	O
process	B-Operating_System
closest	O
to	O
its	O
deadline	O
,	O
which	O
will	O
be	O
the	O
next	O
to	O
be	O
scheduled	O
for	O
execution	O
.	O
</s>
<s>
Similar	O
to	O
shortest	B-Operating_System
job	I-Operating_System
first	I-Operating_System
(	O
SJF	O
)	O
.	O
</s>
<s>
With	O
this	O
strategy	O
the	O
scheduler	O
arranges	O
processes	B-Operating_System
with	O
the	O
least	O
estimated	O
processing	O
time	O
remaining	O
to	O
be	O
next	O
in	O
the	O
queue	B-Device
.	O
</s>
<s>
This	O
requires	O
advanced	O
knowledge	O
or	O
estimations	O
about	O
the	O
time	O
required	O
for	O
a	O
process	B-Operating_System
to	O
complete	O
.	O
</s>
<s>
If	O
a	O
shorter	O
process	B-Operating_System
arrives	O
during	O
another	O
process	B-Operating_System
 '	O
execution	O
,	O
the	O
currently	O
running	O
process	B-Operating_System
is	O
interrupted	O
(	O
known	O
as	O
preemption	B-Operating_System
)	O
,	O
dividing	O
that	O
process	B-Operating_System
into	O
two	O
separate	O
computing	O
blocks	O
.	O
</s>
<s>
This	O
creates	O
excess	O
overhead	O
through	O
additional	O
context	B-Operating_System
switching	I-Operating_System
.	O
</s>
<s>
The	O
scheduler	O
must	O
also	O
place	O
each	O
incoming	O
process	B-Operating_System
into	O
a	O
specific	O
place	O
in	O
the	O
queue	B-Device
,	O
creating	O
additional	O
overhead	O
.	O
</s>
<s>
This	O
algorithm	O
is	O
designed	O
for	O
maximum	B-Algorithm
throughput	I-Algorithm
in	O
most	O
scenarios	O
.	O
</s>
<s>
Waiting	O
time	O
and	O
response	O
time	O
increase	O
as	O
the	O
process	B-Operating_System
's	O
computational	O
requirements	O
increase	O
.	O
</s>
<s>
Since	O
turnaround	B-General_Concept
time	I-General_Concept
is	O
based	O
on	O
waiting	O
time	O
plus	O
processing	O
time	O
,	O
longer	O
processes	B-Operating_System
are	O
significantly	O
affected	O
by	O
this	O
.	O
</s>
<s>
Overall	O
waiting	O
time	O
is	O
smaller	O
than	O
FIFO	B-Operating_System
,	O
however	O
since	O
no	O
process	B-Operating_System
has	O
to	O
wait	O
for	O
the	O
termination	O
of	O
the	O
longest	O
process	B-Operating_System
.	O
</s>
<s>
No	O
particular	O
attention	O
is	O
given	O
to	O
deadlines	O
,	O
the	O
programmer	O
can	O
only	O
attempt	O
to	O
make	O
processes	B-Operating_System
with	O
deadlines	O
as	O
short	O
as	O
possible	O
.	O
</s>
<s>
Starvation	B-Operating_System
is	O
possible	O
,	O
especially	O
in	O
a	O
busy	O
system	O
with	O
many	O
small	O
processes	B-Operating_System
being	O
run	O
.	O
</s>
<s>
The	O
operating	B-General_Concept
system	I-General_Concept
assigns	O
a	O
fixed	O
priority	O
rank	O
to	O
every	O
process	B-Operating_System
,	O
and	O
the	O
scheduler	O
arranges	O
the	O
processes	B-Operating_System
in	O
the	O
ready	O
queue	B-Device
in	O
order	O
of	O
their	O
priority	O
.	O
</s>
<s>
Lower-priority	O
processes	B-Operating_System
get	O
interrupted	O
by	O
incoming	O
higher-priority	O
processes	B-Operating_System
.	O
</s>
<s>
FPPS	O
has	O
no	O
particular	O
advantage	O
in	O
terms	O
of	O
throughput	O
over	O
FIFO	B-Operating_System
scheduling	B-Application
.	O
</s>
<s>
If	O
the	O
number	O
of	O
rankings	O
is	O
limited	O
,	O
it	O
can	O
be	O
characterized	O
as	O
a	O
collection	O
of	O
FIFO	B-Operating_System
queues	B-Device
,	O
one	O
for	O
each	O
priority	O
ranking	O
.	O
</s>
<s>
Processes	B-Operating_System
in	O
lower-priority	O
queues	B-Device
are	O
selected	O
only	O
when	O
all	O
of	O
the	O
higher-priority	O
queues	B-Device
are	O
empty	O
.	O
</s>
<s>
Waiting	O
time	O
and	O
response	O
time	O
depend	O
on	O
the	O
priority	O
of	O
the	O
process	B-Operating_System
.	O
</s>
<s>
Higher-priority	O
processes	B-Operating_System
have	O
smaller	O
waiting	O
and	O
response	O
times	O
.	O
</s>
<s>
Deadlines	O
can	O
be	O
met	O
by	O
giving	O
processes	B-Operating_System
with	O
deadlines	O
a	O
higher	O
priority	O
.	O
</s>
<s>
Starvation	B-Operating_System
of	O
lower-priority	O
processes	B-Operating_System
is	O
possible	O
with	O
large	O
numbers	O
of	O
high-priority	O
processes	B-Operating_System
queuing	O
for	O
CPU	O
time	O
.	O
</s>
<s>
The	O
scheduler	O
assigns	O
a	O
fixed	O
time	O
unit	O
per	O
process	B-Operating_System
,	O
and	O
cycles	O
through	O
them	O
.	O
</s>
<s>
If	O
process	B-Operating_System
completes	O
within	O
that	O
time-slice	O
it	O
gets	O
terminated	O
otherwise	O
it	O
is	O
rescheduled	O
after	O
giving	O
a	O
chance	O
to	O
all	O
other	O
processes	B-Operating_System
.	O
</s>
<s>
RR	O
scheduling	B-Application
involves	O
extensive	O
overhead	O
,	O
especially	O
with	O
a	O
small	O
time	O
unit	O
.	O
</s>
<s>
Balanced	O
throughput	O
between	O
FCFS/	O
FIFO	B-Operating_System
and	O
SJF/SRTF	O
,	O
shorter	O
jobs	O
are	O
completed	O
faster	O
than	O
in	O
FIFO	B-Operating_System
and	O
longer	O
processes	B-Operating_System
are	O
completed	O
faster	O
than	O
in	O
SJF	O
.	O
</s>
<s>
Good	O
average	O
response	O
time	O
,	O
waiting	O
time	O
is	O
dependent	O
on	O
number	O
of	O
processes	B-Operating_System
,	O
and	O
not	O
average	O
process	B-Operating_System
length	O
.	O
</s>
<s>
Starvation	B-Operating_System
can	O
never	O
occur	O
,	O
since	O
no	O
priority	O
is	O
given	O
.	O
</s>
<s>
Order	O
of	O
time	O
unit	O
allocation	O
is	O
based	O
upon	O
process	B-Operating_System
arrival	O
time	O
,	O
similar	O
to	O
FIFO	B-Operating_System
.	O
</s>
<s>
If	O
Time-Slice	O
is	O
large	O
it	O
becomes	O
FCFS	B-Operating_System
/FIFO	O
or	O
if	O
it	O
is	O
short	O
then	O
it	O
becomes	O
SJF/SRTF	O
.	O
</s>
<s>
This	O
is	O
used	O
for	O
situations	O
in	O
which	O
processes	B-Operating_System
are	O
easily	O
divided	O
into	O
different	O
groups	O
.	O
</s>
<s>
For	O
example	O
,	O
a	O
common	O
division	O
is	O
made	O
between	O
foreground	O
(	O
interactive	O
)	O
processes	B-Operating_System
and	O
background	O
(	O
batch	O
)	O
processes	B-Operating_System
.	O
</s>
<s>
These	O
two	O
types	O
of	O
processes	B-Operating_System
have	O
different	O
response-time	O
requirements	O
and	O
so	O
may	O
have	O
different	O
scheduling	B-Application
needs	O
.	O
</s>
<s>
It	O
is	O
very	O
useful	O
for	O
shared	B-Operating_System
memory	I-Operating_System
problems	O
.	O
</s>
<s>
A	O
work-conserving	B-General_Concept
scheduler	I-General_Concept
is	O
a	O
scheduler	O
that	O
always	O
tries	O
to	O
keep	O
the	O
scheduled	O
resources	O
busy	O
,	O
if	O
there	O
are	O
submitted	O
jobs	O
ready	O
to	O
be	O
scheduled	O
.	O
</s>
<s>
There	O
are	O
several	O
scheduling	B-Application
problems	O
in	O
which	O
the	O
goal	O
is	O
to	O
decide	O
which	O
job	O
goes	O
to	O
which	O
station	O
at	O
what	O
time	O
,	O
such	O
that	O
the	O
total	O
makespan	B-Algorithm
is	O
minimized	O
:	O
</s>
<s>
Job	B-Algorithm
shop	I-Algorithm
scheduling	I-Algorithm
there	O
are	O
jobs	O
and	O
identical	O
stations	O
.	O
</s>
<s>
Open-shop	B-Algorithm
scheduling	I-Algorithm
there	O
are	O
jobs	O
and	O
different	O
stations	O
.	O
</s>
<s>
Flow	B-Algorithm
shop	I-Algorithm
scheduling	I-Algorithm
there	O
are	O
jobs	O
and	O
different	O
stations	O
.	O
</s>
<s>
A	O
very	O
common	O
method	O
in	O
embedded	B-Architecture
systems	I-Architecture
is	O
to	O
schedule	O
jobs	O
manually	O
.	O
</s>
<s>
Sometimes	O
the	O
kernel	B-Operating_System
is	O
divided	O
in	O
three	O
or	O
more	O
parts	O
:	O
Manual	O
scheduling	B-Application
,	O
preemptive	B-Operating_System
and	O
interrupt	B-Application
level	O
.	O
</s>
<s>
Exact	O
methods	O
for	O
scheduling	B-Application
jobs	O
are	O
often	O
proprietary	O
.	O
</s>
<s>
When	O
designing	O
an	O
operating	B-General_Concept
system	I-General_Concept
,	O
a	O
programmer	O
must	O
consider	O
which	O
scheduling	B-Application
algorithm	O
will	O
perform	O
best	O
for	O
the	O
use	O
the	O
system	O
is	O
going	O
to	O
see	O
.	O
</s>
<s>
There	O
is	O
no	O
universal	O
"	O
best	O
"	O
scheduling	B-Application
algorithm	O
,	O
and	O
many	O
operating	B-General_Concept
systems	I-General_Concept
use	O
extended	O
or	O
combinations	O
of	O
the	O
scheduling	B-Application
algorithms	O
above	O
.	O
</s>
<s>
For	O
example	O
,	O
Windows	O
NT/XP/Vista	O
uses	O
a	O
multilevel	B-Operating_System
feedback	I-Operating_System
queue	I-Operating_System
,	O
a	O
combination	O
of	O
fixed-priority	O
preemptive	B-Operating_System
scheduling	I-Operating_System
,	O
round-robin	B-Algorithm
,	O
and	O
first	B-Operating_System
in	I-Operating_System
,	I-Operating_System
first	I-Operating_System
out	I-Operating_System
algorithms	O
.	O
</s>
<s>
In	O
this	O
system	O
,	O
threads	B-Operating_System
can	O
dynamically	O
increase	O
or	O
decrease	O
in	O
priority	O
depending	O
on	O
if	O
it	O
has	O
been	O
serviced	O
already	O
,	O
or	O
if	O
it	O
has	O
been	O
waiting	O
extensively	O
.	O
</s>
<s>
Every	O
priority	O
level	O
is	O
represented	O
by	O
its	O
own	O
queue	B-Device
,	O
with	O
round-robin	B-Algorithm
scheduling	I-Algorithm
among	O
the	O
high-priority	O
threads	B-Operating_System
and	O
FIFO	B-Operating_System
among	O
the	O
lower-priority	O
ones	O
.	O
</s>
<s>
In	O
this	O
sense	O
,	O
response	O
time	O
is	O
short	O
for	O
most	O
threads	B-Operating_System
,	O
and	O
short	O
but	O
critical	O
system	O
threads	B-Operating_System
get	O
completed	O
very	O
quickly	O
.	O
</s>
<s>
Since	O
threads	B-Operating_System
can	O
only	O
use	O
one	O
time	O
unit	O
of	O
the	O
round-robin	B-Algorithm
in	O
the	O
highest-priority	O
queue	B-Device
,	O
starvation	B-Operating_System
can	O
be	O
a	O
problem	O
for	O
longer	O
high-priority	O
threads	B-Operating_System
.	O
</s>
<s>
The	O
algorithm	O
used	O
may	O
be	O
as	O
simple	O
as	O
round-robin	B-Algorithm
in	O
which	O
each	O
process	B-Operating_System
is	O
given	O
equal	O
time	O
(	O
for	O
instance	O
1ms	O
,	O
usually	O
between	O
1ms	O
and	O
100ms	O
)	O
in	O
a	O
cycling	O
list	O
.	O
</s>
<s>
So	O
,	O
process	B-Operating_System
A	O
executes	O
for	O
1ms	O
,	O
then	O
process	B-Operating_System
B	O
,	O
then	O
process	B-Operating_System
C	O
,	O
then	O
back	O
to	O
process	B-Operating_System
A	O
.	O
</s>
<s>
More	O
advanced	O
algorithms	O
take	O
into	O
account	O
process	B-Operating_System
priority	O
,	O
or	O
the	O
importance	O
of	O
the	O
process	B-Operating_System
.	O
</s>
<s>
This	O
allows	O
some	O
processes	B-Operating_System
to	O
use	O
more	O
time	O
than	O
other	O
processes	B-Operating_System
.	O
</s>
<s>
The	O
kernel	B-Operating_System
always	O
uses	O
whatever	O
resources	O
it	O
needs	O
to	O
ensure	O
proper	O
functioning	O
of	O
the	O
system	O
,	O
and	O
so	O
can	O
be	O
said	O
to	O
have	O
infinite	O
priority	O
.	O
</s>
<s>
In	O
SMP	B-Operating_System
systems	O
,	O
processor	B-Operating_System
affinity	I-Operating_System
is	O
considered	O
to	O
increase	O
overall	O
system	O
performance	O
,	O
even	O
if	O
it	O
may	O
cause	O
a	O
process	B-Operating_System
itself	O
to	O
run	O
more	O
slowly	O
.	O
</s>
<s>
This	O
generally	O
improves	O
performance	O
by	O
reducing	O
cache	B-General_Concept
thrashing	I-General_Concept
.	O
</s>
<s>
IBM	O
OS/360	B-Application
was	O
available	O
with	O
three	O
different	O
schedulers	O
.	O
</s>
<s>
The	O
differences	O
were	O
such	O
that	O
the	O
variants	O
were	O
often	O
considered	O
three	O
different	O
operating	B-General_Concept
systems	I-General_Concept
:	O
</s>
<s>
MFT	O
version	O
II	O
added	O
subtasks	O
(	O
threads	B-Operating_System
)	O
,	O
which	O
executed	O
at	O
a	O
priority	O
based	O
on	O
that	O
of	O
the	O
parent	O
job	O
.	O
</s>
<s>
Later	O
virtual	O
storage	O
versions	O
of	O
MVS	O
added	O
a	O
Workload	B-Application
Manager	I-Application
feature	O
to	O
the	O
scheduler	O
,	O
which	O
schedules	O
processor	O
resources	O
according	O
to	O
an	O
elaborate	O
scheme	O
defined	O
by	O
the	O
installation	O
.	O
</s>
<s>
Very	O
early	O
MS-DOS	B-Application
and	O
Microsoft	O
Windows	O
systems	O
were	O
non-multitasking	O
,	O
and	O
as	O
such	O
did	O
not	O
feature	O
a	O
scheduler	O
.	O
</s>
<s>
Windows	B-Application
3.1x	I-Application
used	O
a	O
non-preemptive	B-Operating_System
scheduler	I-Operating_System
,	O
meaning	O
that	O
it	O
did	O
not	O
interrupt	B-Application
programs	O
.	O
</s>
<s>
It	O
relied	O
on	O
the	O
program	O
to	O
end	O
or	O
tell	O
the	O
OS	O
that	O
it	O
did	O
n't	O
need	O
the	O
processor	O
so	O
that	O
it	O
could	O
move	O
on	O
to	O
another	O
process	B-Operating_System
.	O
</s>
<s>
This	O
is	O
usually	O
called	O
cooperative	B-Operating_System
multitasking	I-Operating_System
.	O
</s>
<s>
Windows	B-Application
95	I-Application
introduced	O
a	O
rudimentary	O
preemptive	B-Operating_System
scheduler	I-Operating_System
;	O
however	O
,	O
for	O
legacy	O
support	O
opted	O
to	O
let	O
16	O
bit	O
applications	O
run	O
without	O
preemption	B-Operating_System
.	O
</s>
<s>
Windows	O
NT-based	O
operating	B-General_Concept
systems	I-General_Concept
use	O
a	O
multilevel	B-Operating_System
feedback	I-Operating_System
queue	I-Operating_System
.	O
</s>
<s>
32	O
priority	O
levels	O
are	O
defined	O
,	O
0	O
through	O
to	O
31	O
,	O
with	O
priorities	O
0	O
through	O
15	O
being	O
"	O
normal	O
"	O
priorities	O
and	O
priorities	O
16	O
through	O
31	O
being	O
soft	O
real-time	B-General_Concept
priorities	O
,	O
requiring	O
privileges	O
to	O
assign	O
.	O
</s>
<s>
0	O
is	O
reserved	O
for	O
the	O
Operating	B-General_Concept
System	I-General_Concept
.	O
</s>
<s>
User	O
interfaces	O
and	O
APIs	O
work	O
with	O
priority	O
classes	O
for	O
the	O
process	B-Operating_System
and	O
the	O
threads	B-Operating_System
in	O
the	O
process	B-Operating_System
,	O
which	O
are	O
then	O
combined	O
by	O
the	O
system	O
into	O
the	O
absolute	O
priority	O
level	O
.	O
</s>
<s>
The	O
kernel	B-Operating_System
may	O
change	O
the	O
priority	O
level	O
of	O
a	O
thread	B-Operating_System
depending	O
on	O
its	O
I/O	O
and	O
CPU	O
usage	O
and	O
whether	O
it	O
is	O
interactive	O
(	O
i.e.	O
</s>
<s>
accepts	O
and	O
responds	O
to	O
input	O
from	O
humans	O
)	O
,	O
raising	O
the	O
priority	O
of	O
interactive	O
and	O
I/O	O
bounded	O
processes	B-Operating_System
and	O
lowering	O
that	O
of	O
CPU	O
bound	O
processes	B-Operating_System
,	O
to	O
increase	O
the	O
responsiveness	O
of	O
interactive	O
applications	O
.	O
</s>
<s>
The	O
scheduler	O
was	O
modified	O
in	O
Windows	B-Application
Vista	I-Application
to	O
use	O
the	O
cycle	B-Device
counter	I-Device
register	I-Device
of	O
modern	O
processors	B-General_Concept
to	O
keep	O
track	O
of	O
exactly	O
how	O
many	O
CPU	O
cycles	O
a	O
thread	B-Operating_System
has	O
executed	O
,	O
rather	O
than	O
just	O
using	O
an	O
interval-timer	O
interrupt	B-Application
routine	O
.	O
</s>
<s>
Vista	B-Application
also	O
uses	O
a	O
priority	O
scheduler	O
for	O
the	O
I/O	O
queue	B-Device
so	O
that	O
disk	O
defragmenters	O
and	O
other	O
such	O
programs	O
do	O
not	O
interfere	O
with	O
foreground	O
operations	O
.	O
</s>
<s>
Mac	B-Operating_System
OS	I-Operating_System
9	I-Operating_System
uses	O
cooperative	B-Operating_System
scheduling	I-Operating_System
for	O
threads	B-Operating_System
,	O
where	O
one	O
process	B-Operating_System
controls	O
multiple	O
cooperative	B-Operating_System
threads	B-Operating_System
,	O
and	O
also	O
provides	O
preemptive	B-Operating_System
scheduling	I-Operating_System
for	O
multiprocessing	O
tasks	O
.	O
</s>
<s>
The	O
kernel	B-Operating_System
schedules	O
multiprocessing	O
tasks	O
using	O
a	O
preemptive	B-Operating_System
scheduling	I-Operating_System
algorithm	O
.	O
</s>
<s>
All	O
Process	B-Operating_System
Manager	O
processes	B-Operating_System
run	O
within	O
a	O
special	O
multiprocessing	O
task	O
,	O
called	O
the	O
"	O
blue	O
task	O
"	O
.	O
</s>
<s>
Those	O
processes	B-Operating_System
are	O
scheduled	O
cooperatively	O
,	O
using	O
a	O
round-robin	B-Algorithm
scheduling	I-Algorithm
algorithm	O
;	O
a	O
process	B-Operating_System
yields	O
control	O
of	O
the	O
processor	O
to	O
another	O
process	B-Operating_System
by	O
explicitly	O
calling	O
a	O
blocking	O
function	O
such	O
as	O
WaitNextEvent	O
.	O
</s>
<s>
Each	O
process	B-Operating_System
has	O
its	O
own	O
copy	O
of	O
the	O
Thread	B-Operating_System
Manager	O
that	O
schedules	O
that	O
process	B-Operating_System
's	O
threads	B-Operating_System
cooperatively	O
;	O
a	O
thread	B-Operating_System
yields	O
control	O
of	O
the	O
processor	O
to	O
another	O
thread	B-Operating_System
by	O
calling	O
YieldToAnyThread	O
or	O
YieldToThread	O
.	O
</s>
<s>
macOS	B-Application
uses	O
a	O
multilevel	B-Operating_System
feedback	I-Operating_System
queue	I-Operating_System
,	O
with	O
four	O
priority	O
bands	O
for	O
threadsnormal	O
,	O
system	O
high	O
priority	O
,	O
kernel	B-Operating_System
mode	O
only	O
,	O
and	O
real-time	B-General_Concept
.	O
</s>
<s>
Threads	B-Operating_System
are	O
scheduled	O
preemptively	O
;	O
macOS	B-Application
also	O
supports	O
cooperatively	O
scheduled	O
threads	B-Operating_System
in	O
its	O
implementation	O
of	O
the	O
Thread	B-Operating_System
Manager	O
in	O
Carbon	B-Operating_System
.	O
</s>
<s>
In	O
AIX	O
Version	O
4	O
there	O
are	O
three	O
possible	O
values	O
for	O
thread	B-Operating_System
scheduling	B-Application
policy	O
:	O
</s>
<s>
First	B-Operating_System
In	I-Operating_System
,	I-Operating_System
First	I-Operating_System
Out	I-Operating_System
:	O
Once	O
a	O
thread	B-Operating_System
with	O
this	O
policy	O
is	O
scheduled	O
,	O
it	O
runs	O
to	O
completion	O
unless	O
it	O
is	O
blocked	O
,	O
it	O
voluntarily	O
yields	O
control	O
of	O
the	O
CPU	O
,	O
or	O
a	O
higher-priority	O
thread	B-Operating_System
becomes	O
dispatchable	O
.	O
</s>
<s>
Only	O
fixed-priority	O
threads	B-Operating_System
can	O
have	O
a	O
FIFO	B-Operating_System
scheduling	B-Application
policy	O
.	O
</s>
<s>
Round	O
Robin	O
:	O
This	O
is	O
similar	O
to	O
the	O
AIX	O
Version	O
3	O
scheduler	O
round-robin	B-Algorithm
scheme	O
based	O
on	O
10ms	O
time	O
slices	O
.	O
</s>
<s>
When	O
a	O
RR	O
thread	B-Operating_System
has	O
control	O
at	O
the	O
end	O
of	O
the	O
time	O
slice	O
,	O
it	O
moves	O
to	O
the	O
tail	O
of	O
the	O
queue	B-Device
of	O
dispatchable	O
threads	B-Operating_System
of	O
its	O
priority	O
.	O
</s>
<s>
Only	O
fixed-priority	O
threads	B-Operating_System
can	O
have	O
a	O
Round	B-Algorithm
Robin	I-Algorithm
scheduling	I-Algorithm
policy	O
.	O
</s>
<s>
In	O
AIX	O
Version	O
4	O
,	O
this	O
policy	O
is	O
defined	O
to	O
be	O
equivalent	O
to	O
RR	O
,	O
except	O
that	O
it	O
applies	O
to	O
threads	B-Operating_System
with	O
non-fixed	O
priority	O
.	O
</s>
<s>
The	O
recalculation	O
of	O
the	O
running	O
thread	B-Operating_System
's	O
priority	O
value	O
at	O
each	O
clock	O
interrupt	B-Application
means	O
that	O
a	O
thread	B-Operating_System
may	O
lose	O
control	O
because	O
its	O
priority	O
value	O
has	O
risen	O
above	O
that	O
of	O
another	O
dispatchable	O
thread	B-Operating_System
.	O
</s>
<s>
Threads	B-Operating_System
are	O
primarily	O
of	O
interest	O
for	O
applications	O
that	O
currently	O
consist	O
of	O
several	O
asynchronous	O
processes	B-Operating_System
.	O
</s>
<s>
AIX	O
5	O
implements	O
the	O
following	O
scheduling	B-Application
policies	O
:	O
FIFO	B-Operating_System
,	O
round	O
robin	O
,	O
and	O
a	O
fair	O
round	O
robin	O
.	O
</s>
<s>
The	O
FIFO	B-Operating_System
policy	O
has	O
three	O
different	O
implementations	O
:	O
FIFO	B-Operating_System
,	O
FIFO2	O
,	O
and	O
FIFO3	O
.	O
</s>
<s>
In	O
Linux	B-Operating_System
2.4	I-Operating_System
,	O
an	O
O(n )	O
scheduler	O
with	O
a	O
multilevel	B-Operating_System
feedback	I-Operating_System
queue	I-Operating_System
with	O
priority	O
levels	O
ranging	O
from	O
0	O
to	O
140	O
was	O
used	O
;	O
099	O
are	O
reserved	O
for	O
real-time	B-General_Concept
tasks	O
and	O
100140	O
are	O
considered	O
nice	B-Device
task	O
levels	O
.	O
</s>
<s>
For	O
real-time	B-General_Concept
tasks	O
,	O
the	O
time	O
quantum	O
for	O
switching	O
processes	B-Operating_System
was	O
approximately	O
200ms	O
,	O
and	O
for	O
nice	B-Device
tasks	O
approximately	O
10	O
ms.	O
</s>
<s>
The	O
scheduler	O
ran	O
through	O
the	O
run	B-Application
queue	I-Application
of	O
all	O
ready	O
processes	B-Operating_System
,	O
letting	O
the	O
highest	O
priority	O
processes	B-Operating_System
go	O
first	O
and	O
run	O
through	O
their	O
time	O
slices	O
,	O
after	O
which	O
they	O
will	O
be	O
placed	O
in	O
an	O
expired	O
queue	B-Device
.	O
</s>
<s>
When	O
the	O
active	O
queue	B-Device
is	O
empty	O
the	O
expired	O
queue	B-Device
will	O
become	O
the	O
active	O
queue	B-Device
and	O
vice	O
versa	O
.	O
</s>
<s>
However	O
,	O
some	O
enterprise	O
Linux	B-Application
distributions	I-Application
such	O
as	O
SUSE	O
Linux	B-Operating_System
Enterprise	O
Server	O
replaced	O
this	O
scheduler	O
with	O
a	O
backport	O
of	O
the	O
O(1 )	O
scheduler	O
(	O
which	O
was	O
maintained	O
by	O
Alan	O
Cox	O
in	O
his	O
Linux	B-Operating_System
2.4-ac	O
Kernel	B-Operating_System
series	O
)	O
to	O
the	O
Linux	B-Operating_System
2.4	I-Operating_System
kernel	B-Operating_System
used	O
by	O
the	O
distribution	O
.	O
</s>
<s>
In	O
versions	O
2.6.0	O
to	O
2.6.22	O
,	O
the	O
kernel	B-Operating_System
used	O
an	O
O(1 )	O
scheduler	O
developed	O
by	O
Ingo	O
Molnar	O
and	O
many	O
other	O
kernel	B-Operating_System
developers	O
during	O
the	O
Linux	B-Operating_System
2.5	O
development	O
.	O
</s>
<s>
For	O
many	O
kernel	B-Operating_System
in	O
time	O
frame	O
,	O
Con	O
Kolivas	O
developed	O
patch	O
sets	O
which	O
improved	O
interactivity	O
with	O
this	O
scheduler	O
or	O
even	O
replaced	O
it	O
with	O
his	O
own	O
schedulers	O
.	O
</s>
<s>
Con	O
Kolivas	O
 '	O
work	O
,	O
most	O
significantly	O
his	O
implementation	O
of	O
"	O
fair	B-Algorithm
scheduling	I-Algorithm
"	O
named	O
"	O
Rotating	O
Staircase	O
Deadline	O
"	O
,	O
inspired	O
Ingo	O
Molnár	O
to	O
develop	O
the	O
Completely	B-Application
Fair	I-Application
Scheduler	I-Application
as	O
a	O
replacement	O
for	O
the	O
earlier	O
O(1 )	O
scheduler	O
,	O
crediting	O
Kolivas	O
in	O
his	O
announcement	O
.	O
</s>
<s>
CFS	O
is	O
the	O
first	O
implementation	O
of	O
a	O
fair	B-Algorithm
queuing	I-Algorithm
process	B-Operating_System
scheduler	O
widely	O
used	O
in	O
a	O
general-purpose	B-General_Concept
operating	I-General_Concept
system	I-General_Concept
.	O
</s>
<s>
The	O
Completely	B-Application
Fair	I-Application
Scheduler	I-Application
(	O
CFS	O
)	O
uses	O
a	O
well-studied	O
,	O
classic	O
scheduling	B-Application
algorithm	O
called	O
fair	B-Algorithm
queuing	I-Algorithm
originally	O
invented	O
for	O
packet	B-Protocol
networks	I-Protocol
.	O
</s>
<s>
Fair	B-Algorithm
queuing	I-Algorithm
had	O
been	O
previously	O
applied	O
to	O
CPU	O
scheduling	B-Application
under	O
the	O
name	O
stride	B-Operating_System
scheduling	I-Operating_System
.	O
</s>
<s>
The	O
fair	B-Algorithm
queuing	I-Algorithm
CFS	B-Application
scheduler	I-Application
has	O
a	O
scheduling	B-Application
complexity	O
of	O
,	O
where	O
is	O
the	O
number	O
of	O
tasks	O
in	O
the	O
runqueue	B-Application
.	O
</s>
<s>
Choosing	O
a	O
task	O
can	O
be	O
done	O
in	O
constant	O
time	O
,	O
but	O
reinserting	O
a	O
task	O
after	O
it	O
has	O
run	O
requires	O
operations	O
,	O
because	O
the	O
run	B-Application
queue	I-Application
is	O
implemented	O
as	O
a	O
red	O
–	O
black	O
tree	O
.	O
</s>
<s>
The	O
Brain	B-Application
Fuck	I-Application
Scheduler	I-Application
,	O
also	O
created	O
by	O
Con	O
Kolivas	O
,	O
is	O
an	O
alternative	O
to	O
the	O
CFS	O
.	O
</s>
<s>
FreeBSD	B-Operating_System
uses	O
a	O
multilevel	B-Operating_System
feedback	I-Operating_System
queue	I-Operating_System
with	O
priorities	O
ranging	O
from	O
0	O
–	O
255	O
.	O
</s>
<s>
0	O
–	O
63	O
are	O
reserved	O
for	O
interrupts	B-Application
,	O
64	O
–	O
127	O
for	O
the	O
top	O
half	O
of	O
the	O
kernel	B-Operating_System
,	O
128	O
–	O
159	O
for	O
real-time	B-General_Concept
user	O
threads	B-Operating_System
,	O
160	O
–	O
223	O
for	O
time-shared	O
user	O
threads	B-Operating_System
,	O
and	O
224	O
–	O
255	O
for	O
idle	O
user	O
threads	B-Operating_System
.	O
</s>
<s>
Also	O
,	O
like	O
Linux	B-Operating_System
,	O
it	O
uses	O
the	O
active	O
queue	B-Device
setup	O
,	O
but	O
it	O
also	O
has	O
an	O
idle	O
queue	B-Device
.	O
</s>
<s>
NetBSD	B-Device
uses	O
a	O
multilevel	B-Operating_System
feedback	I-Operating_System
queue	I-Operating_System
with	O
priorities	O
ranging	O
from	O
0	O
–	O
223	O
.	O
</s>
<s>
0	O
–	O
63	O
are	O
reserved	O
for	O
time-shared	O
threads	B-Operating_System
(	O
default	O
,	O
SCHED_OTHER	O
policy	O
)	O
,	O
64	O
–	O
95	O
for	O
user	O
threads	B-Operating_System
which	O
entered	O
kernel	B-Operating_System
space	I-Operating_System
,	O
96-128	O
for	O
kernel	B-Operating_System
threads	B-Operating_System
,	O
128	O
–	O
191	O
for	O
user	O
real-time	B-General_Concept
threads	B-Operating_System
(	O
SCHED_FIFO	O
and	O
SCHED_RR	O
policies	O
)	O
,	O
and	O
192	O
–	O
223	O
for	O
software	B-Application
interrupts	I-Application
.	O
</s>
<s>
Solaris	B-Application
uses	O
a	O
multilevel	B-Operating_System
feedback	I-Operating_System
queue	I-Operating_System
with	O
priorities	O
ranging	O
between	O
0	O
and	O
169	O
.	O
</s>
<s>
Priorities	O
059	O
are	O
reserved	O
for	O
time-shared	O
threads	B-Operating_System
,	O
6099	O
for	O
system	O
threads	B-Operating_System
,	O
100159	O
for	O
real-time	B-General_Concept
threads	B-Operating_System
,	O
and	O
160169	O
for	O
low	O
priority	O
interrupts	B-Application
.	O
</s>
<s>
Unlike	O
Linux	B-Operating_System
,	O
when	O
a	O
process	B-Operating_System
is	O
done	O
using	O
its	O
time	O
quantum	O
,	O
it	O
is	O
given	O
a	O
new	O
priority	O
and	O
put	O
back	O
in	O
the	O
queue	B-Device
.	O
</s>
<s>
Solaris9	O
introduced	O
two	O
new	O
scheduling	B-Application
classes	O
,	O
namely	O
fixed	O
priority	O
class	O
and	O
fair	O
share	O
class	O
.	O
</s>
<s>
The	O
threads	B-Operating_System
with	O
fixed	O
priority	O
have	O
the	O
same	O
priority	O
range	O
as	O
that	O
of	O
the	O
time-sharing	O
class	O
,	O
but	O
their	O
priorities	O
are	O
not	O
dynamically	O
adjusted	O
.	O
</s>
<s>
The	O
fair	B-Algorithm
scheduling	I-Algorithm
class	O
uses	O
CPU	O
shares	O
to	O
prioritize	O
threads	B-Operating_System
for	O
scheduling	B-Application
decisions	O
.	O
</s>
<s>
They	O
are	O
allocated	O
to	O
a	O
set	O
of	O
processes	B-Operating_System
,	O
which	O
are	O
collectively	O
known	O
as	O
a	O
project	O
.	O
</s>
