<s>
In	O
computer	B-General_Concept
science	I-General_Concept
,	O
multiple	B-Algorithm
buffering	I-Algorithm
is	O
the	O
use	O
of	O
more	O
than	O
one	O
buffer	B-General_Concept
to	O
hold	O
a	O
block	O
of	O
data	O
,	O
so	O
that	O
a	O
"	O
reader	O
"	O
will	O
see	O
a	O
complete	O
(	O
though	O
perhaps	O
old	O
)	O
version	O
of	O
the	O
data	O
,	O
rather	O
than	O
a	O
partially	O
updated	O
version	O
of	O
the	O
data	O
being	O
created	O
by	O
a	O
"	B-Operating_System
writer	I-Operating_System
"	I-Operating_System
.	O
</s>
<s>
It	O
is	O
very	O
commonly	O
used	O
for	O
computer	B-Device
display	I-Device
images	O
.	O
</s>
<s>
It	O
is	O
also	O
used	O
to	O
avoid	O
the	O
need	O
to	O
use	O
dual-ported	B-General_Concept
RAM	I-General_Concept
(	O
DPRAM	B-General_Concept
)	O
when	O
the	O
readers	O
and	O
writers	O
are	O
different	O
devices	O
.	O
</s>
<s>
An	O
easy	O
way	O
to	O
explain	O
how	O
multiple	B-Algorithm
buffering	I-Algorithm
works	O
is	O
to	O
take	O
a	O
real-world	O
example	O
.	O
</s>
<s>
So	O
you	O
fill	O
one	O
bucket	O
(	O
or	O
buffer	B-General_Concept
)	O
from	O
the	O
tap	O
,	O
turn	O
the	O
tap	O
off	O
,	O
walk	O
over	O
to	O
the	O
pool	O
,	O
pour	O
the	O
water	O
in	O
,	O
walk	O
back	O
to	O
the	O
tap	O
to	O
repeat	O
the	O
exercise	O
.	O
</s>
<s>
In	O
computer	B-General_Concept
science	I-General_Concept
the	O
situation	O
of	O
having	O
a	O
running	O
tap	O
that	O
cannot	O
be	O
,	O
or	O
should	O
not	O
be	O
,	O
turned	O
off	O
is	O
common	O
(	O
such	O
as	O
a	O
stream	O
of	O
audio	O
)	O
.	O
</s>
<s>
The	O
Petri	B-Operating_System
net	I-Operating_System
in	O
the	O
illustration	O
shows	O
how	O
double	O
buffering	O
works	O
.	O
</s>
<s>
Transitions	O
W1	O
and	O
W2	O
represent	O
writing	O
to	O
buffer	B-General_Concept
1	O
and	O
2	O
respectively	O
while	O
R1	O
and	O
R2	O
represent	O
reading	O
from	O
buffer	B-General_Concept
1	O
and	O
2	O
respectively	O
.	O
</s>
<s>
However	O
,	O
this	O
intermediate	O
image	O
is	O
seen	O
by	O
the	O
user	O
as	O
flickering	B-General_Concept
.	O
</s>
<s>
In	O
addition	O
,	O
computer	B-Device
monitors	I-Device
constantly	O
redraw	O
the	O
visible	O
video	O
page	O
(	O
traditionally	O
at	O
around	O
60	O
times	O
a	O
second	O
)	O
,	O
so	O
even	O
a	O
perfect	O
update	O
may	O
be	O
visible	O
momentarily	O
as	O
a	O
horizontal	O
divider	O
between	O
the	O
"	O
new	O
"	O
image	O
and	O
the	O
un-redrawn	O
"	O
old	O
"	O
image	O
,	O
known	O
as	O
tearing	O
.	O
</s>
<s>
A	O
software	O
implementation	O
of	O
double	O
buffering	O
has	O
all	O
drawing	O
operations	O
store	O
their	O
results	O
in	O
some	O
region	O
of	O
system	O
RAM	B-Architecture
;	O
any	O
such	O
region	O
is	O
often	O
called	O
a	O
"	O
back	O
buffer	B-General_Concept
"	O
.	O
</s>
<s>
When	O
all	O
drawing	O
operations	O
are	O
considered	O
complete	O
,	O
the	O
whole	O
region	O
(	O
or	O
only	O
the	O
changed	O
portion	O
)	O
is	O
copied	O
into	O
the	O
video	O
RAM	B-Architecture
(	O
the	O
"	O
front	O
buffer	B-General_Concept
"	O
)	O
;	O
this	O
copying	O
is	O
usually	O
synchronized	O
with	O
the	O
monitor	O
's	O
raster	B-Algorithm
beam	O
in	O
order	O
to	O
avoid	O
tearing	O
.	O
</s>
<s>
Software	O
implementations	O
of	O
double	O
buffering	O
necessarily	O
requires	O
more	O
memory	O
and	O
CPU	O
time	O
than	O
single	O
buffering	O
because	O
of	O
the	O
system	O
memory	O
allocated	O
for	O
the	O
back	O
buffer	B-General_Concept
,	O
the	O
time	O
for	O
the	O
copy	O
operation	O
,	O
and	O
the	O
time	O
waiting	O
for	O
synchronization	O
.	O
</s>
<s>
Compositing	B-Operating_System
window	I-Operating_System
managers	I-Operating_System
often	O
combine	O
the	O
"	O
copying	O
"	O
operation	O
with	O
"	O
compositing	O
"	O
used	O
to	O
position	O
windows	O
,	O
transform	O
them	O
with	O
scale	O
or	O
warping	O
effects	O
,	O
and	O
make	O
portions	O
transparent	O
.	O
</s>
<s>
Thus	O
the	O
"	O
front	O
buffer	B-General_Concept
"	O
may	O
contain	O
only	O
the	O
composite	O
image	O
seen	O
on	O
the	O
screen	O
,	O
while	O
there	O
is	O
a	O
different	O
"	O
back	O
buffer	B-General_Concept
"	O
for	O
every	O
window	O
containing	O
the	O
non-composited	O
image	O
of	O
the	O
entire	O
window	O
contents	O
.	O
</s>
<s>
In	O
the	O
page-flip	O
method	O
,	O
instead	O
of	O
copying	O
the	O
data	O
,	O
both	O
buffers	B-General_Concept
are	O
capable	O
of	O
being	O
displayed	O
(	O
both	O
are	O
in	O
Video	O
RAM	B-Architecture
)	O
.	O
</s>
<s>
At	O
any	O
one	O
time	O
,	O
one	O
buffer	B-General_Concept
is	O
actively	O
being	O
displayed	O
by	O
the	O
monitor	O
,	O
while	O
the	O
other	O
,	O
background	O
buffer	B-General_Concept
is	O
being	O
drawn	O
.	O
</s>
<s>
When	O
the	O
background	O
buffer	B-General_Concept
is	O
complete	O
,	O
the	O
roles	O
of	O
the	O
two	O
are	O
switched	O
.	O
</s>
<s>
The	O
page-flip	O
is	O
typically	O
accomplished	O
by	O
modifying	O
a	O
hardware	B-General_Concept
register	I-General_Concept
in	O
the	O
video	B-General_Concept
display	I-General_Concept
controller	I-General_Concept
—	O
the	O
value	O
of	O
a	O
pointer	O
to	O
the	O
beginning	O
of	O
the	O
display	O
data	O
in	O
the	O
video	O
memory	O
.	O
</s>
<s>
The	O
currently	O
active	O
and	O
visible	O
buffer	B-General_Concept
is	O
called	O
the	O
front	O
buffer	B-General_Concept
,	O
while	O
the	O
background	O
page	O
is	O
called	O
the	O
back	O
buffer	B-General_Concept
.	O
</s>
<s>
This	O
waiting	O
period	O
could	O
be	O
several	O
milliseconds	O
during	O
which	O
neither	O
buffer	B-General_Concept
can	O
be	O
touched	O
.	O
</s>
<s>
In	O
triple	O
buffering	O
the	O
program	O
has	O
two	O
back	O
buffers	B-General_Concept
and	O
can	O
immediately	O
start	O
drawing	O
in	O
the	O
one	O
that	O
is	O
not	O
involved	O
in	O
such	O
copying	O
.	O
</s>
<s>
The	O
third	O
buffer	B-General_Concept
,	O
the	O
front	O
buffer	B-General_Concept
,	O
is	O
read	O
by	O
the	O
graphics	O
card	O
to	O
display	O
the	O
image	O
on	O
the	O
monitor	O
.	O
</s>
<s>
Once	O
the	O
image	O
has	O
been	O
sent	O
to	O
the	O
monitor	O
,	O
the	O
front	O
buffer	B-General_Concept
is	O
flipped	O
with	O
(	O
or	O
copied	O
from	O
)	O
the	O
back	O
buffer	B-General_Concept
holding	O
the	O
most	O
recent	O
complete	O
image	O
.	O
</s>
<s>
Since	O
one	O
of	O
the	O
back	O
buffers	B-General_Concept
is	O
always	O
complete	O
,	O
the	O
graphics	O
card	O
never	O
has	O
to	O
wait	O
for	O
the	O
software	O
to	O
complete	O
.	O
</s>
<s>
For	O
frames	O
that	O
are	O
completed	O
much	O
faster	O
than	O
interval	O
between	O
refreshes	O
,	O
it	O
is	O
possible	O
to	O
replace	O
a	O
back	O
buffers	B-General_Concept
 '	O
