<s>
In	O
computer	O
programming	O
,	O
a	O
sentinel	B-Data_Structure
node	I-Data_Structure
is	O
a	O
specifically	O
designated	O
node	B-Data_Structure
used	O
with	O
linked	B-Data_Structure
lists	I-Data_Structure
and	O
trees	B-Application
as	O
a	O
traversal	O
path	O
terminator	O
.	O
</s>
<s>
This	O
type	O
of	O
node	B-Data_Structure
does	O
not	O
hold	O
or	O
reference	O
any	O
data	O
managed	O
by	O
the	O
data	O
structure	O
.	O
</s>
<s>
If	O
the	O
data	O
structure	O
is	O
accessed	O
concurrently	B-Architecture
(	O
which	O
means	O
that	O
all	O
nodes	O
being	O
accessed	O
have	O
to	O
be	O
protected	O
at	O
least	O
for	O
“	B-Application
read-only	I-Application
”	I-Application
)	O
,	O
for	O
a	O
sentinel-based	O
implementation	O
the	O
sentinel	B-Data_Structure
node	I-Data_Structure
has	O
to	O
be	O
protected	O
for	O
“	O
read-write	O
”	O
by	O
a	O
mutex	B-Operating_System
.	O
</s>
<s>
This	O
extra	O
mutex	B-Operating_System
in	O
quite	O
a	O
few	O
use	O
scenarios	O
can	O
cause	O
severe	O
performance	O
degradation	O
.	O
</s>
<s>
One	O
way	O
to	O
avoid	O
it	O
is	O
to	O
protect	O
the	O
list	O
structure	O
as	O
a	O
whole	O
for	O
“	O
read-write	O
”	O
,	O
whereas	O
in	O
the	O
version	O
with	O
NULL	O
it	O
suffices	O
to	O
protect	O
the	O
data	O
structure	O
as	O
a	O
whole	O
for	O
“	B-Application
read-only	I-Application
”	I-Application
(	O
if	O
an	O
update	O
operation	O
will	O
not	O
follow	O
)	O
.	O
</s>
<s>
Below	O
are	O
two	O
versions	O
of	O
a	O
subroutine	O
(	O
implemented	O
in	O
the	O
C	B-Language
programming	I-Language
language	I-Language
)	O
for	O
looking	O
up	O
a	O
given	O
search	O
key	O
in	O
a	O
singly	O
linked	B-Data_Structure
list	I-Data_Structure
.	O
</s>
<s>
The	O
first	O
one	O
uses	O
the	O
sentinel	B-Data_Structure
value	I-Data_Structure
NULL	O
,	O
and	O
the	O
second	O
one	O
a	O
(	O
pointer	O
to	O
the	O
)	O
sentinel	B-Data_Structure
node	I-Data_Structure
Sentinel	O
,	O
as	O
the	O
end-of-list	O
indicator	O
.	O
</s>
<s>
The	O
declarations	O
of	O
the	O
singly	O
linked	B-Data_Structure
list	I-Data_Structure
data	O
structure	O
and	O
the	O
outcomes	O
of	O
both	O
subroutines	O
are	O
the	O
same	O
.	O
</s>
<s>
node	B-Data_Structure
!=	O
NULL	O
;	O
</s>
<s>
if	O
(	O
node->key	O
==	O
search_key	O
)	O
.	O
</s>
<s>
node->key	O
!=	O
search_key	O
;	O
.	O
</s>
<s>
Linked	B-Data_Structure
list	I-Data_Structure
implementations	O
,	O
especially	O
one	O
of	O
a	O
circular	O
,	O
doubly-linked	O
list	O
,	O
can	O
be	O
simplified	O
remarkably	O
using	O
a	O
sentinel	B-Data_Structure
node	I-Data_Structure
to	O
demarcate	O
the	O
beginning	O
and	O
end	O
of	O
the	O
list	O
.	O
</s>
<s>
The	O
list	O
starts	O
out	O
with	O
a	O
single	O
node	B-Data_Structure
,	O
the	O
sentinel	B-Data_Structure
node	I-Data_Structure
which	O
has	O
the	O
next	O
and	O
previous	O
pointers	O
point	O
to	O
itself	O
.	O
</s>
<s>
In	O
a	O
non-empty	O
list	O
,	O
the	O
sentinel	B-Data_Structure
node	I-Data_Structure
's	O
next	O
pointer	O
gives	O
the	O
head	O
of	O
the	O
list	O
,	O
and	O
the	O
previous	O
pointer	O
gives	O
the	O
tail	O
of	O
the	O
list	O
.	O
</s>
<s>
Notice	O
how	O
the	O
add_node( )	O
method	O
takes	O
the	O
node	B-Data_Structure
that	O
will	O
be	O
displaced	O
by	O
the	O
new	O
node	B-Data_Structure
in	O
the	O
parameter	O
curnode	O
.	O
</s>
<s>
But	O
because	O
of	O
how	O
the	O
linkage	O
is	O
set	O
up	O
to	O
refer	O
back	O
to	O
the	O
sentinel	O
,	O
the	O
code	O
just	O
works	O
for	O
empty	O
lists	O
as	O
well	O
,	O
where	O
curnode	O
will	O
be	O
the	O
sentinel	B-Data_Structure
node	I-Data_Structure
.	O
</s>
<s>
General	O
declarations	O
,	O
similar	O
to	O
article	O
Binary	B-Language
search	I-Language
tree	I-Language
:	O
</s>
<s>
This	O
means	O
that	O
in	O
applications	O
with	O
concurrency	B-Architecture
it	O
has	O
to	O
be	O
protected	O
by	O
a	O
mutex	B-Operating_System
,	O
an	O
effort	O
which	O
normally	O
exceeds	O
the	O
savings	O
of	O
the	O
sentinel	O
.	O
</s>
<s>
There	O
has	O
to	O
be	O
exactly	O
one	O
“	O
node	B-Data_Structure
”	O
to	O
be	O
used	O
as	O
sentinel	O
,	O
but	O
there	O
may	O
be	O
extremely	O
many	O
pointers	O
to	O
it	O
.	O
</s>
