wegen/FrOSCon26/drawings/ring-buffer.svg

798 lines
24 KiB
XML

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
viewBox="0 0 999.99987 829.218"
font-family="sans-serif"
version="1.1"
id="svg30"
sodipodi:docname="ring-buffer.svg"
inkscape:version="1.4.3 (0d15f75042, 2025-12-25)"
inkscape:export-filename="../state-ring.svg"
inkscape:export-xdpi="96"
inkscape:export-ydpi="96"
width="14.58cm"
height="12.09cm"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:dc="http://purl.org/dc/elements/1.1/">
<title
id="title30">State progression in the Ringbuffer</title>
<sodipodi:namedview
id="namedview30"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:showpageshadow="2"
inkscape:pageopacity="0.0"
inkscape:pagecheckerboard="0"
inkscape:deskcolor="#d1d1d1"
inkscape:zoom="1.5339286"
inkscape:cx="293.03841"
inkscape:cy="227.84633"
inkscape:window-width="1920"
inkscape:window-height="1057"
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:window-maximized="1"
inkscape:current-layer="svg30"
inkscape:document-units="cm" />
<!--
Ring-buffer snapshot for the io_uring video demo.
A fixed array of RING_SIZ buffers is used cyclically: slot = frameNr % RING_SIZ.
Two independent, monotonic cursors chase each other around the ring:
nextRead_ (production) submits reads into every FREE slot ahead
nextShow_ (consumption) rests on the slot currently shown, advancing on release
This is an illustrative snapshot (START_FRAME = 40, RING_SIZ = 5).
-->
<defs
id="defs2">
<marker
id="arrow"
markerWidth="9"
markerHeight="9"
refX="7"
refY="4.5"
orient="auto"
markerUnits="userSpaceOnUse">
<path
d="M 0,0 9,4.5 0,9 Z"
fill="#333333"
id="path1" />
</marker>
<marker
id="arrowRot"
markerWidth="10"
markerHeight="10"
refX="6"
refY="5"
orient="auto"
markerUnits="userSpaceOnUse">
<path
d="M 0,0 10,5 0,10 Z"
fill="#888888"
id="path2" />
</marker>
</defs>
<!-- rotation hint (clockwise) -->
<!-- ===================== slots ===================== -->
<!-- slot 0 : SHOW (frame 40, currently lent to GUI) -->
<!-- slot 1 : FEED (frame 41, ready to show) -->
<!-- slot 2 : READ (frame 42, IO in flight) -->
<!-- slot 3 : READ (frame 43, IO in flight) -->
<!-- slot 4 : FREE (next to be submitted) -->
<!-- center caption -->
<!-- ===================== cursors ===================== -->
<!-- nextShow_ -> slot 0 -->
<!-- nextRead_ -> slot 4 -->
<!-- ===================== legend ===================== -->
<metadata
id="metadata30">
<rdf:RDF>
<cc:Work
rdf:about="">
<cc:license
rdf:resource="http://creativecommons.org/licenses/by-sa/4.0/" />
<dc:title>State progression in the Ringbuffer</dc:title>
</cc:Work>
<cc:License
rdf:about="http://creativecommons.org/licenses/by-sa/4.0/">
<cc:permits
rdf:resource="http://creativecommons.org/ns#Reproduction" />
<cc:permits
rdf:resource="http://creativecommons.org/ns#Distribution" />
<cc:requires
rdf:resource="http://creativecommons.org/ns#Notice" />
<cc:requires
rdf:resource="http://creativecommons.org/ns#Attribution" />
<cc:permits
rdf:resource="http://creativecommons.org/ns#DerivativeWorks" />
<cc:requires
rdf:resource="http://creativecommons.org/ns#ShareAlike" />
</cc:License>
</rdf:RDF>
</metadata>
<g
id="drawing">
<path
d="M 715.0571,172.11989 A 235.02157,235.05218 0 0 1 818.10502,465.03107"
fill="none"
stroke="#bbbbbb"
stroke-width="2"
stroke-dasharray="4, 5"
marker-end="url(#arrowRot)"
id="path3" />
<text
x="850.70184"
y="501.16031"
font-size="21.6957px"
fill="#999999"
id="text3"
style="stroke-width:1"
transform="scale(0.99993487,1.0000651)">advances</text>
<g
id="g6"
style="stroke-width:0.553105"
transform="matrix(1.8078582,0,0,1.8080937,0.95311217,-77.397037)">
<circle
cx="310"
cy="120"
r="46"
fill="#e7d8ff"
stroke="#5a2ca0"
stroke-width="1.21683"
id="circle3" />
<text
x="310"
y="112"
text-anchor="middle"
font-size="14px"
font-weight="bold"
id="text4"
style="stroke-width:0.553105">SHOW</text>
<text
x="310"
y="132"
text-anchor="middle"
font-size="12px"
fill="#444444"
id="text5"
style="stroke-width:0.553105">frame 40</text>
<text
x="381.12689"
y="104.65192"
text-anchor="middle"
font-size="11"
fill="#888888"
id="text6"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:16px;font-family:sans-serif;-inkscape-font-specification:'sans-serif, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-east-asian:normal;stroke-width:0.553105">slot 0</text>
</g>
<g
id="g9"
style="stroke-width:0.553105"
transform="matrix(1.8078582,0,0,1.8080937,0.95311217,-77.397037)">
<circle
cx="452"
cy="203"
r="46"
fill="#d8f0d8"
stroke="#3a7a3a"
stroke-width="1.21683"
id="circle6" />
<text
x="452"
y="199"
text-anchor="middle"
font-size="14px"
font-weight="bold"
id="text7"
style="stroke-width:0.553105">FEED</text>
<text
x="452"
y="219"
text-anchor="middle"
font-size="12px"
fill="#444444"
id="text8"
style="stroke-width:0.553105">frame 41</text>
<text
x="524.60187"
y="200"
text-anchor="middle"
font-size="11px"
fill="#888888"
id="text9"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:16px;font-family:sans-serif;-inkscape-font-specification:'sans-serif, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-east-asian:normal;stroke-width:0.553105">slot 1</text>
</g>
<g
id="g12"
style="stroke-width:0.553105"
transform="matrix(1.8078582,0,0,1.8080937,0.95311217,-77.397037)">
<circle
cx="398"
cy="371"
r="46"
fill="#ffedcc"
stroke="#b8860b"
stroke-width="1.21683"
id="circle9" />
<text
x="398"
y="367"
text-anchor="middle"
font-size="14px"
font-weight="bold"
id="text10"
style="stroke-width:0.553105">READ</text>
<text
x="398"
y="387"
text-anchor="middle"
font-size="12px"
fill="#444444"
id="text11"
style="stroke-width:0.553105">frame 42</text>
<text
x="398.65192"
y="439.17114"
text-anchor="middle"
font-size="11"
fill="#888888"
id="text12"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:16px;font-family:sans-serif;-inkscape-font-specification:'sans-serif, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-east-asian:normal;stroke-width:0.553105">slot 2</text>
</g>
<g
id="g15"
style="stroke-width:0.553105"
transform="matrix(1.8078582,0,0,1.8080937,0.95311217,-77.397037)">
<circle
cx="222"
cy="371"
r="46"
fill="#ffedcc"
stroke="#b8860b"
stroke-width="1.21683"
id="circle12" />
<text
x="222"
y="367"
text-anchor="middle"
font-size="14px"
font-weight="bold"
id="text13"
style="stroke-width:0.553105">READ</text>
<text
x="222"
y="387"
text-anchor="middle"
font-size="12px"
fill="#444444"
id="text14"
style="stroke-width:0.553105">frame 43</text>
<text
x="222.65192"
y="439.17114"
text-anchor="middle"
font-size="11"
fill="#888888"
id="text15"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:16px;font-family:sans-serif;-inkscape-font-specification:'sans-serif, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-east-asian:normal;stroke-width:0.553105">slot 3</text>
</g>
<g
id="g18"
style="stroke-width:0.553105"
transform="matrix(1.8078582,0,0,1.8080937,0.95311217,-77.397037)">
<circle
cx="168"
cy="203"
r="46"
fill="#dbe9ff"
stroke="#3a5a8a"
stroke-width="1.21683"
id="circle15" />
<text
x="168"
y="199"
text-anchor="middle"
font-size="14px"
font-weight="bold"
id="text16"
style="stroke-width:0.553105">FREE</text>
<text
x="168"
y="219"
text-anchor="middle"
font-size="12px"
fill="#444444"
id="text17"
style="stroke-width:0.553105">—</text>
<text
x="90.182777"
y="198.69617"
text-anchor="middle"
font-size="11px"
fill="#888888"
id="text18"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:16px;font-family:sans-serif;-inkscape-font-specification:'sans-serif, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-east-asian:normal;stroke-width:0.553105">slot 4</text>
</g>
<text
x="561.42572"
y="423.41733"
text-anchor="middle"
font-size="11"
fill="#999999"
id="text20"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:28.9276px;font-family:sans-serif;-inkscape-font-specification:'sans-serif, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-east-asian:normal;stroke-width:1"
transform="scale(0.99993487,1.0000651)">RING_SIZ = 5</text>
<g
id="g21"
style="stroke-width:0.553105"
transform="matrix(1.8078582,0,0,1.8080937,0.95311217,-77.397037)">
<rect
x="150"
y="52"
width="150"
height="26"
rx="5"
fill="#f3ecff"
stroke="#5a2ca0"
id="rect20"
style="stroke-width:0.553105" />
<text
x="225"
y="70"
text-anchor="middle"
font-size="13px"
fill="#5a2ca0"
id="text21"
style="stroke-width:0.553105">nextShow_ = 40</text>
<path
d="m 278,72 c 22,12 22,2 22,24"
fill="none"
stroke="#5a2ca0"
stroke-width="1.10621"
marker-end="url(#arrow)"
id="path21" />
</g>
<g
id="g22"
style="stroke-width:0.553105"
transform="matrix(1.8078582,0,0,1.8080937,0.95311217,-77.397037)">
<rect
x="18"
y="120"
width="150"
height="26"
rx="5"
fill="#eaf1fb"
stroke="#3a5a8a"
id="rect21"
style="stroke-width:0.553105" />
<text
x="93"
y="138"
text-anchor="middle"
font-size="13px"
fill="#3a5a8a"
id="text22"
style="stroke-width:0.553105">nextRead_ = 44</text>
<path
d="m 110,146 c 10,22 28,22 40,36"
fill="none"
stroke="#3a5a8a"
stroke-width="1.10621"
marker-end="url(#arrow)"
id="path22" />
</g>
<g
font-size="12px"
transform="matrix(1.8078582,0,0,1.8080937,73.26744,786.87175)"
id="g28"
style="stroke-width:0.553105">
<text
x="0"
y="0"
font-weight="bold"
font-size="13px"
id="text23"
style="stroke-width:0.553105">States:</text>
<rect
x="66"
y="-11"
width="15"
height="15"
rx="3"
fill="#dbe9ff"
stroke="#3a5a8a"
id="rect23"
style="stroke-width:0.553105" />
<text
x="86"
y="1"
id="text24"
style="stroke-width:0.553105">FREE</text>
<rect
x="140"
y="-11"
width="15"
height="15"
rx="3"
fill="#ffedcc"
stroke="#b8860b"
id="rect24"
style="stroke-width:0.553105" />
<text
x="160"
y="1"
id="text25"
style="stroke-width:0.553105">READ</text>
<rect
x="216"
y="-11"
width="15"
height="15"
rx="3"
fill="#d8f0d8"
stroke="#3a7a3a"
id="rect25"
style="stroke-width:0.553105" />
<text
x="236"
y="1"
id="text26"
style="stroke-width:0.553105">FEED</text>
<rect
x="292"
y="-11"
width="15"
height="15"
rx="3"
fill="#e7d8ff"
stroke="#5a2ca0"
id="rect26"
style="stroke-width:0.553105" />
<text
x="312"
y="1"
id="text27"
style="stroke-width:0.553105">SHOW</text>
<rect
x="372"
y="-11"
width="15"
height="15"
rx="3"
fill="#ffd6d6"
stroke="#a00000"
id="rect27"
style="stroke-width:0.553105" />
<text
x="392"
y="1"
id="text28"
style="stroke-width:0.553105">STOP</text>
</g>
<g
id="g52"
style="display:inline;stroke-width:0.553105"
transform="matrix(1.8078582,0,0,1.8080937,0.95311217,-77.397037)">
<path
d="m 395,138 a 130,130 0 0 1 57,162"
fill="none"
stroke="#bbbbbb"
stroke-width="1.10621"
stroke-dasharray="4, 5"
marker-end="url(#arrowRot)"
id="path4" />
<text
x="470"
y="320"
font-size="12px"
fill="#999999"
id="text19"
style="stroke-width:0.553105">advances</text>
<circle
cx="310"
cy="120"
r="46"
fill="#e7d8ff"
stroke="#5a2ca0"
stroke-width="1.21683"
id="circle19" />
<text
x="310"
y="112"
text-anchor="middle"
font-size="14px"
font-weight="bold"
id="text29"
style="stroke-width:0.553105">SHOW</text>
<text
x="310"
y="132"
text-anchor="middle"
font-size="12px"
fill="#444444"
id="text30"
style="stroke-width:0.553105">frame 40</text>
<text
x="381.12689"
y="104.65192"
text-anchor="middle"
font-size="11"
fill="#888888"
id="text31"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:16px;font-family:sans-serif;-inkscape-font-specification:'sans-serif, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-east-asian:normal;stroke-width:0.553105">slot 0</text>
<circle
cx="452"
cy="203"
r="46"
fill="#d8f0d8"
stroke="#3a7a3a"
stroke-width="1.21683"
id="circle31" />
<text
x="452"
y="199"
text-anchor="middle"
font-size="14px"
font-weight="bold"
id="text32"
style="stroke-width:0.553105">FEED</text>
<text
x="452"
y="219"
text-anchor="middle"
font-size="12px"
fill="#444444"
id="text33"
style="stroke-width:0.553105">frame 41</text>
<text
x="524.60187"
y="200"
text-anchor="middle"
font-size="11px"
fill="#888888"
id="text34"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:16px;font-family:sans-serif;-inkscape-font-specification:'sans-serif, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-east-asian:normal;stroke-width:0.553105">slot 1</text>
<circle
cx="398"
cy="371"
r="46"
fill="#ffedcc"
stroke="#b8860b"
stroke-width="1.21683"
id="circle34" />
<text
x="398"
y="367"
text-anchor="middle"
font-size="14px"
font-weight="bold"
id="text35"
style="stroke-width:0.553105">READ</text>
<text
x="398"
y="387"
text-anchor="middle"
font-size="12px"
fill="#444444"
id="text36"
style="stroke-width:0.553105">frame 42</text>
<text
x="398.65192"
y="439.17114"
text-anchor="middle"
font-size="11"
fill="#888888"
id="text37"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:16px;font-family:sans-serif;-inkscape-font-specification:'sans-serif, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-east-asian:normal;stroke-width:0.553105">slot 2</text>
<circle
cx="222"
cy="371"
r="46"
fill="#ffedcc"
stroke="#b8860b"
stroke-width="1.21683"
id="circle37" />
<text
x="222"
y="367"
text-anchor="middle"
font-size="14px"
font-weight="bold"
id="text38"
style="stroke-width:0.553105">READ</text>
<text
x="222"
y="387"
text-anchor="middle"
font-size="12px"
fill="#444444"
id="text39"
style="stroke-width:0.553105">frame 43</text>
<text
x="222.65192"
y="439.17114"
text-anchor="middle"
font-size="11"
fill="#888888"
id="text40"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:16px;font-family:sans-serif;-inkscape-font-specification:'sans-serif, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-east-asian:normal;stroke-width:0.553105">slot 3</text>
<circle
cx="168"
cy="203"
r="46"
fill="#dbe9ff"
stroke="#3a5a8a"
stroke-width="1.21683"
id="circle40" />
<text
x="168"
y="199"
text-anchor="middle"
font-size="14px"
font-weight="bold"
id="text41"
style="stroke-width:0.553105">FREE</text>
<text
x="168"
y="219"
text-anchor="middle"
font-size="12px"
fill="#444444"
id="text42"
style="stroke-width:0.553105">—</text>
<text
x="90.182777"
y="198.69617"
text-anchor="middle"
font-size="11px"
fill="#888888"
id="text43"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:16px;font-family:sans-serif;-inkscape-font-specification:'sans-serif, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-east-asian:normal;stroke-width:0.553105">slot 4</text>
<text
x="310"
y="277"
text-anchor="middle"
font-size="11"
fill="#999999"
id="text44"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:16px;font-family:sans-serif;-inkscape-font-specification:'sans-serif, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-east-asian:normal;stroke-width:0.553105">RING_SIZ = 5</text>
<rect
x="150"
y="52"
width="150"
height="26"
rx="5"
fill="#f3ecff"
stroke="#5a2ca0"
id="rect44"
style="stroke-width:0.553105" />
<text
x="225"
y="70"
text-anchor="middle"
font-size="13px"
fill="#5a2ca0"
id="text45"
style="stroke-width:0.553105">nextShow_ = 40</text>
<path
d="m 278,72 c 22,12 22,2 22,24"
fill="none"
stroke="#5a2ca0"
stroke-width="1.10621"
marker-end="url(#arrow)"
id="path45" />
<rect
x="18"
y="120"
width="150"
height="26"
rx="5"
fill="#eaf1fb"
stroke="#3a5a8a"
id="rect45"
style="stroke-width:0.553105" />
<text
x="93"
y="138"
text-anchor="middle"
font-size="13px"
fill="#3a5a8a"
id="text46"
style="stroke-width:0.553105">nextRead_ = 44</text>
<path
d="m 110,146 c 10,22 28,22 40,36"
fill="none"
stroke="#3a5a8a"
stroke-width="1.10621"
marker-end="url(#arrow)"
id="path46" />
<text
x="40"
y="478"
font-weight="bold"
font-size="13px"
id="text47"
style="stroke-width:0.553105">States:</text>
<rect
x="106"
y="467"
width="15"
height="15"
rx="3"
fill="#dbe9ff"
stroke="#3a5a8a"
id="rect47"
style="font-size:12px;stroke-width:0.553105" />
<text
x="126"
y="479"
id="text48"
style="font-size:12px;stroke-width:0.553105">FREE</text>
<rect
x="180"
y="467"
width="15"
height="15"
rx="3"
fill="#ffedcc"
stroke="#b8860b"
id="rect48"
style="font-size:12px;stroke-width:0.553105" />
<text
x="200"
y="479"
id="text49"
style="font-size:12px;stroke-width:0.553105">READ</text>
<rect
x="256"
y="467"
width="15"
height="15"
rx="3"
fill="#d8f0d8"
stroke="#3a7a3a"
id="rect49"
style="font-size:12px;stroke-width:0.553105" />
<text
x="276"
y="479"
id="text50"
style="font-size:12px;stroke-width:0.553105">FEED</text>
<rect
x="332"
y="467"
width="15"
height="15"
rx="3"
fill="#e7d8ff"
stroke="#5a2ca0"
id="rect50"
style="font-size:12px;stroke-width:0.553105" />
<text
x="352"
y="479"
id="text51"
style="font-size:12px;stroke-width:0.553105">SHOW</text>
<rect
x="412"
y="467"
width="15"
height="15"
rx="3"
fill="#ffd6d6"
stroke="#a00000"
id="rect51"
style="font-size:12px;stroke-width:0.553105" />
<text
x="432"
y="479"
id="text52"
style="font-size:12px;stroke-width:0.553105">STOP</text>
</g>
</g>
</svg>