111 lines
5.6 KiB
XML
111 lines
5.6 KiB
XML
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 620 560" font-family="sans-serif">
|
|
<!--
|
|
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>
|
|
<marker id="arrow" markerWidth="9" markerHeight="9" refX="7" refY="4.5"
|
|
orient="auto" markerUnits="userSpaceOnUse">
|
|
<path d="M0,0 L9,4.5 L0,9 Z" fill="#333"/>
|
|
</marker>
|
|
<marker id="arrowRot" markerWidth="10" markerHeight="10" refX="6" refY="5"
|
|
orient="auto" markerUnits="userSpaceOnUse">
|
|
<path d="M0,0 L10,5 L0,10 Z" fill="#888"/>
|
|
</marker>
|
|
</defs>
|
|
|
|
<text x="310" y="34" text-anchor="middle" font-size="18" font-weight="bold">
|
|
Buffers used as a ring: slot = frameNr % RING_SIZ
|
|
</text>
|
|
|
|
<!-- rotation hint (clockwise) -->
|
|
<path d="M 395 138 A 130 130 0 0 1 452 300" fill="none" stroke="#bbb"
|
|
stroke-width="2" stroke-dasharray="4 5" marker-end="url(#arrowRot)"/>
|
|
<text x="470" y="320" font-size="12" fill="#999">advances</text>
|
|
|
|
<!-- ===================== slots ===================== -->
|
|
<!-- slot 0 : SHOW (frame 40, currently lent to GUI) -->
|
|
<g>
|
|
<circle cx="310" cy="120" r="46" fill="#e7d8ff" stroke="#5a2ca0" stroke-width="2.2"/>
|
|
<text x="310" y="112" text-anchor="middle" font-size="14" font-weight="bold">SHOW</text>
|
|
<text x="310" y="132" text-anchor="middle" font-size="12" fill="#444">frame 40</text>
|
|
<text x="372" y="104" text-anchor="middle" font-size="11" fill="#888">slot 0</text>
|
|
</g>
|
|
<!-- slot 1 : FEED (frame 41, ready to show) -->
|
|
<g>
|
|
<circle cx="452" cy="203" r="46" fill="#d8f0d8" stroke="#3a7a3a" stroke-width="2.2"/>
|
|
<text x="452" y="199" text-anchor="middle" font-size="14" font-weight="bold">FEED</text>
|
|
<text x="452" y="219" text-anchor="middle" font-size="12" fill="#444">frame 41</text>
|
|
<text x="507" y="200" text-anchor="middle" font-size="11" fill="#888">slot 1</text>
|
|
</g>
|
|
<!-- slot 2 : READ (frame 42, IO in flight) -->
|
|
<g>
|
|
<circle cx="398" cy="371" r="46" fill="#ffedcc" stroke="#b8860b" stroke-width="2.2"/>
|
|
<text x="398" y="367" text-anchor="middle" font-size="14" font-weight="bold">READ</text>
|
|
<text x="398" y="387" text-anchor="middle" font-size="12" fill="#444">frame 42</text>
|
|
<text x="398" y="432" text-anchor="middle" font-size="11" fill="#888">slot 2</text>
|
|
</g>
|
|
<!-- slot 3 : READ (frame 43, IO in flight) -->
|
|
<g>
|
|
<circle cx="222" cy="371" r="46" fill="#ffedcc" stroke="#b8860b" stroke-width="2.2"/>
|
|
<text x="222" y="367" text-anchor="middle" font-size="14" font-weight="bold">READ</text>
|
|
<text x="222" y="387" text-anchor="middle" font-size="12" fill="#444">frame 43</text>
|
|
<text x="222" y="432" text-anchor="middle" font-size="11" fill="#888">slot 3</text>
|
|
</g>
|
|
<!-- slot 4 : FREE (next to be submitted) -->
|
|
<g>
|
|
<circle cx="168" cy="203" r="46" fill="#dbe9ff" stroke="#3a5a8a" stroke-width="2.2"/>
|
|
<text x="168" y="199" text-anchor="middle" font-size="14" font-weight="bold">FREE</text>
|
|
<text x="168" y="219" text-anchor="middle" font-size="12" fill="#444">—</text>
|
|
<text x="113" y="200" text-anchor="middle" font-size="11" fill="#888">slot 4</text>
|
|
</g>
|
|
|
|
<!-- center caption -->
|
|
<text x="310" y="258" text-anchor="middle" font-size="13" fill="#666">buffer_[ ]</text>
|
|
<text x="310" y="277" text-anchor="middle" font-size="11" fill="#999">RING_SIZ = 5</text>
|
|
|
|
<!-- ===================== cursors ===================== -->
|
|
<!-- nextShow_ -> slot 0 -->
|
|
<g>
|
|
<rect x="150" y="52" width="150" height="26" rx="5" fill="#f3ecff" stroke="#5a2ca0"/>
|
|
<text x="225" y="70" text-anchor="middle" font-size="13" fill="#5a2ca0">
|
|
nextShow_ = 40
|
|
</text>
|
|
<path d="M 278 72 C 300 84, 300 74, 300 96" fill="none" stroke="#5a2ca0"
|
|
stroke-width="2" marker-end="url(#arrow)"/>
|
|
</g>
|
|
<!-- nextRead_ -> slot 4 -->
|
|
<g>
|
|
<rect x="18" y="120" width="150" height="26" rx="5" fill="#eaf1fb" stroke="#3a5a8a"/>
|
|
<text x="93" y="138" text-anchor="middle" font-size="13" fill="#3a5a8a">
|
|
nextRead_ = 44
|
|
</text>
|
|
<path d="M 110 146 C 120 168, 138 168, 150 182" fill="none" stroke="#3a5a8a"
|
|
stroke-width="2" marker-end="url(#arrow)"/>
|
|
</g>
|
|
|
|
<!-- ===================== legend ===================== -->
|
|
<g font-size="12" transform="translate(40,478)">
|
|
<text x="0" y="0" font-weight="bold" font-size="13">States:</text>
|
|
<rect x="66" y="-11" width="15" height="15" rx="3" fill="#dbe9ff" stroke="#3a5a8a"/>
|
|
<text x="86" y="1">FREE</text>
|
|
<rect x="140" y="-11" width="15" height="15" rx="3" fill="#ffedcc" stroke="#b8860b"/>
|
|
<text x="160" y="1">READ</text>
|
|
<rect x="216" y="-11" width="15" height="15" rx="3" fill="#d8f0d8" stroke="#3a7a3a"/>
|
|
<text x="236" y="1">FEED</text>
|
|
<rect x="292" y="-11" width="15" height="15" rx="3" fill="#e7d8ff" stroke="#5a2ca0"/>
|
|
<text x="312" y="1">SHOW</text>
|
|
<rect x="372" y="-11" width="15" height="15" rx="3" fill="#ffd6d6" stroke="#a00000"/>
|
|
<text x="392" y="1">STOP</text>
|
|
</g>
|
|
<text x="40" y="516" font-size="12" fill="#666">
|
|
Between the two cursors lie the frames currently in flight (READ) or ready (FEED);
|
|
</text>
|
|
<text x="40" y="534" font-size="12" fill="#666">
|
|
the gap can never exceed RING_SIZ — that is where the back-pressure lives.
|
|
</text>
|
|
</svg>
|