<s>
Working	B-General_Concept
set	I-General_Concept
is	O
a	O
concept	O
in	O
computer	B-General_Concept
science	I-General_Concept
which	O
defines	O
the	O
amount	O
of	O
memory	O
that	O
a	O
process	B-Operating_System
requires	O
in	O
a	O
given	O
time	O
interval	O
.	O
</s>
<s>
Peter	O
Denning	O
(	O
1968	O
)	O
defines	O
"	O
the	O
working	B-General_Concept
set	I-General_Concept
of	O
information	O
of	O
a	O
process	B-Operating_System
at	O
time	O
to	O
be	O
the	O
collection	O
of	O
information	O
referenced	O
by	O
the	O
process	B-Operating_System
during	O
the	O
process	B-Operating_System
time	O
interval	O
"	O
.	O
</s>
<s>
Typically	O
the	O
units	O
of	O
information	O
in	O
question	O
are	O
considered	O
to	O
be	O
memory	B-General_Concept
pages	I-General_Concept
.	O
</s>
<s>
This	O
is	O
suggested	O
to	O
be	O
an	O
approximation	O
of	O
the	O
set	O
of	O
pages	O
that	O
the	O
process	B-Operating_System
will	O
access	O
in	O
the	O
future	O
(	O
say	O
during	O
the	O
next	O
time	O
units	O
)	O
,	O
and	O
more	O
specifically	O
is	O
suggested	O
to	O
be	O
an	O
indication	O
of	O
what	O
pages	O
ought	O
to	O
be	O
kept	O
in	O
main	O
memory	O
to	O
allow	O
most	O
progress	O
to	O
be	O
made	O
in	O
the	O
execution	O
of	O
that	O
process	B-Operating_System
.	O
</s>
<s>
The	O
effect	O
of	O
the	O
choice	O
of	O
what	O
pages	O
to	O
be	O
kept	O
in	O
main	O
memory	O
(	O
as	O
distinct	O
from	O
being	O
paged	O
out	O
to	O
auxiliary	O
storage	O
)	O
is	O
important	O
:	O
if	O
too	O
many	O
pages	O
of	O
a	O
process	B-Operating_System
are	O
kept	O
in	O
main	O
memory	O
,	O
then	O
fewer	O
other	O
processes	B-Operating_System
can	O
be	O
ready	O
at	O
any	O
one	O
time	O
.	O
</s>
<s>
If	O
too	O
few	O
pages	O
of	O
a	O
process	B-Operating_System
are	O
kept	O
in	O
main	O
memory	O
,	O
then	O
its	O
page	B-General_Concept
fault	I-General_Concept
frequency	O
is	O
greatly	O
increased	O
and	O
the	O
number	O
of	O
active	O
(	O
non-suspended	O
)	O
processes	B-Operating_System
currently	O
executing	O
in	O
the	O
system	O
approaches	O
zero	O
.	O
</s>
<s>
The	O
working	B-General_Concept
set	I-General_Concept
model	I-General_Concept
states	O
that	O
a	O
process	B-Operating_System
can	O
be	O
in	O
RAM	B-Architecture
if	O
and	O
only	O
if	O
all	O
of	O
the	O
pages	O
that	O
it	O
is	O
currently	O
using	O
(	O
often	O
approximated	O
by	O
the	O
most	O
recently	O
used	O
pages	O
)	O
can	O
be	O
in	O
RAM	B-Architecture
.	O
</s>
<s>
The	O
model	O
is	O
an	O
all	O
or	O
nothing	O
model	O
,	O
meaning	O
if	O
the	O
pages	O
it	O
needs	O
to	O
use	O
increases	O
,	O
and	O
there	O
is	O
no	O
room	O
in	O
RAM	B-Architecture
,	O
the	O
process	B-Operating_System
is	O
swapped	O
out	O
of	O
memory	O
to	O
free	O
the	O
memory	O
for	O
other	O
processes	B-Operating_System
to	O
use	O
.	O
</s>
<s>
Often	O
a	O
heavily	O
loaded	B-Operating_System
computer	O
has	O
so	O
many	O
processes	B-Operating_System
queued	O
up	O
that	O
,	O
if	O
all	O
the	O
processes	B-Operating_System
were	O
allowed	O
to	O
run	O
for	O
one	O
scheduling	O
time	O
slice	O
,	O
they	O
would	O
refer	O
to	O
more	O
pages	O
than	O
there	O
is	O
RAM	B-Architecture
,	O
causing	O
the	O
computer	O
to	O
"	O
thrash	B-General_Concept
"	O
.	O
</s>
<s>
By	O
swapping	O
some	O
processes	B-Operating_System
from	O
memory	O
,	O
the	O
result	O
is	O
that	O
processes	B-Operating_System
—	O
even	O
processes	B-Operating_System
that	O
were	O
temporarily	O
removed	O
from	O
memory	O
—	O
finish	O
much	O
sooner	O
than	O
they	O
would	O
if	O
the	O
computer	O
attempted	O
to	O
run	O
them	O
all	O
at	O
once	O
.	O
</s>
<s>
The	O
processes	B-Operating_System
also	O
finish	O
much	O
sooner	O
than	O
they	O
would	O
if	O
the	O
computer	O
only	O
ran	O
one	O
process	B-Operating_System
at	O
a	O
time	O
to	O
completion	O
since	O
it	O
allows	O
other	O
processes	B-Operating_System
to	O
run	O
and	O
make	O
progress	O
during	O
times	O
that	O
one	O
process	B-Operating_System
is	O
waiting	O
on	O
the	O
hard	O
drive	O
or	O
some	O
other	O
global	O
resource	O
.	O
</s>
<s>
In	O
other	O
words	O
,	O
the	O
working	B-General_Concept
set	I-General_Concept
strategy	O
prevents	O
thrashing	B-General_Concept
while	O
keeping	O
the	O
degree	O
of	O
multiprogramming	O
as	O
high	O
as	O
possible	O
.	O
</s>
<s>
The	O
main	O
hurdle	O
in	O
implementing	O
the	O
working	B-General_Concept
set	I-General_Concept
model	I-General_Concept
is	O
keeping	O
track	O
of	O
the	O
working	B-General_Concept
set	I-General_Concept
.	O
</s>
<s>
The	O
working	B-General_Concept
set	I-General_Concept
window	O
is	O
a	O
moving	O
window	O
.	O
</s>
<s>
A	O
page	O
is	O
in	O
the	O
working	B-General_Concept
set	I-General_Concept
if	O
it	O
is	O
referenced	O
in	O
the	O
working	B-General_Concept
set	I-General_Concept
window	O
.	O
</s>
<s>
To	O
avoid	O
the	O
overhead	O
of	O
keeping	O
a	O
list	O
of	O
the	O
last	O
k	O
referenced	O
pages	O
,	O
the	O
working	B-General_Concept
set	I-General_Concept
is	O
often	O
implemented	O
by	O
keeping	O
track	O
of	O
the	O
time	O
t	O
of	O
the	O
last	O
reference	O
,	O
and	O
considering	O
the	O
working	B-General_Concept
set	I-General_Concept
to	O
be	O
all	O
pages	O
referenced	O
within	O
a	O
certain	O
period	O
of	O
time	O
.	O
</s>
<s>
The	O
working	B-General_Concept
set	I-General_Concept
is	O
n't	O
a	O
page	B-General_Concept
replacement	I-General_Concept
algorithm	I-General_Concept
,	O
but	O
page-replacement	O
algorithms	O
can	O
be	O
designed	O
to	O
only	O
remove	O
pages	O
that	O
are	O
n't	O
in	O
the	O
working	B-General_Concept
set	I-General_Concept
for	O
a	O
particular	O
process	B-Operating_System
.	O
</s>
<s>
Working	B-General_Concept
set	I-General_Concept
can	O
be	O
divided	O
into	O
code	O
working	B-General_Concept
set	I-General_Concept
and	O
data	O
working	B-General_Concept
set	I-General_Concept
.	O
</s>
<s>
This	O
distinction	O
is	O
important	O
when	O
code	O
and	O
data	O
are	O
separate	O
at	O
the	O
relevant	O
level	O
of	O
the	O
memory	O
hierarchy	O
,	O
as	O
if	O
either	O
working	B-General_Concept
set	I-General_Concept
does	O
not	O
fit	O
in	O
that	O
level	O
of	O
the	O
hierarchy	O
,	O
thrashing	B-General_Concept
will	O
occur	O
.	O
</s>
<s>
In	O
addition	O
to	O
the	O
code	O
and	O
data	O
themselves	O
,	O
on	O
systems	O
with	O
virtual	B-Architecture
memory	I-Architecture
,	O
the	O
memory	B-General_Concept
map	I-General_Concept
(	O
of	O
virtual	B-Architecture
memory	I-Architecture
to	O
physical	O
memory	O
)	O
entries	O
of	O
the	O
pages	O
of	O
the	O
working	B-General_Concept
set	I-General_Concept
must	O
be	O
cached	O
in	O
the	O
translation	B-Architecture
lookaside	I-Architecture
buffer	I-Architecture
(	O
TLB	O
)	O
for	O
the	O
process	B-Operating_System
to	O
progress	O
efficiently	O
.	O
</s>
<s>
This	O
distinction	O
exists	O
because	O
code	O
and	O
data	O
are	O
cached	O
in	O
small	O
blocks	O
(	O
cache	B-General_Concept
lines	I-General_Concept
)	O
,	O
not	O
entire	O
pages	O
,	O
but	O
address	O
lookup	O
is	O
done	O
at	O
the	O
page	O
level	O
.	O
</s>
<s>
Thus	O
even	O
if	O
the	O
code	O
and	O
data	O
working	B-General_Concept
sets	I-General_Concept
fit	O
into	O
cache	O
,	O
if	O
the	O
working	B-General_Concept
sets	I-General_Concept
are	O
split	O
across	O
many	O
pages	O
,	O
the	O
virtual	O
address	O
working	B-General_Concept
set	I-General_Concept
may	O
not	O
fit	O
into	O
TLB	O
,	O
causing	O
TLB	O
thrashing	B-General_Concept
.	O
</s>
<s>
Analogs	O
of	O
working	B-General_Concept
set	I-General_Concept
exist	O
for	O
other	O
limited	O
resources	O
,	O
most	O
significantly	O
processes	B-Operating_System
.	O
</s>
<s>
If	O
a	O
set	O
of	O
processes	B-Operating_System
requires	O
frequent	O
interaction	O
between	O
multiple	O
processes	B-Operating_System
,	O
then	O
it	O
has	O
a	O
that	O
must	O
be	O
coscheduled	B-Operating_System
in	O
order	O
to	O
progress	O
:	O
</s>
<s>
If	O
the	O
processes	B-Operating_System
are	O
not	O
scheduled	O
simultaneously	O
–	O
for	O
example	O
,	O
if	O
there	O
are	O
two	O
processes	B-Operating_System
but	O
only	O
one	O
core	O
on	O
which	O
to	O
execute	O
them	O
–	O
then	O
the	O
processes	B-Operating_System
can	O
only	O
advance	O
at	O
the	O
rate	O
of	O
one	O
interaction	O
per	O
time	O
slice	O
.	O
</s>
<s>
Other	O
resources	O
include	O
file	B-Application
handles	I-Application
or	O
network	B-Protocol
sockets	I-Protocol
–	O
for	O
example	O
,	O
copying	O
one	O
file	O
to	O
another	O
is	O
most	O
simply	O
done	O
with	O
two	O
file	B-Application
handles	I-Application
:	O
one	O
for	O
input	O
,	O
one	O
for	O
output	O
,	O
and	O
thus	O
has	O
a	O
"	O
file	B-Application
handle	I-Application
working	B-General_Concept
set	I-General_Concept
"	O
size	O
of	O
two	O
.	O
</s>
<s>
If	O
only	O
one	O
file	B-Application
handle	I-Application
is	O
available	O
,	O
copying	O
can	O
still	O
be	O
done	O
,	O
but	O
requires	O
acquiring	O
a	O
file	B-Application
handle	I-Application
for	O
the	O
input	O
,	O
reading	O
from	O
it	O
(	O
say	O
into	O
a	O
buffer	O
)	O
,	O
releasing	O
it	O
,	O
then	O
acquiring	O
a	O
file	B-Application
handle	I-Application
for	O
the	O
output	O
,	O
writing	O
to	O
it	O
,	O
releasing	O
it	O
,	O
then	O
acquiring	O
the	O
input	O
file	B-Application
handle	I-Application
again	O
and	O
repeating	O
.	O
</s>
<s>
Rather	O
than	O
thrashing	B-General_Concept
,	O
these	O
resources	O
are	O
typically	O
required	O
for	O
the	O
program	O
,	O
and	O
if	O
it	O
cannot	O
acquire	O
enough	O
resources	O
,	O
it	O
simply	O
fails	O
.	O
</s>
