<s>
Parallel	B-Library
Extensions	I-Library
was	O
the	O
development	O
name	O
for	O
a	O
managed	O
concurrency	B-Architecture
library	B-Library
developed	O
by	O
a	O
collaboration	O
between	O
Microsoft	O
Research	O
and	O
the	O
CLR	O
team	O
at	O
Microsoft	O
.	O
</s>
<s>
The	O
library	B-Library
was	O
released	O
in	O
version	O
4.0	O
of	O
the	O
.NET	B-Application
Framework	I-Application
.	O
</s>
<s>
It	O
is	O
composed	O
of	O
two	O
parts	O
:	O
Parallel	O
LINQ	B-Language
(	O
PLINQ	O
)	O
and	O
Task	O
Parallel	O
Library	B-Library
(	O
TPL	O
)	O
.	O
</s>
<s>
It	O
also	O
consists	O
of	O
a	O
set	O
of	O
coordination	O
data	B-General_Concept
structures	I-General_Concept
(	O
CDS	O
)	O
–	O
sets	O
of	O
data	B-General_Concept
structures	I-General_Concept
used	O
to	O
synchronize	O
and	O
co-ordinate	O
the	O
execution	O
of	O
concurrent	O
tasks	O
.	O
</s>
<s>
PLINQ	O
,	O
or	O
Parallel	O
LINQ	B-Language
,	O
parallelizing	O
the	O
execution	O
of	O
queries	O
on	O
objects	O
(	O
LINQ	B-Language
to	O
Objects	O
)	O
and	O
XML	O
data	O
(	O
LINQ	B-Language
to	O
XML	O
)	O
.	O
</s>
<s>
PLINQ	O
is	O
intended	O
for	O
exposing	O
data	B-Operating_System
parallelism	I-Operating_System
by	O
use	O
of	O
queries	O
.	O
</s>
<s>
The	O
Task	O
Parallel	O
Library	B-Library
(	O
TPL	O
)	O
is	O
the	O
task	B-Operating_System
parallelism	I-Operating_System
component	O
of	O
the	O
Parallel	B-Library
Extensions	I-Library
to	O
.NET	B-Application
.	O
</s>
<s>
It	O
exposes	O
parallel	O
constructs	O
like	O
parallel	O
For	O
and	O
ForEach	O
loops	O
,	O
using	O
regular	O
method	O
calls	O
and	O
delegates	O
,	O
thus	O
the	O
constructs	O
can	O
be	O
used	O
from	O
any	O
CLI	B-Language
languages	I-Language
.	O
</s>
<s>
The	O
job	O
of	O
spawning	O
and	O
terminating	O
threads	B-Operating_System
,	O
as	O
well	O
as	O
scaling	O
the	O
number	O
of	O
threads	B-Operating_System
according	O
to	O
the	O
number	O
of	O
available	O
processors	O
,	O
is	O
done	O
by	O
the	O
library	B-Library
itself	O
,	O
using	O
a	O
work	B-Operating_System
stealing	I-Operating_System
scheduler	O
.	O
</s>
<s>
TPL	O
also	O
includes	O
other	O
constructs	O
like	O
Task	O
and	O
Future	B-Operating_System
.	O
</s>
<s>
In	O
that	O
sense	O
,	O
it	O
is	O
semantically	O
equivalent	O
to	O
a	O
thread	B-Operating_System
,	O
except	O
that	O
it	O
is	O
a	O
more	O
light-weight	O
object	O
and	O
comes	O
without	O
the	O
overhead	O
of	O
creating	O
an	O
OS	O
thread	B-Operating_System
.	O
</s>
<s>
Tasks	O
are	O
queued	O
by	O
a	O
Task	O
Manager	O
object	O
and	O
are	O
scheduled	O
to	O
run	O
on	O
multiple	O
OS	O
threads	B-Operating_System
in	O
a	O
thread	B-Operating_System
pool	I-Operating_System
when	O
their	O
turn	O
comes	O
.	O
</s>
<s>
Future	B-Operating_System
is	O
a	O
task	O
that	O
returns	O
a	O
result	O
.	O
</s>
<s>
The	O
result	O
is	O
computed	O
in	O
a	O
background	O
thread	B-Operating_System
encapsulated	O
by	O
the	O
Future	B-Operating_System
object	O
,	O
and	O
the	O
result	O
is	O
buffered	O
until	O
it	O
is	O
retrieved	O
.	O
</s>
<s>
If	O
an	O
attempt	O
is	O
made	O
to	O
retrieve	O
the	O
result	O
before	O
it	O
has	O
been	O
computed	O
then	O
the	O
requesting	O
thread	B-Operating_System
will	O
block	O
until	O
the	O
result	O
is	O
available	O
.	O
</s>
<s>
The	O
main	O
concept	O
in	O
the	O
Parallel	B-Library
Extensions	I-Library
to	O
.NET	B-Application
is	O
a	O
Task	O
,	O
which	O
is	O
a	O
small	O
unit	O
of	O
code	O
,	O
usually	O
represented	O
as	O
a	O
lambda	B-General_Concept
function	I-General_Concept
,	O
that	O
can	O
be	O
executed	O
independently	O
.	O
</s>
<s>
A	O
Task	O
Manager	O
contains	O
a	O
global	O
queue	B-Application
of	O
Tasks	O
,	O
which	O
are	O
then	O
executed	O
.	O
</s>
<s>
It	O
also	O
encapsulates	O
multiple	O
threads	B-Operating_System
onto	O
which	O
the	O
Tasks	O
are	O
executed	O
.	O
</s>
<s>
By	O
default	O
,	O
as	O
many	O
threads	B-Operating_System
as	O
there	O
are	O
processors	O
(	O
or	O
processor	O
cores	O
)	O
on	O
the	O
system	O
are	O
created	O
,	O
though	O
this	O
number	O
may	O
be	O
manually	O
modified	O
.	O
</s>
<s>
Each	O
thread	B-Operating_System
is	O
associated	O
with	O
a	O
thread-specific	O
queue	B-Application
of	O
Tasks	O
.	O
</s>
<s>
When	O
idle	O
,	O
each	O
thread	B-Operating_System
picks	O
up	O
a	O
batch	O
of	O
Tasks	O
and	O
puts	O
them	O
on	O
its	O
local	O
queue	B-Application
,	O
where	O
they	O
are	O
then	O
executed	O
,	O
one	O
by	O
one	O
.	O
</s>
<s>
If	O
the	O
global	O
queue	B-Application
is	O
empty	O
,	O
a	O
thread	B-Operating_System
will	O
look	O
for	O
Tasks	O
in	O
the	O
queues	B-Application
of	O
its	O
peers	O
,	O
and	O
will	O
take	O
the	O
Tasks	O
which	O
have	O
been	O
in	O
the	O
queue	B-Application
the	O
longest	O
(	O
task	O
stealing	O
)	O
.	O
</s>
