<s>
In	O
computer	B-General_Concept
science	I-General_Concept
,	O
a	O
fiber	O
is	O
a	O
particularly	O
lightweight	O
thread	B-Operating_System
of	I-Operating_System
execution	I-Operating_System
.	O
</s>
<s>
Like	O
threads	B-Operating_System
,	O
fibers	O
share	O
address	B-General_Concept
space	I-General_Concept
.	O
</s>
<s>
However	O
,	O
fibers	O
use	O
cooperative	B-Operating_System
multitasking	I-Operating_System
while	O
threads	B-Operating_System
use	O
preemptive	O
multitasking	O
.	O
</s>
<s>
Threads	B-Operating_System
often	O
depend	O
on	O
the	O
kernel	O
's	O
thread	B-Operating_System
scheduler	O
to	O
preempt	O
a	O
busy	O
thread	B-Operating_System
and	O
resume	O
another	O
thread	B-Operating_System
;	O
fibers	O
yield	O
themselves	O
to	O
run	O
another	O
fiber	O
while	O
executing	O
.	O
</s>
<s>
The	O
key	O
difference	O
between	O
fibers	O
and	O
kernel	O
threads	B-Operating_System
is	O
that	O
fibers	O
use	O
cooperative	O
context	O
switching	O
,	O
instead	O
of	O
preemptive	O
time-slicing	O
.	O
</s>
<s>
Fibers	O
(	O
sometimes	O
called	O
stackful	O
coroutines	O
or	O
user	O
mode	O
cooperatively	O
scheduled	O
threads	B-Operating_System
)	O
and	O
stackless	O
coroutines	O
(	O
compiler	O
synthesized	O
state	O
machines	O
)	O
represent	O
two	O
distinct	O
programming	O
facilities	O
with	O
vast	O
performance	O
and	O
functionality	O
differences	O
.	O
</s>
<s>
Because	O
fibers	O
multitask	O
cooperatively	O
,	O
thread	B-Operating_System
safety	I-Operating_System
is	O
less	O
of	O
an	O
issue	O
than	O
with	O
preemptively	O
scheduled	O
threads	B-Operating_System
,	O
and	O
synchronization	O
constructs	O
including	O
spinlocks	B-Operating_System
and	O
atomic	B-General_Concept
operations	I-General_Concept
are	O
unnecessary	O
when	O
writing	O
fibered	O
code	O
,	O
as	O
they	O
are	O
implicitly	O
synchronized	O
.	O
</s>
<s>
However	O
,	O
many	O
libraries	O
yield	O
a	O
fiber	O
implicitly	O
as	O
a	O
method	O
of	O
conducting	O
non-blocking	B-Architecture
I/O	I-Architecture
;	O
as	O
such	O
,	O
some	O
caution	O
and	O
documentation	O
reading	O
is	O
advised	O
.	O
</s>
<s>
A	O
disadvantage	O
is	O
that	O
fibers	O
cannot	O
utilize	O
multiprocessor	B-Operating_System
machines	O
without	O
also	O
using	O
preemptive	O
threads	B-Operating_System
;	O
however	O
,	O
an	O
M:N	O
threading	O
model	O
with	O
no	O
more	O
preemptive	O
threads	B-Operating_System
than	O
CPU	O
cores	O
can	O
be	O
more	O
efficient	O
than	O
either	O
pure	O
fibers	O
or	O
pure	O
preemptive	O
threading	O
.	O
</s>
<s>
In	O
some	O
server	O
programs	O
fibers	O
are	O
used	O
to	O
soft	O
block	O
themselves	O
to	O
allow	O
their	O
single-threaded	B-Operating_System
parent	O
programs	O
to	O
continue	O
working	O
.	O
</s>
<s>
Fibers	O
yield	O
control	O
to	O
the	O
single-threaded	B-Operating_System
main	O
program	O
,	O
and	O
when	O
the	O
I/O	O
operation	O
is	O
completed	O
fibers	O
continue	O
where	O
they	O
left	O
off	O
.	O
</s>
<s>
Less	O
support	O
from	O
the	O
operating	B-General_Concept
system	I-General_Concept
is	O
needed	O
for	O
fibers	O
than	O
for	O
threads	B-Operating_System
.	O
</s>
<s>
They	O
can	O
be	O
implemented	O
in	O
modern	O
Unix	B-Application
systems	I-Application
using	O
the	O
library	O
functions	O
getcontext	B-Operating_System
,	I-Operating_System
setcontext	I-Operating_System
and	I-Operating_System
swapcontext	I-Operating_System
in	O
ucontext.h	O
,	O
as	O
in	O
GNU	B-Application
Portable	I-Application
Threads	I-Application
,	O
or	O
in	O
assembler	O
as	O
.	O
</s>
<s>
On	O
Microsoft	B-Application
Windows	I-Application
,	O
fibers	O
are	O
created	O
using	O
the	O
ConvertThreadToFiber	O
and	O
CreateFiber	O
calls	O
;	O
a	O
fiber	O
that	O
is	O
currently	O
suspended	O
may	O
be	O
resumed	O
in	O
any	O
thread	B-Operating_System
.	O
</s>
<s>
Fiber-local	O
storage	O
,	O
analogous	O
to	O
thread-local	O
storage	O
,	O
may	O
be	O
used	O
to	O
create	O
unique	O
copies	O
of	O
variables	O
.	O
</s>
<s>
Symbian	B-Operating_System
OS	I-Operating_System
used	O
a	O
similar	O
concept	O
to	O
fibers	O
in	O
its	O
Active	O
Scheduler	O
.	O
</s>
<s>
An	O
active	B-Language
object	I-Language
contained	O
one	O
fiber	O
to	O
be	O
executed	O
by	O
the	O
Active	O
Scheduler	O
when	O
one	O
of	O
several	O
outstanding	O
asynchronous	O
calls	O
completed	O
.	O
</s>
<s>
Several	O
Active	B-Language
objects	I-Language
could	O
be	O
waiting	O
to	O
execute	O
(	O
based	O
on	O
priority	O
)	O
and	O
each	O
one	O
had	O
to	O
restrict	O
its	O
own	O
execution	O
time	O
.	O
</s>
<s>
Fibers	O
can	O
be	O
implemented	O
without	O
operating	B-General_Concept
system	I-General_Concept
support	O
,	O
although	O
some	O
operating	B-General_Concept
systems	I-General_Concept
or	O
libraries	O
provide	O
explicit	O
support	O
for	O
them	O
.	O
</s>