frames	O
with	O
newer	O
iterations	O
multiple	O
times	O
before	O
copying	O
.	O
</s>
<s>
This	O
means	O
frames	O
may	O
be	O
written	O
to	O
the	O
back	O
buffer	B-General_Concept
that	O
are	O
never	O
used	O
at	O
all	O
before	O
being	O
overwritten	O
by	O
successive	O
frames	O
.	O
</s>
<s>
An	O
alternative	O
method	O
sometimes	O
referred	O
to	O
as	O
triple	O
buffering	O
is	O
a	O
swap	O
chain	O
three	O
buffers	B-General_Concept
long	O
.	O
</s>
<s>
After	O
the	O
program	O
has	O
drawn	O
both	O
back	O
buffers	B-General_Concept
,	O
it	O
waits	O
until	O
the	O
first	O
one	O
is	O
placed	O
on	O
the	O
screen	O
,	O
before	O
drawing	O
another	O
back	O
buffer	B-General_Concept
(	O
i.e.	O
</s>
<s>
it	O
is	O
a	O
3-long	O
first	B-Operating_System
in	I-Operating_System
,	I-Operating_System
first	I-Operating_System
out	I-Operating_System
queue	O
)	O
.	O
</s>
<s>
The	O
term	O
quad	O
buffering	O
means	O
the	O
use	O
of	O
double	O
buffering	O
for	O
each	O
of	O
the	O
left	O
and	O
right	O
eye	O
images	O
in	O
stereoscopic	B-Algorithm
implementations	O
,	O
thus	O
four	O
buffers	B-General_Concept
total	O
(	O
if	O
triple	O
buffering	O
was	O
used	O
then	O
there	O
would	O
be	O
six	O
buffers	B-General_Concept
)	O
.	O
</s>
<s>
The	O
command	O
to	O
swap	O
or	O
copy	O
the	O
buffer	B-General_Concept
typically	O
applies	O
to	O
both	O
pairs	O
at	O
once	O
,	O
so	O
at	O
no	O
time	O
does	O
one	O
eye	O
see	O
an	O
older	O
image	O
than	O
the	O
other	O
eye	O
.	O
</s>
<s>
3D	O
standards	O
like	O
OpenGL	B-Application
and	O
Direct3D	B-Application
support	O
quad	O
buffering	O
.	O
</s>
<s>
The	O
term	O
double	O
buffering	O
is	O
used	O
for	O
copying	O
data	O
between	O
two	O
buffers	B-General_Concept
for	O
direct	B-General_Concept
memory	I-General_Concept
access	I-General_Concept
(	O
DMA	O
)	O
transfers	O
,	O
not	O
for	O
enhancing	O
performance	O
,	O
but	O
to	O
meet	O
specific	O
addressing	O
requirements	O
of	O
a	O
device	O
(	O
esp	O
.	O
</s>
<s>
32-bit	O
devices	O
on	O
systems	O
with	O
wider	O
addressing	O
provided	O
via	O
Physical	B-General_Concept
Address	I-General_Concept
Extension	I-General_Concept
)	O
.	O
</s>
<s>
DOS	B-Device
and	O
Windows	O
device	B-Application
drivers	I-Application
are	O
a	O
place	O
where	O
the	O
term	O
"	O
double	O
buffering	O
"	O
is	O
likely	O
to	O
be	O
used	O
.	O
</s>
<s>
Linux	O
and	O
BSD	O
source	O
code	O
calls	O
these	O
"	O
bounce	O
buffers	B-General_Concept
"	O
.	O
</s>
