<s>
A	O
protothread	B-Operating_System
is	O
a	O
low-overhead	O
mechanism	O
for	O
concurrent	B-Architecture
programming	I-Architecture
.	O
</s>
<s>
Protothreads	B-Operating_System
function	O
as	O
stackless	B-General_Concept
,	O
lightweight	O
threads	B-Operating_System
,	O
or	O
coroutines	B-Architecture
,	O
providing	O
a	O
blocking	B-Operating_System
context	O
cheaply	O
using	O
minimal	O
memory	O
per	O
protothread	B-Operating_System
(	O
on	O
the	O
order	O
of	O
single	O
bytes	O
)	O
.	O
</s>
<s>
Protothreads	B-Operating_System
are	O
used	O
to	O
accomplish	O
a	O
non-preempted	B-Operating_System
form	O
of	O
concurrency	B-Operating_System
known	O
as	O
cooperative	B-Operating_System
multitasking	I-Operating_System
and	O
,	O
therefore	O
,	O
do	O
not	O
incur	O
context	B-Operating_System
switch	I-Operating_System
when	O
yielding	O
to	O
another	O
thread	B-Operating_System
.	O
</s>
<s>
Within	O
a	O
protothread	B-Operating_System
,	O
yielding	O
is	O
accomplished	O
by	O
utilizing	O
Duff	O
's	O
device	O
within	O
a	O
thread	B-Operating_System
's	O
function	O
and	O
an	O
external	O
variable	O
used	O
in	O
within	O
the	O
switch	O
statement	O
.	O
</s>
<s>
In	O
order	O
to	O
block	B-Operating_System
threads	B-Operating_System
,	O
these	O
yields	O
may	O
be	O
guarded	O
by	O
a	O
conditional	B-Language
so	O
that	O
successive	O
calls	O
to	O
the	O
same	O
function	O
will	O
yield	O
unless	O
the	O
guard	O
conditional	B-Language
is	O
true	O
.	O
</s>
<s>
A	O
feature	O
of	O
protothreads	B-Operating_System
relative	O
to	O
other	O
implementations	O
of	O
coroutines	B-Architecture
,	O
or	O
proper	O
threads	B-Operating_System
,	O
is	O
that	O
they	O
are	O
stackless	B-General_Concept
.	O
</s>
<s>
A	O
disadvantage	O
is	O
that	O
local	O
variables	O
within	O
the	O
protothread	B-Operating_System
cannot	O
be	O
trusted	O
to	O
have	O
retained	O
their	O
values	O
across	O
a	O
yield	O
to	O
another	O
context	O
.	O
</s>
<s>
 [ ... ] 	O
I	O
never	O
thought	O
it	O
was	O
an	O
adequate	O
general-purpose	O
coroutine	B-Architecture
implementation	O
because	O
it	O
’s	O
not	O
easy	O
to	O
have	O
multiple	O
simultaneous	O
activations	O
of	O
a	O
coroutine	B-Architecture
and	O
it	O
’s	O
not	O
possible	O
using	O
this	O
method	O
to	O
have	O
coroutines	B-Architecture
give	O
up	O
control	O
anywhere	O
but	O
in	O
their	O
top-level	O
routine	O
.	O
</s>
<s>
The	O
protothread	B-Operating_System
concept	O
was	O
developed	O
by	O
Adam	O
Dunkels	O
and	O
Oliver	O
Schmidt	O
,	O
based	O
on	O
prior	O
work	O
by	O
Simon	O
Tatham	O
and	O
Tom	O
Duff	O
.	O
</s>
