<s>
In	O
computer	B-General_Concept
science	I-General_Concept
,	O
serializing	B-Operating_System
tokens	I-Operating_System
are	O
a	O
concept	O
in	O
concurrency	O
control	O
arising	O
from	O
the	O
ongoing	O
development	O
of	O
DragonFly	B-Application
BSD	I-Application
.	O
</s>
<s>
According	O
to	O
Matthew	O
Dillon	O
,	O
they	O
are	O
most	O
akin	O
to	O
SPLs	B-Operating_System
,	O
except	O
a	O
token	O
works	O
across	O
multiple	O
CPUs	B-General_Concept
while	O
SPLs	B-Operating_System
only	O
work	O
within	O
a	O
single	O
CPU	O
's	O
domain	O
.	O
</s>
<s>
Serializing	B-Operating_System
tokens	I-Operating_System
allow	O
programmers	O
to	O
write	O
multiprocessor-safe	O
code	O
without	O
themselves	O
or	O
the	O
lower	O
level	O
subsystems	O
needing	O
to	O
be	O
aware	O
of	O
every	O
single	O
entity	O
that	O
may	O
also	O
be	O
holding	O
the	O
same	O
token	O
.	O
</s>
<s>
Tokens	O
and	O
mutual	B-Operating_System
exclusion	I-Operating_System
(	O
mutex	B-Operating_System
)	O
mechanisms	O
are	O
locks	B-Operating_System
.	O
</s>
<s>
Unlike	O
mutexes	B-Operating_System
,	O
tokens	O
do	O
not	O
exclude	O
other	O
threads	O
from	O
accessing	O
the	O
resource	O
while	O
they	O
are	O
blocked	O
or	O
asleep	O
.	O
</s>
<s>
Concurrent	O
execution	O
:	O
in	O
multiprocessor	B-Operating_System
computers	O
,	O
a	O
thread	O
may	O
be	O
run	O
at	O
exactly	O
the	O
same	O
time	O
as	O
another	O
thread	O
on	O
a	O
different	O
CPU	O
.	O
</s>
<s>
Preemption	O
:	O
a	O
thread	O
may	O
preempt	O
a	O
lower-priority	O
thread	O
,	O
such	O
as	O
a	O
hardware	O
interrupt	O
or	O
Light	B-Operating_System
Weight	I-Operating_System
Kernel	I-Operating_System
Threads	I-Operating_System
.	O
</s>
<s>
The	O
following	O
table	O
summarizes	O
the	O
properties	O
of	O
tokens	O
and	O
mutexes	B-Operating_System
.	O
</s>
<s>
Issues	O
such	O
as	O
deadlock	B-Operating_System
and	O
priority	B-Operating_System
inversion	I-Operating_System
can	O
be	O
very	O
difficult	O
to	O
avoid	O
,	O
and	O
require	O
coordination	O
at	O
many	O
levels	O
of	O
the	O
kernel	O
.	O
</s>
<s>
Because	O
locking	B-Operating_System
with	O
tokens	O
does	O
not	O
deadlock	B-Operating_System
and	O
acquired	O
tokens	O
need	O
not	O
be	O
atomic	O
when	O
later	O
operations	O
block	O
,	O
it	O
allow	O
much	O
simpler	O
code	O
than	O
mutexes	B-Operating_System
.	O
</s>
<s>
The	O
following	O
pseudocode	B-Language
and	O
explanations	O
illustrate	O
how	O
serializing	B-Operating_System
tokens	I-Operating_System
work	O
.	O
</s>
<s>
+	O
Example	O
PseudoCode	B-Language
using	O
serializing	B-Operating_System
tokens	I-Operating_System
Thread	O
A	O
Thread	O
BAction	O
lwkt_gettoken(T1 )	O
;	O
</s>
<s>
Mac	B-Operating_System
OS	I-Operating_System
X	I-Operating_System
's	O
Darwin	O
kernel	O
uses	O
a	O
similar	O
technique	O
(	O
called	O
a	O
funnel	O
)	O
to	O
serialize	O
access	O
to	O
the	O
BSD	B-Operating_System
portion	O
of	O
the	O
kernel	O
.	O
</s>
