<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet href="/static/feed.xsl" type="text/xsl" ?>
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:quartz="https://quartz.jzhao.xyz/ns">
  <script xmlns="http://www.w3.org/1999/xhtml" src="/static/scripts/xslt-polyfill-214fd525.js"></script>
  <title>/wiki / io</title>
  <subtitle>Recent notes in /wiki / io on Animesh Mishra</subtitle>
  <link href="https://animishraa05.github.io/wiki/io" />
  <link rel="alternate" type="text/html" href="https://animishraa05.github.io/wiki/io" />
  <category term="wiki/io" />
  <id>https://animishraa05.github.io/wiki/io</id>
  <updated>2026-09-02T00:00:00.000Z</updated>
  <contributor>
    <name>Animesh Mishra</name>
    <email>animesh.mishra818@gmail.com</email>
  </contributor>
  <logo>https://animishraa05.github.io/icon.png</logo>
  <icon>https://animishraa05.github.io/icon.png</icon>
  <generator>Quartz v4.6.0 -- quartz.jzhao.xyz</generator>
  <rights type="html">&amp;amp;copy; 2026 Animesh Mishra</rights>
  
  <entry>
    <title>cpu</title>
    <link href="https://animishraa05.github.io/wiki/io/cpu" />
    <link rel="alternate" type="text/markdown" href="https://animishraa05.github.io/wiki/io/cpu.md" />
    <summary>The Problem Auto-created stub for broken link [[cpu]] — needs human content.</summary>
    <published>2026-09-02T00:00:00.000Z</published>
    <updated>2026-09-02T00:00:00.000Z</updated>
    <publishedTime>Sep 02, 2026</publishedTime>
    <updatedTime>Sep 02, 2026</updatedTime>
    <category term="dev" label="dev" />
    <author>
      <name>Animesh Mishra</name>
      <email>animesh.mishra818@gmail.com</email>
    </author>
    <content type="html">&lt;h2 id=&quot;the-problem&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;The Problem&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#the-problem&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;Auto-created stub for broken link &lt;code class=&quot;notranslate&quot;&gt;[[cpu]]&lt;/code&gt; — needs human content.&lt;/p&gt;
&lt;h2 id=&quot;formal-definition&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Formal Definition&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#formal-definition&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;Per Wikipedia: “To be written.”&lt;/p&gt;
&lt;h2 id=&quot;explanation&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Explanation&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#explanation&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;Stub — fill with plain language explanation.&lt;/p&gt;
&lt;h2 id=&quot;how-it-works&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;How It Works&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#how-it-works&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ol dir=&quot;auto&quot;&gt;
&lt;li&gt;To be written.&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&quot;visual-explanation&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Visual Explanation&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#visual-explanation&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;div class=&quot;graphviz-container&quot; style=&quot;display: flex; justify-content: center; margin: 1.5rem 0; overflow-x: auto;&quot; dir=&quot;auto&quot;&gt;&lt;!--?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?--&gt;

&lt;!-- Generated by graphviz version 15.1.0 (0)
 --&gt;
&lt;!-- Title: cpu Pages: 1 --&gt;
&lt;svg width=&quot;293pt&quot; height=&quot;44pt&quot; viewBox=&quot;0.00 0.00 293.00 44.00&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; xmlns:xlink=&quot;http://www.w3.org/1999/xlink&quot;&gt;
&lt;g id=&quot;graph0&quot; class=&quot;graph&quot; transform=&quot;scale(1 1) rotate(0) translate(4 40)&quot;&gt;
&lt;title&gt;cpu&lt;/title&gt;
&lt;polygon fill=&quot;white&quot; stroke=&quot;none&quot; points=&quot;-4,4 -4,-40 288.66,-40 288.66,4 -4,4&quot;&gt;&lt;/polygon&gt;
&lt;!-- A --&gt;
&lt;g id=&quot;node1&quot; class=&quot;node&quot;&gt;
&lt;title&gt;A&lt;/title&gt;
&lt;polygon fill=&quot;#f0f4ff&quot; stroke=&quot;black&quot; points=&quot;75.15,-36 0,-36 0,0 75.15,0 75.15,-36&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;37.58&quot; y=&quot;-13.8&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;14.00&quot;&gt;Stub: cpu&lt;/text&gt;
&lt;/g&gt;
&lt;!-- B --&gt;
&lt;g id=&quot;node2&quot; class=&quot;node&quot;&gt;
&lt;title&gt;B&lt;/title&gt;
&lt;polygon fill=&quot;#f0f4ff&quot; stroke=&quot;black&quot; points=&quot;284.66,-36 187.73,-36 187.73,0 284.66,0 284.66,-36&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;236.2&quot; y=&quot;-13.8&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;14.00&quot;&gt;To be written&lt;/text&gt;
&lt;/g&gt;
&lt;!-- A&amp;#45;&amp;gt;B --&gt;
&lt;g id=&quot;edge1&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;A-&gt;B&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M75.56,-18C103.92,-18 143.62,-18 176.33,-18&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;176.06,-21.5 186.06,-18 176.06,-14.5 176.06,-21.5&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;131.44&quot; y=&quot;-22.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;needs content&lt;/text&gt;
&lt;/g&gt;
&lt;/g&gt;
&lt;/svg&gt;
&lt;/div&gt;
&lt;h2 id=&quot;semantic-network&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Semantic Network&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#semantic-network&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;div class=&quot;graphviz-container&quot; style=&quot;display: flex; justify-content: center; margin: 1.5rem 0; overflow-x: auto;&quot; dir=&quot;auto&quot;&gt;&lt;!--?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?--&gt;

&lt;!-- Generated by graphviz version 15.1.0 (0)
 --&gt;
&lt;!-- Title: semantic_cpu Pages: 1 --&gt;
&lt;svg width=&quot;140pt&quot; height=&quot;55pt&quot; viewBox=&quot;0.00 0.00 140.00 55.00&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; xmlns:xlink=&quot;http://www.w3.org/1999/xlink&quot;&gt;
&lt;g id=&quot;graph0&quot; class=&quot;graph&quot; transform=&quot;scale(1 1) rotate(0) translate(4 50.64)&quot;&gt;
&lt;title&gt;semantic_cpu&lt;/title&gt;
&lt;polygon fill=&quot;white&quot; stroke=&quot;none&quot; points=&quot;-4,4 -4,-50.64 135.56,-50.64 135.56,4 -4,4&quot;&gt;&lt;/polygon&gt;
&lt;!-- THIS --&gt;
&lt;g id=&quot;node1&quot; class=&quot;node&quot;&gt;
&lt;title&gt;THIS&lt;/title&gt;
&lt;ellipse fill=&quot;#ffd700&quot; stroke=&quot;black&quot; stroke-width=&quot;2&quot; cx=&quot;27&quot; cy=&quot;-28.64&quot; rx=&quot;27&quot; ry=&quot;18&quot;&gt;&lt;/ellipse&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;27&quot; y=&quot;-24.74&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;13.00&quot;&gt;cpu&lt;/text&gt;
&lt;/g&gt;
&lt;!-- REL1 --&gt;
&lt;g id=&quot;node2&quot; class=&quot;node&quot;&gt;
&lt;title&gt;REL1&lt;/title&gt;
&lt;ellipse fill=&quot;#f0f0f0&quot; stroke=&quot;black&quot; cx=&quot;98.21&quot; cy=&quot;-18&quot; rx=&quot;33.35&quot; ry=&quot;18&quot;&gt;&lt;/ellipse&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;98.21&quot; y=&quot;-14.7&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;11.00&quot;&gt;Related&lt;/text&gt;
&lt;/g&gt;
&lt;!-- THIS&amp;#45;&amp;#45;REL1 --&gt;
&lt;g id=&quot;edge1&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;THIS--REL1&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M53.52,-24.68C57.47,-24.09 61.58,-23.47 65.65,-22.87&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;50.06&quot; y=&quot;-11.17&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;related&lt;/text&gt;
&lt;/g&gt;
&lt;/g&gt;
&lt;/svg&gt;
&lt;/div&gt;
&lt;h2 id=&quot;key-properties&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Key Properties&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#key-properties&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;To be written.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;real-world-example&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Real-World Example&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#real-world-example&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;figure data-rehype-pretty-code-figure=&quot;&quot;&gt;&lt;pre style=&quot;--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e&quot; tabindex=&quot;0&quot; data-language=&quot;python&quot; data-theme=&quot;github-light github-dark&quot; class=&quot;notranslate&quot;&gt;&lt;span class=&quot;clipboard-button&quot; type=&quot;button&quot; aria-label=&quot;copy source&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 -8 24 24&quot; fill=&quot;currentColor&quot; stroke=&quot;none&quot; stroke-width=&quot;0&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;copy-icon&quot;&gt;&lt;use href=&quot;#github-copy&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 -8 24 24&quot; fill=&quot;currentColor&quot; stroke=&quot;none&quot; stroke-width=&quot;0&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;check-icon&quot;&gt;&lt;use href=&quot;#github-check&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;code data-language=&quot;python&quot; data-theme=&quot;github-light github-dark&quot; style=&quot;display: grid;&quot; class=&quot;notranslate&quot;&gt;&lt;span data-line=&quot;&quot;&gt;&lt;span style=&quot;--shiki-light:#6A737D;--shiki-dark:#6A737D&quot;&gt;# &lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;TODO&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6A737D;--shiki-dark:#6A737D&quot;&gt;: add example&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;
&lt;h2 id=&quot;connections&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Connections&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#connections&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../&quot; class=&quot;internal alias&quot; data-slug=&quot;index&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Index&lt;/a&gt; — auto stub, needs proper links&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;edge-cases--gotchas&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Edge Cases &amp;#x26; Gotchas&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#edge-cases--gotchas&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;To be written.&lt;/li&gt;
&lt;/ul&gt;</content>
  </entry><entry>
    <title>critical-section</title>
    <link href="https://animishraa05.github.io/wiki/io/critical-section" />
    <link rel="alternate" type="text/markdown" href="https://animishraa05.github.io/wiki/io/critical-section.md" />
    <summary>The Problem Auto-created stub for broken link [[critical-section]] — needs human content.</summary>
    <published>2026-09-02T00:00:00.000Z</published>
    <updated>2026-09-02T00:00:00.000Z</updated>
    <publishedTime>Sep 02, 2026</publishedTime>
    <updatedTime>Sep 02, 2026</updatedTime>
    <category term="dev" label="dev" />
    <author>
      <name>Animesh Mishra</name>
      <email>animesh.mishra818@gmail.com</email>
    </author>
    <content type="html">&lt;h2 id=&quot;the-problem&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;The Problem&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#the-problem&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;Auto-created stub for broken link &lt;code class=&quot;notranslate&quot;&gt;[[critical-section]]&lt;/code&gt; — needs human content.&lt;/p&gt;
&lt;h2 id=&quot;formal-definition&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Formal Definition&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#formal-definition&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;Per Wikipedia: “To be written.”&lt;/p&gt;
&lt;h2 id=&quot;explanation&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Explanation&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#explanation&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;Stub — fill with plain language explanation.&lt;/p&gt;
&lt;h2 id=&quot;how-it-works&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;How It Works&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#how-it-works&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ol dir=&quot;auto&quot;&gt;
&lt;li&gt;To be written.&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&quot;visual-explanation&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Visual Explanation&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#visual-explanation&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;figure data-rehype-pretty-code-figure=&quot;&quot;&gt;&lt;pre class=&quot;notranslate&quot; style=&quot;--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e&quot; tabindex=&quot;0&quot; data-language=&quot;dot&quot; data-theme=&quot;github-light github-dark&quot;&gt;&lt;span class=&quot;clipboard-button&quot; type=&quot;button&quot; aria-label=&quot;copy source&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 -8 24 24&quot; fill=&quot;currentColor&quot; stroke=&quot;none&quot; stroke-width=&quot;0&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;copy-icon&quot;&gt;&lt;use href=&quot;#github-copy&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 -8 24 24&quot; fill=&quot;currentColor&quot; stroke=&quot;none&quot; stroke-width=&quot;0&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;check-icon&quot;&gt;&lt;use href=&quot;#github-check&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;code data-language=&quot;dot&quot; data-theme=&quot;github-light github-dark&quot; style=&quot;display: grid;&quot; class=&quot;notranslate&quot;&gt;&lt;span data-line=&quot;&quot;&gt;&lt;span&gt;digraph critical-section {&lt;/span&gt;&lt;/span&gt;
&lt;span data-line=&quot;&quot;&gt;&lt;span&gt;  rankdir=LR&lt;/span&gt;&lt;/span&gt;
&lt;span data-line=&quot;&quot;&gt;&lt;span&gt;  node [shape=box style=filled fillcolor=&quot;#f0f4ff&quot; fontname=&quot;Helvetica&quot;]&lt;/span&gt;&lt;/span&gt;
&lt;span data-line=&quot;&quot;&gt;&lt;span&gt;  A [label=&quot;Stub: critical-section&quot;]&lt;/span&gt;&lt;/span&gt;
&lt;span data-line=&quot;&quot;&gt;&lt;span&gt;  B [label=&quot;To be written&quot;]&lt;/span&gt;&lt;/span&gt;
&lt;span data-line=&quot;&quot;&gt;&lt;span&gt;  A -&gt; B [label=&quot;needs content&quot;]&lt;/span&gt;&lt;/span&gt;
&lt;span data-line=&quot;&quot;&gt;&lt;span&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;
&lt;h2 id=&quot;semantic-network&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Semantic Network&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#semantic-network&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;figure data-rehype-pretty-code-figure=&quot;&quot;&gt;&lt;pre class=&quot;notranslate&quot; style=&quot;--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e&quot; tabindex=&quot;0&quot; data-language=&quot;dot&quot; data-theme=&quot;github-light github-dark&quot;&gt;&lt;span class=&quot;clipboard-button&quot; type=&quot;button&quot; aria-label=&quot;copy source&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 -8 24 24&quot; fill=&quot;currentColor&quot; stroke=&quot;none&quot; stroke-width=&quot;0&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;copy-icon&quot;&gt;&lt;use href=&quot;#github-copy&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 -8 24 24&quot; fill=&quot;currentColor&quot; stroke=&quot;none&quot; stroke-width=&quot;0&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;check-icon&quot;&gt;&lt;use href=&quot;#github-check&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;code data-language=&quot;dot&quot; data-theme=&quot;github-light github-dark&quot; style=&quot;display: grid;&quot; class=&quot;notranslate&quot;&gt;&lt;span data-line=&quot;&quot;&gt;&lt;span&gt;graph semantic_critical-section {&lt;/span&gt;&lt;/span&gt;
&lt;span data-line=&quot;&quot;&gt;&lt;span&gt;  layout=neato&lt;/span&gt;&lt;/span&gt;
&lt;span data-line=&quot;&quot;&gt;&lt;span&gt;  node [shape=ellipse fontname=&quot;Helvetica&quot; fontsize=11 style=filled]&lt;/span&gt;&lt;/span&gt;
&lt;span data-line=&quot;&quot;&gt;&lt;span&gt;  THIS [label=&quot;critical section&quot; fillcolor=&quot;#ffd700&quot; fontsize=13 style=&quot;filled,bold&quot;]&lt;/span&gt;&lt;/span&gt;
&lt;span data-line=&quot;&quot;&gt;&lt;span&gt;  REL1 [label=&quot;Related&quot; fillcolor=&quot;#f0f0f0&quot;]&lt;/span&gt;&lt;/span&gt;
&lt;span data-line=&quot;&quot;&gt;&lt;span&gt;  THIS -- REL1 [label=&quot;related&quot;]&lt;/span&gt;&lt;/span&gt;
&lt;span data-line=&quot;&quot;&gt;&lt;span&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;
&lt;h2 id=&quot;key-properties&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Key Properties&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#key-properties&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;To be written.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;real-world-example&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Real-World Example&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#real-world-example&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;figure data-rehype-pretty-code-figure=&quot;&quot;&gt;&lt;pre class=&quot;notranslate&quot; style=&quot;--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e&quot; tabindex=&quot;0&quot; data-language=&quot;python&quot; data-theme=&quot;github-light github-dark&quot;&gt;&lt;span class=&quot;clipboard-button&quot; type=&quot;button&quot; aria-label=&quot;copy source&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 -8 24 24&quot; fill=&quot;currentColor&quot; stroke=&quot;none&quot; stroke-width=&quot;0&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;copy-icon&quot;&gt;&lt;use href=&quot;#github-copy&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 -8 24 24&quot; fill=&quot;currentColor&quot; stroke=&quot;none&quot; stroke-width=&quot;0&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;check-icon&quot;&gt;&lt;use href=&quot;#github-check&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;code data-language=&quot;python&quot; data-theme=&quot;github-light github-dark&quot; style=&quot;display: grid;&quot; class=&quot;notranslate&quot;&gt;&lt;span data-line=&quot;&quot;&gt;&lt;span style=&quot;--shiki-light:#6A737D;--shiki-dark:#6A737D&quot;&gt;# &lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;TODO&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6A737D;--shiki-dark:#6A737D&quot;&gt;: add example&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;
&lt;h2 id=&quot;connections&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Connections&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#connections&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../&quot; class=&quot;internal alias&quot; data-slug=&quot;index&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Index&lt;/a&gt; — auto stub, needs proper links&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;edge-cases--gotchas&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Edge Cases &amp;#x26; Gotchas&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#edge-cases--gotchas&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;To be written.&lt;/li&gt;
&lt;/ul&gt;</content>
  </entry><entry>
    <title>Io — Map of Content</title>
    <link href="https://animishraa05.github.io/wiki/io/io-moc" />
    <link rel="alternate" type="text/markdown" href="https://animishraa05.github.io/wiki/io/io-moc.md" />
    <summary> Map of Content for Io — 54 concepts. Start here to navigate io.</summary>
    <published>2026-09-02T00:00:00.000Z</published>
    <updated>2026-09-02T00:00:00.000Z</updated>
    <publishedTime>Sep 02, 2026</publishedTime>
    <updatedTime>Sep 02, 2026</updatedTime>
    <category term="meta" label="meta" />
<category term="io" label="io" />
    <author>
      <name>Animesh Mishra</name>
      <email>animesh.mishra818@gmail.com</email>
    </author>
    <content type="html">&lt;blockquote&gt;
&lt;p dir=&quot;auto&quot;&gt;Map of Content for &lt;strong&gt;Io&lt;/strong&gt; — 54 concepts. Start here to navigate io.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h2 id=&quot;core-concepts&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Core Concepts&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#core-concepts&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;a href=&quot;../../binary-semaphore&quot; class=&quot;internal alias&quot; data-slug=&quot;binary-semaphore&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Binary Semaphore&lt;/a&gt; — concept&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;../../block-driver&quot; class=&quot;internal alias&quot; data-slug=&quot;block-driver&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Block Driver&lt;/a&gt; — concept&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;../../buffering&quot; class=&quot;internal alias&quot; data-slug=&quot;buffering&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Buffering&lt;/a&gt; — concept&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;../../character-driver&quot; class=&quot;internal alias&quot; data-slug=&quot;character-driver&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Character Driver&lt;/a&gt; — concept&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;../../c-look&quot; class=&quot;internal alias&quot; data-slug=&quot;c-look&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;C-LOOK&lt;/a&gt; — concept&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;../../collision-resolution&quot; class=&quot;internal alias&quot; data-slug=&quot;collision-resolution&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Collision Resolution&lt;/a&gt; — concept&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;../../counting-semaphore&quot; class=&quot;internal alias&quot; data-slug=&quot;counting-semaphore&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Counting Semaphore&lt;/a&gt; — concept&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;../../c-scan&quot; class=&quot;internal alias&quot; data-slug=&quot;c-scan&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;C-SCAN&lt;/a&gt; — concept&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;../../demand-paging&quot; class=&quot;internal alias&quot; data-slug=&quot;demand-paging&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Demand Paging&lt;/a&gt; — concept&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;../../device-controller&quot; class=&quot;internal alias&quot; data-slug=&quot;device-controller&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Device Controller&lt;/a&gt; — concept&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;../../device-driver&quot; class=&quot;internal alias&quot; data-slug=&quot;device-driver&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Device Driver&lt;/a&gt; — concept&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;../../device-independent-io-software&quot; class=&quot;internal alias&quot; data-slug=&quot;device-independent-io-software&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;O Software&lt;/a&gt; — concept&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;../../disk-management&quot; class=&quot;internal alias&quot; data-slug=&quot;disk-management&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Disk Management&lt;/a&gt; — concept&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;../../disk-scheduling-compared&quot; class=&quot;internal&quot; data-slug=&quot;disk-scheduling-compared&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;disk-scheduling-compared&lt;/a&gt; — concept&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;../../disk-scheduling&quot; class=&quot;internal alias&quot; data-slug=&quot;disk-scheduling&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Disk Scheduling&lt;/a&gt; — concept&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;../../disk-structure&quot; class=&quot;internal alias&quot; data-slug=&quot;disk-structure&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Disk Structure&lt;/a&gt; — concept&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;../../dma&quot; class=&quot;internal alias&quot; data-slug=&quot;dma&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;DMA&lt;/a&gt; — concept&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;../../double-hashing&quot; class=&quot;internal alias&quot; data-slug=&quot;double-hashing&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Double Hashing&lt;/a&gt; — concept&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;../../fcfs&quot; class=&quot;internal alias&quot; data-slug=&quot;fcfs&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;FCFS&lt;/a&gt; — concept&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;../../hash-function&quot; class=&quot;internal alias&quot; data-slug=&quot;hash-function&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Hash Function&lt;/a&gt; — concept&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;../../hashing&quot; class=&quot;internal alias&quot; data-slug=&quot;hashing&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Hashing&lt;/a&gt; — concept&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;../../hashing-performance&quot; class=&quot;internal&quot; data-slug=&quot;hashing-performance&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;hashing-performance&lt;/a&gt; — concept&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;../../interrupt-handler&quot; class=&quot;internal alias&quot; data-slug=&quot;interrupt-handler&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Interrupt Handler&lt;/a&gt; — concept&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;../../io-devices&quot; class=&quot;internal alias&quot; data-slug=&quot;io-devices&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;O Devices&lt;/a&gt; — concept&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;../../io-request-to-hardware&quot; class=&quot;internal alias&quot; data-slug=&quot;io-request-to-hardware&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;O Request to Hardware Operation&lt;/a&gt; — concept&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;../../io-software-structure&quot; class=&quot;internal alias&quot; data-slug=&quot;io-software-structure&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;O Software Structure&lt;/a&gt; — concept&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;../../io-system&quot; class=&quot;internal alias&quot; data-slug=&quot;io-system&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;O System&lt;/a&gt; — concept&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;../../linear-probing&quot; class=&quot;internal alias&quot; data-slug=&quot;linear-probing&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Linear Probing&lt;/a&gt; — concept&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;../../load-factor&quot; class=&quot;internal alias&quot; data-slug=&quot;load-factor&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Load Factor&lt;/a&gt; — concept&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;../../look-scheduling&quot; class=&quot;internal alias&quot; data-slug=&quot;look-scheduling&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;LOOK Scheduling&lt;/a&gt; — concept&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;../../network-driver&quot; class=&quot;internal alias&quot; data-slug=&quot;network-driver&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Network Driver&lt;/a&gt; — concept&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;../../page-fault&quot; class=&quot;internal alias&quot; data-slug=&quot;page-fault&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Page Fault&lt;/a&gt; — concept&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;../../page-table&quot; class=&quot;internal alias&quot; data-slug=&quot;page-table&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Page Table&lt;/a&gt; — concept&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;../../paging&quot; class=&quot;internal alias&quot; data-slug=&quot;paging&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Paging&lt;/a&gt; — concept&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;../../paging-vs-segmentation&quot; class=&quot;internal&quot; data-slug=&quot;paging-vs-segmentation&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;paging-vs-segmentation&lt;/a&gt; — concept&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;../../polling&quot; class=&quot;internal alias&quot; data-slug=&quot;polling&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Polling&lt;/a&gt; — concept&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;../../producer-consumer&quot; class=&quot;internal alias&quot; data-slug=&quot;producer-consumer&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Producer-Consumer Problem&lt;/a&gt; — concept&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;../../quadratic-probing&quot; class=&quot;internal alias&quot; data-slug=&quot;quadratic-probing&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Quadratic Probing&lt;/a&gt; — concept&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;../../raid&quot; class=&quot;internal alias&quot; data-slug=&quot;raid&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;RAID&lt;/a&gt; — concept&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;../../reader-writer&quot; class=&quot;internal alias&quot; data-slug=&quot;reader-writer&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Reader-Writer Problem&lt;/a&gt; — concept&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;../../scan-scheduling&quot; class=&quot;internal alias&quot; data-slug=&quot;scan-scheduling&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;SCAN Scheduling&lt;/a&gt; — concept&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;../../segmentation&quot; class=&quot;internal alias&quot; data-slug=&quot;segmentation&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Segmentation&lt;/a&gt; — concept&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;../../semaphore&quot; class=&quot;internal alias&quot; data-slug=&quot;semaphore&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Semaphore&lt;/a&gt; — concept&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;../../semaphore-types&quot; class=&quot;internal&quot; data-slug=&quot;semaphore-types&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;semaphore-types&lt;/a&gt; — concept&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;../../separate-chaining&quot; class=&quot;internal alias&quot; data-slug=&quot;separate-chaining&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Separate Chaining&lt;/a&gt; — concept&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;../../signal-operation&quot; class=&quot;internal alias&quot; data-slug=&quot;signal-operation&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;signal Operation&lt;/a&gt; — concept&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;../../sstf&quot; class=&quot;internal alias&quot; data-slug=&quot;sstf&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;SSTF&lt;/a&gt; — concept&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;../../swap-space&quot; class=&quot;internal alias&quot; data-slug=&quot;swap-space&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Swap Space&lt;/a&gt; — concept&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;../../system-bus&quot; class=&quot;internal alias&quot; data-slug=&quot;system-bus&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;System Bus&lt;/a&gt; — concept&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;../../thrashing&quot; class=&quot;internal alias&quot; data-slug=&quot;thrashing&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Thrashing&lt;/a&gt; — concept&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;../../tlb&quot; class=&quot;internal alias&quot; data-slug=&quot;tlb&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;TLB&lt;/a&gt; — concept&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;../../user-level-io-software&quot; class=&quot;internal alias&quot; data-slug=&quot;user-level-io-software&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;O Software&lt;/a&gt; — concept&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;../../virtual-memory&quot; class=&quot;internal alias&quot; data-slug=&quot;virtual-memory&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Virtual Memory&lt;/a&gt; — concept&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;../../wait-operation&quot; class=&quot;internal alias&quot; data-slug=&quot;wait-operation&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;wait Operation&lt;/a&gt; — concept&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;mechanisms--how-things-work&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Mechanisms &amp;#x26; How Things Work&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#mechanisms--how-things-work&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;&lt;em&gt;Auto-generated — edit to curate. Pages that explain processes/flows.&lt;/em&gt;&lt;/p&gt;
&lt;h2 id=&quot;comparisons--tradeoffs&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Comparisons &amp;#x26; Tradeoffs&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#comparisons--tradeoffs&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;em&gt;(No synthesis yet — create via ingest or query —save)&lt;/em&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;suggested-reading-order&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Suggested Reading Order&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#suggested-reading-order&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ol dir=&quot;auto&quot;&gt;
&lt;li&gt;Browse Core Concepts above — start with most-linked page&lt;/li&gt;
&lt;li&gt;Follow Connections sections for dense graph traversal&lt;/li&gt;
&lt;/ol&gt;</content>
  </entry><entry>
    <title>memory</title>
    <link href="https://animishraa05.github.io/wiki/io/memory" />
    <link rel="alternate" type="text/markdown" href="https://animishraa05.github.io/wiki/io/memory.md" />
    <summary>The Problem Auto-created stub for broken link [[memory]] — needs human content.</summary>
    <published>2026-09-02T00:00:00.000Z</published>
    <updated>2026-09-02T00:00:00.000Z</updated>
    <publishedTime>Sep 02, 2026</publishedTime>
    <updatedTime>Sep 02, 2026</updatedTime>
    <category term="dev" label="dev" />
    <author>
      <name>Animesh Mishra</name>
      <email>animesh.mishra818@gmail.com</email>
    </author>
    <content type="html">&lt;h2 id=&quot;the-problem&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;The Problem&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#the-problem&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;Auto-created stub for broken link &lt;code class=&quot;notranslate&quot;&gt;[[memory]]&lt;/code&gt; — needs human content.&lt;/p&gt;
&lt;h2 id=&quot;formal-definition&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Formal Definition&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#formal-definition&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;Per Wikipedia: “To be written.”&lt;/p&gt;
&lt;h2 id=&quot;explanation&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Explanation&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#explanation&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;Stub — fill with plain language explanation.&lt;/p&gt;
&lt;h2 id=&quot;how-it-works&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;How It Works&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#how-it-works&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ol dir=&quot;auto&quot;&gt;
&lt;li&gt;To be written.&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&quot;visual-explanation&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Visual Explanation&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#visual-explanation&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;div class=&quot;graphviz-container&quot; style=&quot;display: flex; justify-content: center; margin: 1.5rem 0; overflow-x: auto;&quot; dir=&quot;auto&quot;&gt;&lt;!--?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?--&gt;

&lt;!-- Generated by graphviz version 15.1.0 (0)
 --&gt;
&lt;!-- Title: memory Pages: 1 --&gt;
&lt;svg width=&quot;321pt&quot; height=&quot;44pt&quot; viewBox=&quot;0.00 0.00 321.00 44.00&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; xmlns:xlink=&quot;http://www.w3.org/1999/xlink&quot;&gt;
&lt;g id=&quot;graph0&quot; class=&quot;graph&quot; transform=&quot;scale(1 1) rotate(0) translate(4 40)&quot;&gt;
&lt;title&gt;memory&lt;/title&gt;
&lt;polygon fill=&quot;white&quot; stroke=&quot;none&quot; points=&quot;-4,4 -4,-40 316.64,-40 316.64,4 -4,4&quot;&gt;&lt;/polygon&gt;
&lt;!-- A --&gt;
&lt;g id=&quot;node1&quot; class=&quot;node&quot;&gt;
&lt;title&gt;A&lt;/title&gt;
&lt;polygon fill=&quot;#f0f4ff&quot; stroke=&quot;black&quot; points=&quot;103.14,-36 0,-36 0,0 103.14,0 103.14,-36&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;51.57&quot; y=&quot;-13.8&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;14.00&quot;&gt;Stub: memory&lt;/text&gt;
&lt;/g&gt;
&lt;!-- B --&gt;
&lt;g id=&quot;node2&quot; class=&quot;node&quot;&gt;
&lt;title&gt;B&lt;/title&gt;
&lt;polygon fill=&quot;#f0f4ff&quot; stroke=&quot;black&quot; points=&quot;312.64,-36 215.72,-36 215.72,0 312.64,0 312.64,-36&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;264.18&quot; y=&quot;-13.8&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;14.00&quot;&gt;To be written&lt;/text&gt;
&lt;/g&gt;
&lt;!-- A&amp;#45;&amp;gt;B --&gt;
&lt;g id=&quot;edge1&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;A-&gt;B&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M103.55,-18C133.91,-18 172.57,-18 204.23,-18&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;204.04,-21.5 214.04,-18 204.04,-14.5 204.04,-21.5&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;159.43&quot; y=&quot;-22.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;needs content&lt;/text&gt;
&lt;/g&gt;
&lt;/g&gt;
&lt;/svg&gt;
&lt;/div&gt;
&lt;h2 id=&quot;semantic-network&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Semantic Network&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#semantic-network&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;div class=&quot;graphviz-container&quot; style=&quot;display: flex; justify-content: center; margin: 1.5rem 0; overflow-x: auto;&quot; dir=&quot;auto&quot;&gt;&lt;!--?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?--&gt;

&lt;!-- Generated by graphviz version 15.1.0 (0)
 --&gt;
&lt;!-- Title: semantic_memory Pages: 1 --&gt;
&lt;svg width=&quot;154pt&quot; height=&quot;55pt&quot; viewBox=&quot;0.00 0.00 154.00 55.00&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; xmlns:xlink=&quot;http://www.w3.org/1999/xlink&quot;&gt;
&lt;g id=&quot;graph0&quot; class=&quot;graph&quot; transform=&quot;scale(1 1) rotate(0) translate(4 50.64)&quot;&gt;
&lt;title&gt;semantic_memory&lt;/title&gt;
&lt;polygon fill=&quot;white&quot; stroke=&quot;none&quot; points=&quot;-4,4 -4,-50.64 150.24,-50.64 150.24,4 -4,4&quot;&gt;&lt;/polygon&gt;
&lt;!-- THIS --&gt;
&lt;g id=&quot;node1&quot; class=&quot;node&quot;&gt;
&lt;title&gt;THIS&lt;/title&gt;
&lt;ellipse fill=&quot;#ffd700&quot; stroke=&quot;black&quot; stroke-width=&quot;2&quot; cx=&quot;41.68&quot; cy=&quot;-28.64&quot; rx=&quot;41.68&quot; ry=&quot;18&quot;&gt;&lt;/ellipse&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;41.68&quot; y=&quot;-24.74&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;13.00&quot;&gt;memory&lt;/text&gt;
&lt;/g&gt;
&lt;!-- REL1 --&gt;
&lt;g id=&quot;node2&quot; class=&quot;node&quot;&gt;
&lt;title&gt;REL1&lt;/title&gt;
&lt;ellipse fill=&quot;#f0f0f0&quot; stroke=&quot;black&quot; cx=&quot;112.89&quot; cy=&quot;-18&quot; rx=&quot;33.35&quot; ry=&quot;18&quot;&gt;&lt;/ellipse&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;112.89&quot; y=&quot;-14.7&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;11.00&quot;&gt;Related&lt;/text&gt;
&lt;/g&gt;
&lt;!-- THIS&amp;#45;&amp;#45;REL1 --&gt;
&lt;g id=&quot;edge1&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;THIS--REL1&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M81.45,-22.7C81.58,-22.68 81.7,-22.66 81.83,-22.64&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;72.12&quot; y=&quot;-10.07&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;related&lt;/text&gt;
&lt;/g&gt;
&lt;/g&gt;
&lt;/svg&gt;
&lt;/div&gt;
&lt;h2 id=&quot;key-properties&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Key Properties&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#key-properties&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;To be written.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;real-world-example&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Real-World Example&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#real-world-example&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;figure data-rehype-pretty-code-figure=&quot;&quot;&gt;&lt;pre style=&quot;--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e&quot; tabindex=&quot;0&quot; data-language=&quot;python&quot; data-theme=&quot;github-light github-dark&quot; class=&quot;notranslate&quot;&gt;&lt;span class=&quot;clipboard-button&quot; type=&quot;button&quot; aria-label=&quot;copy source&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 -8 24 24&quot; fill=&quot;currentColor&quot; stroke=&quot;none&quot; stroke-width=&quot;0&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;copy-icon&quot;&gt;&lt;use href=&quot;#github-copy&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 -8 24 24&quot; fill=&quot;currentColor&quot; stroke=&quot;none&quot; stroke-width=&quot;0&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;check-icon&quot;&gt;&lt;use href=&quot;#github-check&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;code data-language=&quot;python&quot; data-theme=&quot;github-light github-dark&quot; style=&quot;display: grid;&quot; class=&quot;notranslate&quot;&gt;&lt;span data-line=&quot;&quot;&gt;&lt;span style=&quot;--shiki-light:#6A737D;--shiki-dark:#6A737D&quot;&gt;# &lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;TODO&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6A737D;--shiki-dark:#6A737D&quot;&gt;: add example&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;
&lt;h2 id=&quot;connections&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Connections&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#connections&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../&quot; class=&quot;internal alias&quot; data-slug=&quot;index&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Index&lt;/a&gt; — auto stub, needs proper links&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;edge-cases--gotchas&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Edge Cases &amp;#x26; Gotchas&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#edge-cases--gotchas&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;To be written.&lt;/li&gt;
&lt;/ul&gt;</content>
  </entry><entry>
    <title>mutex</title>
    <link href="https://animishraa05.github.io/wiki/io/mutex" />
    <link rel="alternate" type="text/markdown" href="https://animishraa05.github.io/wiki/io/mutex.md" />
    <summary>The Problem Auto-created stub for broken link [[mutex]] — needs human content.</summary>
    <published>2026-09-02T00:00:00.000Z</published>
    <updated>2026-09-02T00:00:00.000Z</updated>
    <publishedTime>Sep 02, 2026</publishedTime>
    <updatedTime>Sep 02, 2026</updatedTime>
    <category term="dev" label="dev" />
    <author>
      <name>Animesh Mishra</name>
      <email>animesh.mishra818@gmail.com</email>
    </author>
    <content type="html">&lt;h2 id=&quot;the-problem&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;The Problem&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#the-problem&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;Auto-created stub for broken link &lt;code class=&quot;notranslate&quot;&gt;[[mutex]]&lt;/code&gt; — needs human content.&lt;/p&gt;
&lt;h2 id=&quot;formal-definition&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Formal Definition&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#formal-definition&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;Per Wikipedia: “To be written.”&lt;/p&gt;
&lt;h2 id=&quot;explanation&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Explanation&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#explanation&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;Stub — fill with plain language explanation.&lt;/p&gt;
&lt;h2 id=&quot;how-it-works&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;How It Works&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#how-it-works&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ol dir=&quot;auto&quot;&gt;
&lt;li&gt;To be written.&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&quot;visual-explanation&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Visual Explanation&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#visual-explanation&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;div class=&quot;graphviz-container&quot; style=&quot;display: flex; justify-content: center; margin: 1.5rem 0; overflow-x: auto;&quot; dir=&quot;auto&quot;&gt;&lt;!--?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?--&gt;

&lt;!-- Generated by graphviz version 15.1.0 (0)
 --&gt;
&lt;!-- Title: mutex Pages: 1 --&gt;
&lt;svg width=&quot;308pt&quot; height=&quot;44pt&quot; viewBox=&quot;0.00 0.00 308.00 44.00&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; xmlns:xlink=&quot;http://www.w3.org/1999/xlink&quot;&gt;
&lt;g id=&quot;graph0&quot; class=&quot;graph&quot; transform=&quot;scale(1 1) rotate(0) translate(4 40)&quot;&gt;
&lt;title&gt;mutex&lt;/title&gt;
&lt;polygon fill=&quot;white&quot; stroke=&quot;none&quot; points=&quot;-4,4 -4,-40 304.21,-40 304.21,4 -4,4&quot;&gt;&lt;/polygon&gt;
&lt;!-- A --&gt;
&lt;g id=&quot;node1&quot; class=&quot;node&quot;&gt;
&lt;title&gt;A&lt;/title&gt;
&lt;polygon fill=&quot;#f0f4ff&quot; stroke=&quot;black&quot; points=&quot;90.7,-36 0,-36 0,0 90.7,0 90.7,-36&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;45.35&quot; y=&quot;-13.8&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;14.00&quot;&gt;Stub: mutex&lt;/text&gt;
&lt;/g&gt;
&lt;!-- B --&gt;
&lt;g id=&quot;node2&quot; class=&quot;node&quot;&gt;
&lt;title&gt;B&lt;/title&gt;
&lt;polygon fill=&quot;#f0f4ff&quot; stroke=&quot;black&quot; points=&quot;300.21,-36 203.29,-36 203.29,0 300.21,0 300.21,-36&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;251.75&quot; y=&quot;-13.8&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;14.00&quot;&gt;To be written&lt;/text&gt;
&lt;/g&gt;
&lt;!-- A&amp;#45;&amp;gt;B --&gt;
&lt;g id=&quot;edge1&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;A-&gt;B&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M90.95,-18C120.46,-18 159.47,-18 191.56,-18&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;191.52,-21.5 201.52,-18 191.52,-14.5 191.52,-21.5&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;146.99&quot; y=&quot;-22.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;needs content&lt;/text&gt;
&lt;/g&gt;
&lt;/g&gt;
&lt;/svg&gt;
&lt;/div&gt;
&lt;h2 id=&quot;semantic-network&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Semantic Network&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#semantic-network&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;div class=&quot;graphviz-container&quot; style=&quot;display: flex; justify-content: center; margin: 1.5rem 0; overflow-x: auto;&quot; dir=&quot;auto&quot;&gt;&lt;!--?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?--&gt;

&lt;!-- Generated by graphviz version 15.1.0 (0)
 --&gt;
&lt;!-- Title: semantic_mutex Pages: 1 --&gt;
&lt;svg width=&quot;147pt&quot; height=&quot;55pt&quot; viewBox=&quot;0.00 0.00 147.00 55.00&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; xmlns:xlink=&quot;http://www.w3.org/1999/xlink&quot;&gt;
&lt;g id=&quot;graph0&quot; class=&quot;graph&quot; transform=&quot;scale(1 1) rotate(0) translate(4 50.64)&quot;&gt;
&lt;title&gt;semantic_mutex&lt;/title&gt;
&lt;polygon fill=&quot;white&quot; stroke=&quot;none&quot; points=&quot;-4,4 -4,-50.64 142.6,-50.64 142.6,4 -4,4&quot;&gt;&lt;/polygon&gt;
&lt;!-- THIS --&gt;
&lt;g id=&quot;node1&quot; class=&quot;node&quot;&gt;
&lt;title&gt;THIS&lt;/title&gt;
&lt;ellipse fill=&quot;#ffd700&quot; stroke=&quot;black&quot; stroke-width=&quot;2&quot; cx=&quot;34.03&quot; cy=&quot;-28.64&quot; rx=&quot;34.03&quot; ry=&quot;18&quot;&gt;&lt;/ellipse&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;34.03&quot; y=&quot;-24.74&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;13.00&quot;&gt;mutex&lt;/text&gt;
&lt;/g&gt;
&lt;!-- REL1 --&gt;
&lt;g id=&quot;node2&quot; class=&quot;node&quot;&gt;
&lt;title&gt;REL1&lt;/title&gt;
&lt;ellipse fill=&quot;#f0f0f0&quot; stroke=&quot;black&quot; cx=&quot;105.24&quot; cy=&quot;-18&quot; rx=&quot;33.35&quot; ry=&quot;18&quot;&gt;&lt;/ellipse&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;105.24&quot; y=&quot;-14.7&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;11.00&quot;&gt;Related&lt;/text&gt;
&lt;/g&gt;
&lt;!-- THIS&amp;#45;&amp;#45;REL1 --&gt;
&lt;g id=&quot;edge1&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;THIS--REL1&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M67.14,-23.69C69.03,-23.41 70.92,-23.13 72.81,-22.85&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;50.93&quot; y=&quot;-10.67&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;related&lt;/text&gt;
&lt;/g&gt;
&lt;/g&gt;
&lt;/svg&gt;
&lt;/div&gt;
&lt;h2 id=&quot;key-properties&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Key Properties&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#key-properties&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;To be written.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;real-world-example&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Real-World Example&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#real-world-example&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;figure data-rehype-pretty-code-figure=&quot;&quot;&gt;&lt;pre style=&quot;--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e&quot; tabindex=&quot;0&quot; data-language=&quot;python&quot; data-theme=&quot;github-light github-dark&quot; class=&quot;notranslate&quot;&gt;&lt;span class=&quot;clipboard-button&quot; type=&quot;button&quot; aria-label=&quot;copy source&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 -8 24 24&quot; fill=&quot;currentColor&quot; stroke=&quot;none&quot; stroke-width=&quot;0&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;copy-icon&quot;&gt;&lt;use href=&quot;#github-copy&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 -8 24 24&quot; fill=&quot;currentColor&quot; stroke=&quot;none&quot; stroke-width=&quot;0&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;check-icon&quot;&gt;&lt;use href=&quot;#github-check&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;code data-language=&quot;python&quot; data-theme=&quot;github-light github-dark&quot; style=&quot;display: grid;&quot; class=&quot;notranslate&quot;&gt;&lt;span data-line=&quot;&quot;&gt;&lt;span style=&quot;--shiki-light:#6A737D;--shiki-dark:#6A737D&quot;&gt;# &lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;TODO&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6A737D;--shiki-dark:#6A737D&quot;&gt;: add example&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;
&lt;h2 id=&quot;connections&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Connections&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#connections&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../&quot; class=&quot;internal alias&quot; data-slug=&quot;index&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Index&lt;/a&gt; — auto stub, needs proper links&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;edge-cases--gotchas&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Edge Cases &amp;#x26; Gotchas&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#edge-cases--gotchas&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;To be written.&lt;/li&gt;
&lt;/ul&gt;</content>
  </entry><entry>
    <title>race-condition</title>
    <link href="https://animishraa05.github.io/wiki/io/race-condition" />
    <link rel="alternate" type="text/markdown" href="https://animishraa05.github.io/wiki/io/race-condition.md" />
    <summary>The Problem Auto-created stub for broken link [[race-condition]] — needs human content.</summary>
    <published>2026-09-02T00:00:00.000Z</published>
    <updated>2026-09-02T00:00:00.000Z</updated>
    <publishedTime>Sep 02, 2026</publishedTime>
    <updatedTime>Sep 02, 2026</updatedTime>
    <category term="dev" label="dev" />
    <author>
      <name>Animesh Mishra</name>
      <email>animesh.mishra818@gmail.com</email>
    </author>
    <content type="html">&lt;h2 id=&quot;the-problem&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;The Problem&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#the-problem&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;Auto-created stub for broken link &lt;code class=&quot;notranslate&quot;&gt;[[race-condition]]&lt;/code&gt; — needs human content.&lt;/p&gt;
&lt;h2 id=&quot;formal-definition&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Formal Definition&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#formal-definition&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;Per Wikipedia: “To be written.”&lt;/p&gt;
&lt;h2 id=&quot;explanation&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Explanation&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#explanation&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;Stub — fill with plain language explanation.&lt;/p&gt;
&lt;h2 id=&quot;how-it-works&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;How It Works&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#how-it-works&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ol dir=&quot;auto&quot;&gt;
&lt;li&gt;To be written.&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&quot;visual-explanation&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Visual Explanation&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#visual-explanation&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;figure data-rehype-pretty-code-figure=&quot;&quot;&gt;&lt;pre class=&quot;notranslate&quot; style=&quot;--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e&quot; tabindex=&quot;0&quot; data-language=&quot;dot&quot; data-theme=&quot;github-light github-dark&quot;&gt;&lt;span class=&quot;clipboard-button&quot; type=&quot;button&quot; aria-label=&quot;copy source&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 -8 24 24&quot; fill=&quot;currentColor&quot; stroke=&quot;none&quot; stroke-width=&quot;0&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;copy-icon&quot;&gt;&lt;use href=&quot;#github-copy&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 -8 24 24&quot; fill=&quot;currentColor&quot; stroke=&quot;none&quot; stroke-width=&quot;0&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;check-icon&quot;&gt;&lt;use href=&quot;#github-check&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;code data-language=&quot;dot&quot; data-theme=&quot;github-light github-dark&quot; style=&quot;display: grid;&quot; class=&quot;notranslate&quot;&gt;&lt;span data-line=&quot;&quot;&gt;&lt;span&gt;digraph race-condition {&lt;/span&gt;&lt;/span&gt;
&lt;span data-line=&quot;&quot;&gt;&lt;span&gt;  rankdir=LR&lt;/span&gt;&lt;/span&gt;
&lt;span data-line=&quot;&quot;&gt;&lt;span&gt;  node [shape=box style=filled fillcolor=&quot;#f0f4ff&quot; fontname=&quot;Helvetica&quot;]&lt;/span&gt;&lt;/span&gt;
&lt;span data-line=&quot;&quot;&gt;&lt;span&gt;  A [label=&quot;Stub: race-condition&quot;]&lt;/span&gt;&lt;/span&gt;
&lt;span data-line=&quot;&quot;&gt;&lt;span&gt;  B [label=&quot;To be written&quot;]&lt;/span&gt;&lt;/span&gt;
&lt;span data-line=&quot;&quot;&gt;&lt;span&gt;  A -&gt; B [label=&quot;needs content&quot;]&lt;/span&gt;&lt;/span&gt;
&lt;span data-line=&quot;&quot;&gt;&lt;span&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;
&lt;h2 id=&quot;semantic-network&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Semantic Network&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#semantic-network&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;figure data-rehype-pretty-code-figure=&quot;&quot;&gt;&lt;pre class=&quot;notranslate&quot; style=&quot;--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e&quot; tabindex=&quot;0&quot; data-language=&quot;dot&quot; data-theme=&quot;github-light github-dark&quot;&gt;&lt;span class=&quot;clipboard-button&quot; type=&quot;button&quot; aria-label=&quot;copy source&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 -8 24 24&quot; fill=&quot;currentColor&quot; stroke=&quot;none&quot; stroke-width=&quot;0&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;copy-icon&quot;&gt;&lt;use href=&quot;#github-copy&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 -8 24 24&quot; fill=&quot;currentColor&quot; stroke=&quot;none&quot; stroke-width=&quot;0&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;check-icon&quot;&gt;&lt;use href=&quot;#github-check&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;code data-language=&quot;dot&quot; data-theme=&quot;github-light github-dark&quot; style=&quot;display: grid;&quot; class=&quot;notranslate&quot;&gt;&lt;span data-line=&quot;&quot;&gt;&lt;span&gt;graph semantic_race-condition {&lt;/span&gt;&lt;/span&gt;
&lt;span data-line=&quot;&quot;&gt;&lt;span&gt;  layout=neato&lt;/span&gt;&lt;/span&gt;
&lt;span data-line=&quot;&quot;&gt;&lt;span&gt;  node [shape=ellipse fontname=&quot;Helvetica&quot; fontsize=11 style=filled]&lt;/span&gt;&lt;/span&gt;
&lt;span data-line=&quot;&quot;&gt;&lt;span&gt;  THIS [label=&quot;race condition&quot; fillcolor=&quot;#ffd700&quot; fontsize=13 style=&quot;filled,bold&quot;]&lt;/span&gt;&lt;/span&gt;
&lt;span data-line=&quot;&quot;&gt;&lt;span&gt;  REL1 [label=&quot;Related&quot; fillcolor=&quot;#f0f0f0&quot;]&lt;/span&gt;&lt;/span&gt;
&lt;span data-line=&quot;&quot;&gt;&lt;span&gt;  THIS -- REL1 [label=&quot;related&quot;]&lt;/span&gt;&lt;/span&gt;
&lt;span data-line=&quot;&quot;&gt;&lt;span&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;
&lt;h2 id=&quot;key-properties&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Key Properties&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#key-properties&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;To be written.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;real-world-example&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Real-World Example&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#real-world-example&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;figure data-rehype-pretty-code-figure=&quot;&quot;&gt;&lt;pre class=&quot;notranslate&quot; style=&quot;--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e&quot; tabindex=&quot;0&quot; data-language=&quot;python&quot; data-theme=&quot;github-light github-dark&quot;&gt;&lt;span class=&quot;clipboard-button&quot; type=&quot;button&quot; aria-label=&quot;copy source&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 -8 24 24&quot; fill=&quot;currentColor&quot; stroke=&quot;none&quot; stroke-width=&quot;0&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;copy-icon&quot;&gt;&lt;use href=&quot;#github-copy&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 -8 24 24&quot; fill=&quot;currentColor&quot; stroke=&quot;none&quot; stroke-width=&quot;0&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;check-icon&quot;&gt;&lt;use href=&quot;#github-check&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;code data-language=&quot;python&quot; data-theme=&quot;github-light github-dark&quot; style=&quot;display: grid;&quot; class=&quot;notranslate&quot;&gt;&lt;span data-line=&quot;&quot;&gt;&lt;span style=&quot;--shiki-light:#6A737D;--shiki-dark:#6A737D&quot;&gt;# &lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;TODO&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6A737D;--shiki-dark:#6A737D&quot;&gt;: add example&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;
&lt;h2 id=&quot;connections&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Connections&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#connections&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../&quot; class=&quot;internal alias&quot; data-slug=&quot;index&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Index&lt;/a&gt; — auto stub, needs proper links&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;edge-cases--gotchas&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Edge Cases &amp;#x26; Gotchas&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#edge-cases--gotchas&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;To be written.&lt;/li&gt;
&lt;/ul&gt;</content>
  </entry><entry>
    <title>segment-table</title>
    <link href="https://animishraa05.github.io/wiki/io/segment-table" />
    <link rel="alternate" type="text/markdown" href="https://animishraa05.github.io/wiki/io/segment-table.md" />
    <summary>The Problem Auto-created stub for broken link [[segment-table]] — needs human content.</summary>
    <published>2026-09-02T00:00:00.000Z</published>
    <updated>2026-09-02T00:00:00.000Z</updated>
    <publishedTime>Sep 02, 2026</publishedTime>
    <updatedTime>Sep 02, 2026</updatedTime>
    <category term="dev" label="dev" />
    <author>
      <name>Animesh Mishra</name>
      <email>animesh.mishra818@gmail.com</email>
    </author>
    <content type="html">&lt;h2 id=&quot;the-problem&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;The Problem&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#the-problem&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;Auto-created stub for broken link &lt;code class=&quot;notranslate&quot;&gt;[[segment-table]]&lt;/code&gt; — needs human content.&lt;/p&gt;
&lt;h2 id=&quot;formal-definition&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Formal Definition&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#formal-definition&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;Per Wikipedia: “To be written.”&lt;/p&gt;
&lt;h2 id=&quot;explanation&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Explanation&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#explanation&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;Stub — fill with plain language explanation.&lt;/p&gt;
&lt;h2 id=&quot;how-it-works&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;How It Works&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#how-it-works&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ol dir=&quot;auto&quot;&gt;
&lt;li&gt;To be written.&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&quot;visual-explanation&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Visual Explanation&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#visual-explanation&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;figure data-rehype-pretty-code-figure=&quot;&quot;&gt;&lt;pre class=&quot;notranslate&quot; style=&quot;--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e&quot; tabindex=&quot;0&quot; data-language=&quot;dot&quot; data-theme=&quot;github-light github-dark&quot;&gt;&lt;span class=&quot;clipboard-button&quot; type=&quot;button&quot; aria-label=&quot;copy source&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 -8 24 24&quot; fill=&quot;currentColor&quot; stroke=&quot;none&quot; stroke-width=&quot;0&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;copy-icon&quot;&gt;&lt;use href=&quot;#github-copy&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 -8 24 24&quot; fill=&quot;currentColor&quot; stroke=&quot;none&quot; stroke-width=&quot;0&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;check-icon&quot;&gt;&lt;use href=&quot;#github-check&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;code data-language=&quot;dot&quot; data-theme=&quot;github-light github-dark&quot; style=&quot;display: grid;&quot; class=&quot;notranslate&quot;&gt;&lt;span data-line=&quot;&quot;&gt;&lt;span&gt;digraph segment-table {&lt;/span&gt;&lt;/span&gt;
&lt;span data-line=&quot;&quot;&gt;&lt;span&gt;  rankdir=LR&lt;/span&gt;&lt;/span&gt;
&lt;span data-line=&quot;&quot;&gt;&lt;span&gt;  node [shape=box style=filled fillcolor=&quot;#f0f4ff&quot; fontname=&quot;Helvetica&quot;]&lt;/span&gt;&lt;/span&gt;
&lt;span data-line=&quot;&quot;&gt;&lt;span&gt;  A [label=&quot;Stub: segment-table&quot;]&lt;/span&gt;&lt;/span&gt;
&lt;span data-line=&quot;&quot;&gt;&lt;span&gt;  B [label=&quot;To be written&quot;]&lt;/span&gt;&lt;/span&gt;
&lt;span data-line=&quot;&quot;&gt;&lt;span&gt;  A -&gt; B [label=&quot;needs content&quot;]&lt;/span&gt;&lt;/span&gt;
&lt;span data-line=&quot;&quot;&gt;&lt;span&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;
&lt;h2 id=&quot;semantic-network&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Semantic Network&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#semantic-network&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;figure data-rehype-pretty-code-figure=&quot;&quot;&gt;&lt;pre class=&quot;notranslate&quot; style=&quot;--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e&quot; tabindex=&quot;0&quot; data-language=&quot;dot&quot; data-theme=&quot;github-light github-dark&quot;&gt;&lt;span class=&quot;clipboard-button&quot; type=&quot;button&quot; aria-label=&quot;copy source&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 -8 24 24&quot; fill=&quot;currentColor&quot; stroke=&quot;none&quot; stroke-width=&quot;0&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;copy-icon&quot;&gt;&lt;use href=&quot;#github-copy&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 -8 24 24&quot; fill=&quot;currentColor&quot; stroke=&quot;none&quot; stroke-width=&quot;0&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;check-icon&quot;&gt;&lt;use href=&quot;#github-check&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;code data-language=&quot;dot&quot; data-theme=&quot;github-light github-dark&quot; style=&quot;display: grid;&quot; class=&quot;notranslate&quot;&gt;&lt;span data-line=&quot;&quot;&gt;&lt;span&gt;graph semantic_segment-table {&lt;/span&gt;&lt;/span&gt;
&lt;span data-line=&quot;&quot;&gt;&lt;span&gt;  layout=neato&lt;/span&gt;&lt;/span&gt;
&lt;span data-line=&quot;&quot;&gt;&lt;span&gt;  node [shape=ellipse fontname=&quot;Helvetica&quot; fontsize=11 style=filled]&lt;/span&gt;&lt;/span&gt;
&lt;span data-line=&quot;&quot;&gt;&lt;span&gt;  THIS [label=&quot;segment table&quot; fillcolor=&quot;#ffd700&quot; fontsize=13 style=&quot;filled,bold&quot;]&lt;/span&gt;&lt;/span&gt;
&lt;span data-line=&quot;&quot;&gt;&lt;span&gt;  REL1 [label=&quot;Related&quot; fillcolor=&quot;#f0f0f0&quot;]&lt;/span&gt;&lt;/span&gt;
&lt;span data-line=&quot;&quot;&gt;&lt;span&gt;  THIS -- REL1 [label=&quot;related&quot;]&lt;/span&gt;&lt;/span&gt;
&lt;span data-line=&quot;&quot;&gt;&lt;span&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;
&lt;h2 id=&quot;key-properties&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Key Properties&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#key-properties&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;To be written.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;real-world-example&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Real-World Example&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#real-world-example&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;figure data-rehype-pretty-code-figure=&quot;&quot;&gt;&lt;pre class=&quot;notranslate&quot; style=&quot;--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e&quot; tabindex=&quot;0&quot; data-language=&quot;python&quot; data-theme=&quot;github-light github-dark&quot;&gt;&lt;span class=&quot;clipboard-button&quot; type=&quot;button&quot; aria-label=&quot;copy source&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 -8 24 24&quot; fill=&quot;currentColor&quot; stroke=&quot;none&quot; stroke-width=&quot;0&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;copy-icon&quot;&gt;&lt;use href=&quot;#github-copy&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 -8 24 24&quot; fill=&quot;currentColor&quot; stroke=&quot;none&quot; stroke-width=&quot;0&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;check-icon&quot;&gt;&lt;use href=&quot;#github-check&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;code data-language=&quot;python&quot; data-theme=&quot;github-light github-dark&quot; style=&quot;display: grid;&quot; class=&quot;notranslate&quot;&gt;&lt;span data-line=&quot;&quot;&gt;&lt;span style=&quot;--shiki-light:#6A737D;--shiki-dark:#6A737D&quot;&gt;# &lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;TODO&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6A737D;--shiki-dark:#6A737D&quot;&gt;: add example&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;
&lt;h2 id=&quot;connections&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Connections&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#connections&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../&quot; class=&quot;internal alias&quot; data-slug=&quot;index&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Index&lt;/a&gt; — auto stub, needs proper links&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;edge-cases--gotchas&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Edge Cases &amp;#x26; Gotchas&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#edge-cases--gotchas&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;To be written.&lt;/li&gt;
&lt;/ul&gt;</content>
  </entry><entry>
    <title>binary-semaphore</title>
    <link href="https://animishraa05.github.io/wiki/io/binary-semaphore" />
    <link rel="alternate" type="text/markdown" href="https://animishraa05.github.io/wiki/io/binary-semaphore.md" />
    <summary>The Problem When only one process can access a shared resource at a time (mutual exclusion), we need a semaphore with only two states: locked and unlocked.</summary>
    <published>2026-04-30T00:00:00.000Z</published>
    <updated>2026-04-30T00:00:00.000Z</updated>
    <publishedTime>Apr 30, 2026</publishedTime>
    <updatedTime>Apr 30, 2026</updatedTime>
    <category term="systems" label="systems" />
<category term="concurrency" label="concurrency" />
    <author>
      <name>Animesh Mishra</name>
      <email>animesh.mishra818@gmail.com</email>
    </author>
    <content type="html">&lt;h2 id=&quot;the-problem&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;The Problem&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#the-problem&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;When only one process can access a shared resource at a time (mutual exclusion), we need a semaphore with only two states: locked and unlocked.&lt;/p&gt;
&lt;h2 id=&quot;core-idea&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Core Idea&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#core-idea&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;A binary semaphore can only take values 0 (locked) and 1 (unlocked), used for mutual exclusion of critical sections.&lt;/p&gt;
&lt;h2 id=&quot;how-it-works&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;How It Works&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#how-it-works&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ol dir=&quot;auto&quot;&gt;
&lt;li&gt;Initialize semaphore to 1 (unlocked)&lt;/li&gt;
&lt;li&gt;Process enters critical section: &lt;code class=&quot;notranslate&quot;&gt;wait(S)&lt;/code&gt; → S becomes 0 (locked)&lt;/li&gt;
&lt;li&gt;Other processes calling &lt;code class=&quot;notranslate&quot;&gt;wait(S)&lt;/code&gt; block (S becomes negative)&lt;/li&gt;
&lt;li&gt;Process exits: &lt;code class=&quot;notranslate&quot;&gt;signal(S)&lt;/code&gt; → S becomes 1 (unlocked), wake up one waiter&lt;/li&gt;
&lt;/ol&gt;
&lt;div class=&quot;graphviz-container&quot; style=&quot;display: flex; justify-content: center; margin: 1.5rem 0; overflow-x: auto;&quot; dir=&quot;auto&quot;&gt;&lt;!--?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?--&gt;

&lt;!-- Generated by graphviz version 15.1.0 (0)
 --&gt;
&lt;!-- Title: binary_sem Pages: 1 --&gt;
&lt;svg width=&quot;111pt&quot; height=&quot;282pt&quot; viewBox=&quot;0.00 0.00 111.00 282.00&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; xmlns:xlink=&quot;http://www.w3.org/1999/xlink&quot;&gt;
&lt;g id=&quot;graph0&quot; class=&quot;graph&quot; transform=&quot;scale(1 1) rotate(0) translate(4 278.4)&quot;&gt;
&lt;title&gt;binary_sem&lt;/title&gt;
&lt;polygon fill=&quot;white&quot; stroke=&quot;none&quot; points=&quot;-4,4 -4,-278.4 107.48,-278.4 107.48,4 -4,4&quot;&gt;&lt;/polygon&gt;
&lt;!-- Init --&gt;
&lt;g id=&quot;node1&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Init&lt;/title&gt;
&lt;polygon fill=&quot;lightyellow&quot; stroke=&quot;black&quot; points=&quot;90.06,-274.4 13.42,-274.4 13.42,-232.8 90.06,-232.8 90.06,-274.4&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;51.74&quot; y=&quot;-257.8&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Init: S = 1&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;51.74&quot; y=&quot;-241&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;(unlocked)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- P1 --&gt;
&lt;g id=&quot;node2&quot; class=&quot;node&quot;&gt;
&lt;title&gt;P1&lt;/title&gt;
&lt;polygon fill=&quot;lightgreen&quot; stroke=&quot;black&quot; points=&quot;86.38,-196.8 17.1,-196.8 17.1,-155.2 86.38,-155.2 86.38,-196.8&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;51.74&quot; y=&quot;-180.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Process 1&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;51.74&quot; y=&quot;-163.4&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;wait(S)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Init&amp;#45;&amp;gt;P1 --&gt;
&lt;g id=&quot;edge1&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Init-&gt;P1&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M51.74,-232.34C51.74,-224.99 51.74,-216.51 51.74,-208.43&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;55.24,-208.57 51.74,-198.57 48.24,-208.57 55.24,-208.57&quot;&gt;&lt;/polygon&gt;
&lt;/g&gt;
&lt;!-- CS --&gt;
&lt;g id=&quot;node3&quot; class=&quot;node&quot;&gt;
&lt;title&gt;CS&lt;/title&gt;
&lt;polygon fill=&quot;orange&quot; stroke=&quot;black&quot; points=&quot;103.48,-119.2 0,-119.2 0,-77.6 103.48,-77.6 103.48,-119.2&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;51.74&quot; y=&quot;-102.6&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Critical Section&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;51.74&quot; y=&quot;-85.8&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;S = 0 (locked)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- P1&amp;#45;&amp;gt;CS --&gt;
&lt;g id=&quot;edge2&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;P1-&gt;CS&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M51.74,-154.74C51.74,-147.39 51.74,-138.91 51.74,-130.83&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;55.24,-130.97 51.74,-120.97 48.24,-130.97 55.24,-130.97&quot;&gt;&lt;/polygon&gt;
&lt;/g&gt;
&lt;!-- Exit --&gt;
&lt;g id=&quot;node4&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Exit&lt;/title&gt;
&lt;polygon fill=&quot;lightblue&quot; stroke=&quot;black&quot; points=&quot;91.49,-41.6 11.99,-41.6 11.99,0 91.49,0 91.49,-41.6&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;51.74&quot; y=&quot;-25&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;signal(S)&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;51.74&quot; y=&quot;-8.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;S = 1 again&lt;/text&gt;
&lt;/g&gt;
&lt;!-- CS&amp;#45;&amp;gt;Exit --&gt;
&lt;g id=&quot;edge3&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;CS-&gt;Exit&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M51.74,-77.14C51.74,-69.79 51.74,-61.31 51.74,-53.23&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;55.24,-53.37 51.74,-43.37 48.24,-53.37 55.24,-53.37&quot;&gt;&lt;/polygon&gt;
&lt;/g&gt;
&lt;/g&gt;
&lt;/svg&gt;
&lt;/div&gt;
&lt;h2 id=&quot;key-properties&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Key Properties&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#key-properties&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;Only two values: 0 (locked) and 1 (unlocked)&lt;/li&gt;
&lt;li&gt;Provides mutual exclusion (mutex)&lt;/li&gt;
&lt;li&gt;Initialized to 1 for mutex use&lt;/li&gt;
&lt;li&gt;Can be used as a lock/mutex&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;connections&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Connections&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#connections&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Built from:&lt;/strong&gt; &lt;a href=&quot;../../semaphore&quot; class=&quot;internal alias&quot; data-slug=&quot;semaphore&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Semaphore&lt;/a&gt;, &lt;a href=&quot;../../critical-section&quot; class=&quot;internal alias&quot; data-slug=&quot;critical-section&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Critical Section&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Builds into:&lt;/strong&gt; &lt;a href=&quot;../../mutex&quot; class=&quot;internal alias&quot; data-slug=&quot;mutex&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Mutex&lt;/a&gt;, &lt;a href=&quot;../../race-condition&quot; class=&quot;internal alias&quot; data-slug=&quot;race-condition&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Race Condition&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../counting-semaphore&quot; class=&quot;internal alias&quot; data-slug=&quot;counting-semaphore&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Counting Semaphore&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Contrasts with:&lt;/strong&gt; &lt;a href=&quot;../../counting-semaphore&quot; class=&quot;internal alias&quot; data-slug=&quot;counting-semaphore&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Counting Semaphore&lt;/a&gt; (one bit vs N values)&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;edge-cases--gotchas&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Edge Cases &amp;#x26; Gotchas&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#edge-cases--gotchas&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;Busy-waiting implementation wastes CPU (better to block/sleep)&lt;/li&gt;
&lt;li&gt;Must be acquired and released by same process&lt;/li&gt;
&lt;li&gt;Forgetting signal() causes deadlock&lt;/li&gt;
&lt;/ul&gt;</content>
  </entry><entry>
    <title>block-driver</title>
    <link href="https://animishraa05.github.io/wiki/io/block-driver" />
    <link rel="alternate" type="text/markdown" href="https://animishraa05.github.io/wiki/io/block-driver.md" />
    <summary>The Problem Block devices (disks, SSDs) transfer data in fixed-size blocks and support seeking to arbitrary positions.</summary>
    <published>2026-04-30T00:00:00.000Z</published>
    <updated>2026-04-30T00:00:00.000Z</updated>
    <publishedTime>Apr 30, 2026</publishedTime>
    <updatedTime>Apr 30, 2026</updatedTime>
    <category term="systems" label="systems" />
<category term="io" label="io" />
    <author>
      <name>Animesh Mishra</name>
      <email>animesh.mishra818@gmail.com</email>
    </author>
    <content type="html">&lt;h2 id=&quot;the-problem&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;The Problem&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#the-problem&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;Block devices (disks, SSDs) transfer data in fixed-size blocks and support seeking to arbitrary positions. The OS needs a driver type that understands block addressing and buffering.&lt;/p&gt;
&lt;h2 id=&quot;core-idea&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Core Idea&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#core-idea&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;A block driver handles block-oriented devices, managing block-sized data transfers (typically 512B or 4KB), supporting random access and buffering.&lt;/p&gt;
&lt;h2 id=&quot;how-it-works&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;How It Works&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#how-it-works&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ol dir=&quot;auto&quot;&gt;
&lt;li&gt;OS sends block read/write request (block number, count)&lt;/li&gt;
&lt;li&gt;Driver translates block number to disk address (cylinder, head, sector)&lt;/li&gt;
&lt;li&gt;Driver sets up DMA for bulk data transfer&lt;/li&gt;
&lt;li&gt;Driver handles completion interrupt&lt;/li&gt;
&lt;li&gt;Driver may do elevator sorting (disk scheduling) for multiple requests&lt;/li&gt;
&lt;/ol&gt;
&lt;div class=&quot;graphviz-container&quot; style=&quot;display: flex; justify-content: center; margin: 1.5rem 0; overflow-x: auto;&quot; dir=&quot;auto&quot;&gt;&lt;!--?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?--&gt;

&lt;!-- Generated by graphviz version 15.1.0 (0)
 --&gt;
&lt;!-- Title: block_driver Pages: 1 --&gt;
&lt;svg width=&quot;547pt&quot; height=&quot;86pt&quot; viewBox=&quot;0.00 0.00 547.00 86.00&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; xmlns:xlink=&quot;http://www.w3.org/1999/xlink&quot;&gt;
&lt;g id=&quot;graph0&quot; class=&quot;graph&quot; transform=&quot;scale(1 1) rotate(0) translate(4 81.84)&quot;&gt;
&lt;title&gt;block_driver&lt;/title&gt;
&lt;polygon fill=&quot;white&quot; stroke=&quot;none&quot; points=&quot;-4,4 -4,-81.84 543.08,-81.84 543.08,4 -4,4&quot;&gt;&lt;/polygon&gt;
&lt;!-- OS --&gt;
&lt;g id=&quot;node1&quot; class=&quot;node&quot;&gt;
&lt;title&gt;OS&lt;/title&gt;
&lt;polygon fill=&quot;lightyellow&quot; stroke=&quot;black&quot; points=&quot;100.36,-56.74 0,-56.74 0,-15.14 100.36,-15.14 100.36,-56.74&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;50.18&quot; y=&quot;-40.14&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;OS&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;50.18&quot; y=&quot;-23.34&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;(block request)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- BDriver --&gt;
&lt;g id=&quot;node2&quot; class=&quot;node&quot;&gt;
&lt;title&gt;BDriver&lt;/title&gt;
&lt;polygon fill=&quot;lightgreen&quot; stroke=&quot;black&quot; points=&quot;331.57,-65.14 226.55,-65.14 226.55,-6.74 331.57,-6.74 331.57,-65.14&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;279.06&quot; y=&quot;-48.54&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Block Driver&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;279.06&quot; y=&quot;-31.74&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;translate block#&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;279.06&quot; y=&quot;-14.94&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;to CHS address&lt;/text&gt;
&lt;/g&gt;
&lt;!-- OS&amp;#45;&amp;gt;BDriver --&gt;
&lt;g id=&quot;edge1&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;OS-&gt;BDriver&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M100.69,-35.94C134.22,-35.94 178.82,-35.94 214.9,-35.94&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;214.78,-39.44 224.78,-35.94 214.78,-32.44 214.78,-39.44&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;163.45&quot; y=&quot;-40.14&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;read block 1234&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Disk --&gt;
&lt;g id=&quot;node3&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Disk&lt;/title&gt;
&lt;polygon fill=&quot;lightblue&quot; stroke=&quot;black&quot; points=&quot;539.08,-56.74 442.62,-56.74 442.62,-15.14 539.08,-15.14 539.08,-56.74&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;490.85&quot; y=&quot;-40.14&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Disk&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;490.85&quot; y=&quot;-23.34&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;(block device)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- BDriver&amp;#45;&amp;gt;Disk --&gt;
&lt;g id=&quot;edge2&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;BDriver-&gt;Disk&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M332.02,-41.75C337.93,-42.24 343.88,-42.66 349.57,-42.94 382.88,-44.62 391.31,-44.73 424.62,-42.94 426.66,-42.84 428.74,-42.71 430.84,-42.56&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;430.96,-46.06 440.65,-41.78 430.4,-39.09 430.96,-46.06&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;387.1&quot; y=&quot;-65.24&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;CHS: 2,5,12&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;387.1&quot; y=&quot;-48.44&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;(DMA setup)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Disk&amp;#45;&amp;gt;BDriver --&gt;
&lt;g id=&quot;edge3&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Disk-&gt;BDriver&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; stroke-dasharray=&quot;5 2&quot; d=&quot;M451.87,-14.75C443.17,-10.86 433.77,-7.39 424.62,-5.34 392.06,1.91 382.21,1.52 349.57,-5.34 347.4,-5.8 345.2,-6.33 343.01,-6.93&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;342,-3.57 333.5,-9.89 344.08,-10.26 342,-3.57&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;387.1&quot; y=&quot;-26.34&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;data ready&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;387.1&quot; y=&quot;-9.54&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;(interrupt)&lt;/text&gt;
&lt;/g&gt;
&lt;/g&gt;
&lt;/svg&gt;
&lt;/div&gt;
&lt;h2 id=&quot;key-properties&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Key Properties&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#key-properties&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;Transfers fixed-size blocks (512B, 4KB typical)&lt;/li&gt;
&lt;li&gt;Supports random access (seek to any block)&lt;/li&gt;
&lt;li&gt;Uses buffering/caching heavily (buffers are block-sized)&lt;/li&gt;
&lt;li&gt;Examples: hard disk driver, SSD driver, USB mass storage&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;connections&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Connections&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#connections&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Built from:&lt;/strong&gt; &lt;a href=&quot;../../device-driver&quot; class=&quot;internal alias&quot; data-slug=&quot;device-driver&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Device Driver&lt;/a&gt;, &lt;a href=&quot;../../io-devices&quot; class=&quot;internal alias&quot; data-slug=&quot;io-devices&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;O Devices&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Builds into:&lt;/strong&gt; &lt;a href=&quot;../../disk-structure&quot; class=&quot;internal alias&quot; data-slug=&quot;disk-structure&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Disk Structure&lt;/a&gt;, &lt;a href=&quot;../../disk-scheduling&quot; class=&quot;internal alias&quot; data-slug=&quot;disk-scheduling&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Disk Scheduling&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../character-driver&quot; class=&quot;internal alias&quot; data-slug=&quot;character-driver&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Character Driver&lt;/a&gt;, &lt;a href=&quot;../../dma&quot; class=&quot;internal alias&quot; data-slug=&quot;dma&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;DMA&lt;/a&gt;, &lt;a href=&quot;../../buffering&quot; class=&quot;internal alias&quot; data-slug=&quot;buffering&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Buffering&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Contrasts with:&lt;/strong&gt; &lt;a href=&quot;../../network-driver&quot; class=&quot;internal alias&quot; data-slug=&quot;network-driver&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Network Driver&lt;/a&gt; (packet-based, not block-based)&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;edge-cases--gotchas&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Edge Cases &amp;#x26; Gotchas&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#edge-cases--gotchas&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;Block size must match device’s physical block size (or be properly translated)&lt;/li&gt;
&lt;li&gt;Misaligned block accesses hurt performance on some devices&lt;/li&gt;
&lt;li&gt;Some “block” devices are actually flash-backed and have different characteristics&lt;/li&gt;
&lt;/ul&gt;</content>
  </entry><entry>
    <title>buffering</title>
    <link href="https://animishraa05.github.io/wiki/io/buffering" />
    <link rel="alternate" type="text/markdown" href="https://animishraa05.github.io/wiki/io/buffering.md" />
    <summary>The Problem Devices operate at different speeds (CPU is fast, disk is slow, keyboard is very slow).</summary>
    <published>2026-04-30T00:00:00.000Z</published>
    <updated>2026-04-30T00:00:00.000Z</updated>
    <publishedTime>Apr 30, 2026</publishedTime>
    <updatedTime>Apr 30, 2026</updatedTime>
    <category term="systems" label="systems" />
<category term="io" label="io" />
    <author>
      <name>Animesh Mishra</name>
      <email>animesh.mishra818@gmail.com</email>
    </author>
    <content type="html">&lt;h2 id=&quot;the-problem&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;The Problem&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#the-problem&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;Devices operate at different speeds (CPU is fast, disk is slow, keyboard is very slow). Data transfer between them needs temporary storage to bridge the speed gap.&lt;/p&gt;
&lt;h2 id=&quot;core-idea&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Core Idea&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#core-idea&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;Buffering is the use of temporary storage (in memory) to hold data while it’s being transferred between devices or between a device and an application.&lt;/p&gt;
&lt;h2 id=&quot;how-it-works&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;How It Works&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#how-it-works&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ol dir=&quot;auto&quot;&gt;
&lt;li&gt;Data from slow device stored in buffer (memory)&lt;/li&gt;
&lt;li&gt;Fast device/CPU can read from buffer at its own speed&lt;/li&gt;
&lt;li&gt;Buffer decouples producer and consumer of data&lt;/li&gt;
&lt;li&gt;Can be single buffer, double buffer, or circular buffer&lt;/li&gt;
&lt;/ol&gt;
&lt;div class=&quot;graphviz-container&quot; style=&quot;display: flex; justify-content: center; margin: 1.5rem 0; overflow-x: auto;&quot; dir=&quot;auto&quot;&gt;&lt;!--?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?--&gt;

&lt;!-- Generated by graphviz version 15.1.0 (0)
 --&gt;
&lt;!-- Title: buffer Pages: 1 --&gt;
&lt;svg width=&quot;477pt&quot; height=&quot;50pt&quot; viewBox=&quot;0.00 0.00 477.00 50.00&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; xmlns:xlink=&quot;http://www.w3.org/1999/xlink&quot;&gt;
&lt;g id=&quot;graph0&quot; class=&quot;graph&quot; transform=&quot;scale(1 1) rotate(0) translate(4 45.6)&quot;&gt;
&lt;title&gt;buffer&lt;/title&gt;
&lt;polygon fill=&quot;white&quot; stroke=&quot;none&quot; points=&quot;-4,4 -4,-45.6 473.13,-45.6 473.13,4 -4,4&quot;&gt;&lt;/polygon&gt;
&lt;!-- Slow --&gt;
&lt;g id=&quot;node1&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Slow&lt;/title&gt;
&lt;polygon fill=&quot;lightgray&quot; stroke=&quot;black&quot; points=&quot;107.75,-41.6 0,-41.6 0,0 107.75,0 107.75,-41.6&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;53.88&quot; y=&quot;-25&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Slow Device&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;53.88&quot; y=&quot;-8.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;(disk, keyboard)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Buf --&gt;
&lt;g id=&quot;node2&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Buf&lt;/title&gt;
&lt;polygon fill=&quot;lightyellow&quot; stroke=&quot;black&quot; points=&quot;269.76,-41.6 197.78,-41.6 197.78,0 269.76,0 269.76,-41.6&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;233.77&quot; y=&quot;-25&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Buffer&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;233.77&quot; y=&quot;-8.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;(memory)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Slow&amp;#45;&amp;gt;Buf --&gt;
&lt;g id=&quot;edge1&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Slow-&gt;Buf&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M108.25,-20.8C133.05,-20.8 162.27,-20.8 186.17,-20.8&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;185.92,-24.3 195.92,-20.8 185.92,-17.3 185.92,-24.3&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;152.77&quot; y=&quot;-25&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;fill buffer&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Fast --&gt;
&lt;g id=&quot;node3&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Fast&lt;/title&gt;
&lt;polygon fill=&quot;lightgreen&quot; stroke=&quot;black&quot; points=&quot;469.13,-38.8 355.53,-38.8 355.53,-2.8 469.13,-2.8 469.13,-38.8&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;412.33&quot; y=&quot;-16.6&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Fast Device/CPU&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Buf&amp;#45;&amp;gt;Fast --&gt;
&lt;g id=&quot;edge2&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Buf-&gt;Fast&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M270.08,-20.8C291.2,-20.8 318.73,-20.8 343.88,-20.8&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;343.72,-24.3 353.72,-20.8 343.72,-17.3 343.72,-24.3&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;312.65&quot; y=&quot;-25&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;consume&lt;/text&gt;
&lt;/g&gt;
&lt;/g&gt;
&lt;/svg&gt;
&lt;/div&gt;
&lt;h2 id=&quot;key-properties&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Key Properties&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#key-properties&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;Decouples speed differences between devices&lt;/li&gt;
&lt;li&gt;Can be single, double, or circular buffer&lt;/li&gt;
&lt;li&gt;Block devices use buffer cache (disk blocks)&lt;/li&gt;
&lt;li&gt;Character devices use line buffers or raw mode&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;connections&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Connections&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#connections&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Built from:&lt;/strong&gt; &lt;a href=&quot;../../io-system&quot; class=&quot;internal alias&quot; data-slug=&quot;io-system&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;O System&lt;/a&gt;, &lt;a href=&quot;../../device-independent-io-software&quot; class=&quot;internal alias&quot; data-slug=&quot;device-independent-io-software&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;O Software&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Builds into:&lt;/strong&gt; &lt;a href=&quot;../../io-request-to-hardware&quot; class=&quot;internal alias&quot; data-slug=&quot;io-request-to-hardware&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;O Request to Hardware Operation&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../device-driver&quot; class=&quot;internal alias&quot; data-slug=&quot;device-driver&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Device Driver&lt;/a&gt;, &lt;a href=&quot;../../dma&quot; class=&quot;internal alias&quot; data-slug=&quot;dma&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;DMA&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Contrasts with:&lt;/strong&gt; &lt;a href=&quot;../../no-buffering&quot; class=&quot;internal alias&quot; data-slug=&quot;no-buffering&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;No Buffering&lt;/a&gt; (unbuffered I/O is slow)&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;edge-cases--gotchas&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Edge Cases &amp;#x26; Gotchas&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#edge-cases--gotchas&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;Buffer overflow if consumer too slow&lt;/li&gt;
&lt;li&gt;Buffer too small = frequent I/O operations&lt;/li&gt;
&lt;li&gt;Buffer too large = wasted memory&lt;/li&gt;
&lt;/ul&gt;</content>
  </entry><entry>
    <title>c-look</title>
    <link href="https://animishraa05.github.io/wiki/io/c-look" />
    <link rel="alternate" type="text/markdown" href="https://animishraa05.github.io/wiki/io/c-look.md" />
    <summary>The Problem C-SCAN wastes time on the return jump (no service), and always goes to disk end.</summary>
    <published>2026-04-30T00:00:00.000Z</published>
    <updated>2026-04-30T00:00:00.000Z</updated>
    <publishedTime>Apr 30, 2026</publishedTime>
    <updatedTime>Apr 30, 2026</updatedTime>
    <category term="systems" label="systems" />
<category term="storage" label="storage" />
    <author>
      <name>Animesh Mishra</name>
      <email>animesh.mishra818@gmail.com</email>
    </author>
    <content type="html">&lt;h2 id=&quot;the-problem&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;The Problem&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#the-problem&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;C-SCAN wastes time on the return jump (no service), and always goes to disk end. Can we combine C-SCAN and LOOK?&lt;/p&gt;
&lt;h2 id=&quot;core-idea&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Core Idea&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#core-idea&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;C-LOOK combines C-SCAN (one direction only) with LOOK (stop at last request), giving uniform wait times without unnecessary travel.&lt;/p&gt;
&lt;h2 id=&quot;how-it-works&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;How It Works&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#how-it-works&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ol dir=&quot;auto&quot;&gt;
&lt;li&gt;Move in one direction, service requests&lt;/li&gt;
&lt;li&gt;Stop at last request (don’t go to disk end)&lt;/li&gt;
&lt;li&gt;Jump back to first request&lt;/li&gt;
&lt;li&gt;Continue in same direction (circular)&lt;/li&gt;
&lt;/ol&gt;
&lt;div class=&quot;graphviz-container&quot; style=&quot;display: flex; justify-content: center; margin: 1.5rem 0; overflow-x: auto;&quot; dir=&quot;auto&quot;&gt;&lt;!--?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?--&gt;

&lt;!-- Generated by graphviz version 15.1.0 (0)
 --&gt;
&lt;!-- Title: clook Pages: 1 --&gt;
&lt;svg width=&quot;162pt&quot; height=&quot;301pt&quot; viewBox=&quot;0.00 0.00 162.00 301.00&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; xmlns:xlink=&quot;http://www.w3.org/1999/xlink&quot;&gt;
&lt;g id=&quot;graph0&quot; class=&quot;graph&quot; transform=&quot;scale(1 1) rotate(0) translate(4 297.2)&quot;&gt;
&lt;title&gt;clook&lt;/title&gt;
&lt;polygon fill=&quot;white&quot; stroke=&quot;none&quot; points=&quot;-4,4 -4,-297.2 157.75,-297.2 157.75,4 -4,4&quot;&gt;&lt;/polygon&gt;
&lt;!-- First --&gt;
&lt;g id=&quot;node1&quot; class=&quot;node&quot;&gt;
&lt;title&gt;First&lt;/title&gt;
&lt;polygon fill=&quot;lightgreen&quot; stroke=&quot;black&quot; points=&quot;141.48,-293.2 73.76,-293.2 73.76,-257.2 141.48,-257.2 141.48,-293.2&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;107.62&quot; y=&quot;-271&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;First Req&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Service --&gt;
&lt;g id=&quot;node2&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Service&lt;/title&gt;
&lt;polygon fill=&quot;lightblue&quot; stroke=&quot;black&quot; points=&quot;125.24,-220.2 0,-220.2 0,-184.2 125.24,-184.2 125.24,-220.2&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;62.62&quot; y=&quot;-198&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;→ Service direction&lt;/text&gt;
&lt;/g&gt;
&lt;!-- First&amp;#45;&amp;gt;Service --&gt;
&lt;g id=&quot;edge1&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;First-&gt;Service&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M96.73,-257.01C91.53,-248.82 85.2,-238.82 79.41,-229.68&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;82.53,-228.08 74.22,-221.51 76.62,-231.83 82.53,-228.08&quot;&gt;&lt;/polygon&gt;
&lt;/g&gt;
&lt;!-- Last --&gt;
&lt;g id=&quot;node3&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Last&lt;/title&gt;
&lt;polygon fill=&quot;salmon&quot; stroke=&quot;black&quot; points=&quot;114.75,-147.2 38.49,-147.2 38.49,-105.6 114.75,-105.6 114.75,-147.2&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;76.62&quot; y=&quot;-130.6&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Last Req&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;76.62&quot; y=&quot;-113.8&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;(stop here)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Service&amp;#45;&amp;gt;Last --&gt;
&lt;g id=&quot;edge2&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Service-&gt;Last&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M65.94,-183.71C67.35,-176.27 69.04,-167.35 70.66,-158.83&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;74.07,-159.6 72.5,-149.12 67.2,-158.3 74.07,-159.6&quot;&gt;&lt;/polygon&gt;
&lt;/g&gt;
&lt;!-- Jump --&gt;
&lt;g id=&quot;node4&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Jump&lt;/title&gt;
&lt;polygon fill=&quot;lightgray&quot; stroke=&quot;black&quot; points=&quot;153.75,-36 77.49,-36 77.49,0 153.75,0 153.75,-36&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;115.62&quot; y=&quot;-13.8&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Jump back&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Last&amp;#45;&amp;gt;Jump --&gt;
&lt;g id=&quot;edge3&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Last-&gt;Jump&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M74.79,-105.13C74.26,-90.33 75.28,-70.13 82.48,-54 83.82,-50.99 85.54,-48.08 87.47,-45.31&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;90.12,-47.6 93.76,-37.65 84.71,-43.16 90.12,-47.6&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;111.05&quot; y=&quot;-75&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;no service&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;111.05&quot; y=&quot;-58.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;on return&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Jump&amp;#45;&amp;gt;First --&gt;
&lt;g id=&quot;edge4&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Jump-&gt;First&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M130.58,-36.43C134.26,-41.74 137.7,-47.81 139.62,-54 161.5,-124.59 152.95,-148.61 134.62,-220.2 132.28,-229.34 128.25,-238.73 124,-247.06&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;121.05,-245.16 119.35,-255.62 127.2,-248.51 121.05,-245.16&quot;&gt;&lt;/polygon&gt;
&lt;/g&gt;
&lt;/g&gt;
&lt;/svg&gt;
&lt;/div&gt;
&lt;h2 id=&quot;key-properties&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Key Properties&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#key-properties&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;Uniform wait times (like C-SCAN)&lt;/li&gt;
&lt;li&gt;No unnecessary travel to disk end (like LOOK)&lt;/li&gt;
&lt;li&gt;Most efficient of the SCAN family&lt;/li&gt;
&lt;li&gt;Default in many modern systems&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;connections&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Connections&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#connections&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Built from:&lt;/strong&gt; &lt;a href=&quot;../../disk-scheduling&quot; class=&quot;internal alias&quot; data-slug=&quot;disk-scheduling&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Disk Scheduling&lt;/a&gt;, &lt;a href=&quot;../../c-scan&quot; class=&quot;internal alias&quot; data-slug=&quot;c-scan&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;C-SCAN&lt;/a&gt;, &lt;a href=&quot;../../look-scheduling&quot; class=&quot;internal alias&quot; data-slug=&quot;look-scheduling&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;LOOK&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../scan-scheduling&quot; class=&quot;internal alias&quot; data-slug=&quot;scan-scheduling&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;SCAN&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Contrasts with:&lt;/strong&gt; &lt;a href=&quot;../../c-scan&quot; class=&quot;internal alias&quot; data-slug=&quot;c-scan&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;C-SCAN&lt;/a&gt; (stops at last request vs goes to end)&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;edge-cases--gotchas&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Edge Cases &amp;#x26; Gotchas&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#edge-cases--gotchas&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;Needs to track first and last request&lt;/li&gt;
&lt;li&gt;Most practical for real-world workloads&lt;/li&gt;
&lt;li&gt;Often the default disk scheduler&lt;/li&gt;
&lt;/ul&gt;</content>
  </entry><entry>
    <title>c-scan</title>
    <link href="https://animishraa05.github.io/wiki/io/c-scan" />
    <link rel="alternate" type="text/markdown" href="https://animishraa05.github.io/wiki/io/c-scan.md" />
    <summary>The Problem SCAN has uneven wait times — requests just passed when the arm reverses have to wait a full cycle.</summary>
    <published>2026-04-30T00:00:00.000Z</published>
    <updated>2026-04-30T00:00:00.000Z</updated>
    <publishedTime>Apr 30, 2026</publishedTime>
    <updatedTime>Apr 30, 2026</updatedTime>
    <category term="systems" label="systems" />
<category term="storage" label="storage" />
    <author>
      <name>Animesh Mishra</name>
      <email>animesh.mishra818@gmail.com</email>
    </author>
    <content type="html">&lt;h2 id=&quot;the-problem&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;The Problem&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#the-problem&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;SCAN has uneven wait times — requests just passed when the arm reverses have to wait a full cycle. Can we make wait times more uniform?&lt;/p&gt;
&lt;h2 id=&quot;core-idea&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Core Idea&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#core-idea&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;C-SCAN (Circular SCAN) services requests in one direction only, then jumps back to the beginning without servicing requests on the return trip.&lt;/p&gt;
&lt;h2 id=&quot;how-it-works&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;How It Works&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#how-it-works&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ol dir=&quot;auto&quot;&gt;
&lt;li&gt;Move disk arm in one direction (e.g., inward)&lt;/li&gt;
&lt;li&gt;Service all requests in that direction&lt;/li&gt;
&lt;li&gt;When reaching end, jump back to start&lt;/li&gt;
&lt;li&gt;Continue in same direction (no reverse)&lt;/li&gt;
&lt;li&gt;Circular — never reverses direction&lt;/li&gt;
&lt;/ol&gt;
&lt;div class=&quot;graphviz-container&quot; style=&quot;display: flex; justify-content: center; margin: 1.5rem 0; overflow-x: auto;&quot; dir=&quot;auto&quot;&gt;&lt;!--?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?--&gt;

&lt;!-- Generated by graphviz version 15.1.0 (0)
 --&gt;
&lt;!-- Title: cscan Pages: 1 --&gt;
&lt;svg width=&quot;136pt&quot; height=&quot;290pt&quot; viewBox=&quot;0.00 0.00 136.00 290.00&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; xmlns:xlink=&quot;http://www.w3.org/1999/xlink&quot;&gt;
&lt;g id=&quot;graph0&quot; class=&quot;graph&quot; transform=&quot;scale(1 1) rotate(0) translate(4 286)&quot;&gt;
&lt;title&gt;cscan&lt;/title&gt;
&lt;polygon fill=&quot;white&quot; stroke=&quot;none&quot; points=&quot;-4,4 -4,-286 131.97,-286 131.97,4 -4,4&quot;&gt;&lt;/polygon&gt;
&lt;!-- Start --&gt;
&lt;g id=&quot;node1&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Start&lt;/title&gt;
&lt;polygon fill=&quot;lightgreen&quot; stroke=&quot;black&quot; points=&quot;107.74,-282 53.74,-282 53.74,-246 107.74,-246 107.74,-282&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;80.74&quot; y=&quot;-259.8&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Start&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Service --&gt;
&lt;g id=&quot;node2&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Service&lt;/title&gt;
&lt;polygon fill=&quot;lightblue&quot; stroke=&quot;black&quot; points=&quot;89.47,-209 0,-209 0,-167.4 89.47,-167.4 89.47,-209&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;44.74&quot; y=&quot;-192.4&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;→ Service&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;44.74&quot; y=&quot;-175.6&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;one direction&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Start&amp;#45;&amp;gt;Service --&gt;
&lt;g id=&quot;edge1&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Start-&gt;Service&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M72.2,-245.51C68.45,-237.81 63.93,-228.54 59.64,-219.76&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;62.8,-218.25 55.27,-210.8 56.51,-221.32 62.8,-218.25&quot;&gt;&lt;/polygon&gt;
&lt;/g&gt;
&lt;!-- End --&gt;
&lt;g id=&quot;node3&quot; class=&quot;node&quot;&gt;
&lt;title&gt;End&lt;/title&gt;
&lt;polygon fill=&quot;lightgray&quot; stroke=&quot;black&quot; points=&quot;82.74,-130.4 28.74,-130.4 28.74,-94.4 82.74,-94.4 82.74,-130.4&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;55.74&quot; y=&quot;-108.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;End&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Service&amp;#45;&amp;gt;End --&gt;
&lt;g id=&quot;edge2&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Service-&gt;End&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M47.74,-167.03C48.9,-159.26 50.25,-150.23 51.5,-141.82&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;54.95,-142.44 52.96,-132.04 48.02,-141.41 54.95,-142.44&quot;&gt;&lt;/polygon&gt;
&lt;/g&gt;
&lt;!-- Jump --&gt;
&lt;g id=&quot;node4&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Jump&lt;/title&gt;
&lt;polygon fill=&quot;salmon&quot; stroke=&quot;black&quot; points=&quot;127.97,-41.6 45.5,-41.6 45.5,0 127.97,0 127.97,-41.6&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;86.74&quot; y=&quot;-25&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Jump back&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;86.74&quot; y=&quot;-8.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;(no service)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- End&amp;#45;&amp;gt;Jump --&gt;
&lt;g id=&quot;edge3&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;End-&gt;Jump&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M55.38,-94.13C55.68,-83.83 56.97,-70.64 60.99,-59.6 61.97,-56.92 63.17,-54.26 64.53,-51.64&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;67.41,-53.65 69.54,-43.27 61.4,-50.06 67.41,-53.65&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;82.36&quot; y=&quot;-63.8&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;circular&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Jump&amp;#45;&amp;gt;Start --&gt;
&lt;g id=&quot;edge4&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Jump-&gt;Start&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M97.73,-42.06C100.2,-47.59 102.47,-53.69 103.74,-59.6 117.67,-124.56 110.61,-143.63 98.74,-209 97.16,-217.69 94.49,-226.89 91.68,-235.19&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;88.46,-233.8 88.37,-244.39 95.05,-236.17 88.46,-233.8&quot;&gt;&lt;/polygon&gt;
&lt;/g&gt;
&lt;/g&gt;
&lt;/svg&gt;
&lt;/div&gt;
&lt;h2 id=&quot;key-properties&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Key Properties&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#key-properties&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;More uniform wait times than SCAN&lt;/li&gt;
&lt;li&gt;No reversal = simpler logic&lt;/li&gt;
&lt;li&gt;Wastes time on return jump (no service)&lt;/li&gt;
&lt;li&gt;Better for systems needing predictable latency&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;connections&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Connections&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#connections&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Built from:&lt;/strong&gt; &lt;a href=&quot;../../disk-scheduling&quot; class=&quot;internal alias&quot; data-slug=&quot;disk-scheduling&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Disk Scheduling&lt;/a&gt;, &lt;a href=&quot;../../scan-scheduling&quot; class=&quot;internal alias&quot; data-slug=&quot;scan-scheduling&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;SCAN&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Builds into:&lt;/strong&gt; &lt;a href=&quot;../../look-scheduling&quot; class=&quot;internal alias&quot; data-slug=&quot;look-scheduling&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;LOOK&lt;/a&gt;, &lt;a href=&quot;../../c-look&quot; class=&quot;internal alias&quot; data-slug=&quot;c-look&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;C-LOOK&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../disk-structure&quot; class=&quot;internal alias&quot; data-slug=&quot;disk-structure&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Disk Structure&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Contrasts with:&lt;/strong&gt; &lt;a href=&quot;../../scan-scheduling&quot; class=&quot;internal alias&quot; data-slug=&quot;scan-scheduling&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;SCAN&lt;/a&gt; (one direction vs reverse)&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;edge-cases--gotchas&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Edge Cases &amp;#x26; Gotchas&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#edge-cases--gotchas&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;Return jump wastes time (no requests serviced)&lt;/li&gt;
&lt;li&gt;Still may not be optimal for all workloads&lt;/li&gt;
&lt;li&gt;Good for real-time systems (predictable)&lt;/li&gt;
&lt;/ul&gt;</content>
  </entry><entry>
    <title>character-driver</title>
    <link href="https://animishraa05.github.io/wiki/io/character-driver" />
    <link rel="alternate" type="text/markdown" href="https://animishraa05.github.io/wiki/io/character-driver.md" />
    <summary>The Problem Character devices (keyboard, mouse, serial port) transfer data as a stream of bytes, one at a time, with no random access.</summary>
    <published>2026-04-30T00:00:00.000Z</published>
    <updated>2026-04-30T00:00:00.000Z</updated>
    <publishedTime>Apr 30, 2026</publishedTime>
    <updatedTime>Apr 30, 2026</updatedTime>
    <category term="systems" label="systems" />
<category term="io" label="io" />
    <author>
      <name>Animesh Mishra</name>
      <email>animesh.mishra818@gmail.com</email>
    </author>
    <content type="html">&lt;h2 id=&quot;the-problem&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;The Problem&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#the-problem&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;Character devices (keyboard, mouse, serial port) transfer data as a stream of bytes, one at a time, with no random access. The driver must handle sequential, unbuffered transfers.&lt;/p&gt;
&lt;h2 id=&quot;core-idea&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Core Idea&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#core-idea&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;A character driver handles byte-stream devices, managing sequential data transfer one character/byte at a time, without seeking or block structure.&lt;/p&gt;
&lt;h2 id=&quot;how-it-works&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;How It Works&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#how-it-works&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ol dir=&quot;auto&quot;&gt;
&lt;li&gt;OS sends read/write request for character data&lt;/li&gt;
&lt;li&gt;Driver reads/writes bytes sequentially from device&lt;/li&gt;
&lt;li&gt;Typically uses small buffers (one character or small FIFO)&lt;/li&gt;
&lt;li&gt;Interrupt per character (or small group) is common&lt;/li&gt;
&lt;li&gt;No seeking — data is a sequential stream&lt;/li&gt;
&lt;/ol&gt;
&lt;div class=&quot;graphviz-container&quot; style=&quot;display: flex; justify-content: center; margin: 1.5rem 0; overflow-x: auto;&quot; dir=&quot;auto&quot;&gt;&lt;!--?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?--&gt;

&lt;!-- Generated by graphviz version 15.1.0 (0)
 --&gt;
&lt;!-- Title: char_driver Pages: 1 --&gt;
&lt;svg width=&quot;507pt&quot; height=&quot;73pt&quot; viewBox=&quot;0.00 0.00 507.00 73.00&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; xmlns:xlink=&quot;http://www.w3.org/1999/xlink&quot;&gt;
&lt;g id=&quot;graph0&quot; class=&quot;graph&quot; transform=&quot;scale(1 1) rotate(0) translate(4 69.06)&quot;&gt;
&lt;title&gt;char_driver&lt;/title&gt;
&lt;polygon fill=&quot;white&quot; stroke=&quot;none&quot; points=&quot;-4,4 -4,-69.06 502.96,-69.06 502.96,4 -4,4&quot;&gt;&lt;/polygon&gt;
&lt;!-- OS --&gt;
&lt;g id=&quot;node1&quot; class=&quot;node&quot;&gt;
&lt;title&gt;OS&lt;/title&gt;
&lt;polygon fill=&quot;lightyellow&quot; stroke=&quot;black&quot; points=&quot;73.13,-56.66 0,-56.66 0,-15.06 73.13,-15.06 73.13,-56.66&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;36.56&quot; y=&quot;-40.06&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;OS&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;36.56&quot; y=&quot;-23.26&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;read chars&lt;/text&gt;
&lt;/g&gt;
&lt;!-- CDriver --&gt;
&lt;g id=&quot;node2&quot; class=&quot;node&quot;&gt;
&lt;title&gt;CDriver&lt;/title&gt;
&lt;polygon fill=&quot;lightgreen&quot; stroke=&quot;black&quot; points=&quot;301.21,-65.06 190.77,-65.06 190.77,-6.66 301.21,-6.66 301.21,-65.06&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;245.99&quot; y=&quot;-48.46&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Character Driver&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;245.99&quot; y=&quot;-31.66&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;byte-by-byte&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;245.99&quot; y=&quot;-14.86&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;or small FIFO&lt;/text&gt;
&lt;/g&gt;
&lt;!-- OS&amp;#45;&amp;gt;CDriver --&gt;
&lt;g id=&quot;edge1&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;OS-&gt;CDriver&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M73.22,-35.86C102.28,-35.86 144.1,-35.86 179.19,-35.86&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;178.82,-39.36 188.82,-35.86 178.82,-32.36 178.82,-39.36&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;131.95&quot; y=&quot;-40.06&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;read 100 bytes&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Kbd --&gt;
&lt;g id=&quot;node3&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Kbd&lt;/title&gt;
&lt;polygon fill=&quot;lightblue&quot; stroke=&quot;black&quot; points=&quot;498.96,-56.66 409.51,-56.66 409.51,-15.06 498.96,-15.06 498.96,-56.66&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;454.23&quot; y=&quot;-40.06&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Keyboard&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;454.23&quot; y=&quot;-23.26&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;(char device)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- CDriver&amp;#45;&amp;gt;Kbd --&gt;
&lt;g id=&quot;edge2&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;CDriver-&gt;Kbd&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M301.37,-41.7C307.39,-42.18 313.43,-42.58 319.21,-42.86 351.31,-44.42 359.43,-44.68 391.51,-42.86 393.56,-42.75 395.65,-42.61 397.76,-42.46&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;397.95,-45.95 407.61,-41.61 397.35,-38.98 397.95,-45.95&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;355.36&quot; y=&quot;-48.33&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;get next char&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Kbd&amp;#45;&amp;gt;CDriver --&gt;
&lt;g id=&quot;edge3&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Kbd-&gt;CDriver&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; stroke-dasharray=&quot;5 2&quot; d=&quot;M417.4,-14.67C409.16,-10.78 400.25,-7.31 391.51,-5.26 360.23,2.07 350.7,1.13 319.21,-5.26 316.92,-5.73 314.61,-6.27 312.29,-6.88&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;311.49,-3.46 302.92,-9.68 313.5,-10.17 311.49,-3.46&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;355.36&quot; y=&quot;-26.26&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;keystroke&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;355.36&quot; y=&quot;-9.46&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;(interrupt)&lt;/text&gt;
&lt;/g&gt;
&lt;/g&gt;
&lt;/svg&gt;
&lt;/div&gt;
&lt;h2 id=&quot;key-properties&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Key Properties&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#key-properties&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;Transfers one byte or small buffers at a time&lt;/li&gt;
&lt;li&gt;No seeking — sequential access only&lt;/li&gt;
&lt;li&gt;Examples: keyboard, mouse, serial port, printer&lt;/li&gt;
&lt;li&gt;Often uses interrupts per character (can be high overhead)&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;connections&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Connections&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#connections&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Built from:&lt;/strong&gt; &lt;a href=&quot;../../device-driver&quot; class=&quot;internal alias&quot; data-slug=&quot;device-driver&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Device Driver&lt;/a&gt;, &lt;a href=&quot;../../io-devices&quot; class=&quot;internal alias&quot; data-slug=&quot;io-devices&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;O Devices&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Builds into:&lt;/strong&gt; &lt;a href=&quot;../../io-software-structure&quot; class=&quot;internal alias&quot; data-slug=&quot;io-software-structure&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;O Software Structure&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../block-driver&quot; class=&quot;internal alias&quot; data-slug=&quot;block-driver&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Block Driver&lt;/a&gt;, &lt;a href=&quot;../../interrupt-handler&quot; class=&quot;internal alias&quot; data-slug=&quot;interrupt-handler&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Interrupt Handler&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Contrasts with:&lt;/strong&gt; &lt;a href=&quot;../../block-driver&quot; class=&quot;internal alias&quot; data-slug=&quot;block-driver&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Block Driver&lt;/a&gt; (random access vs sequential)&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;edge-cases--gotchas&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Edge Cases &amp;#x26; Gotchas&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#edge-cases--gotchas&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;High interrupt rate for fast character streams (use FIFO buffers)&lt;/li&gt;
&lt;li&gt;Some character devices support limited “seek” (e.g., tape drives)&lt;/li&gt;
&lt;li&gt;Character devices don’t support memory-mapped I/O typically&lt;/li&gt;
&lt;/ul&gt;</content>
  </entry><entry>
    <title>collision-resolution</title>
    <link href="https://animishraa05.github.io/wiki/io/collision-resolution" />
    <link rel="alternate" type="text/markdown" href="https://animishraa05.github.io/wiki/io/collision-resolution.md" />
    <summary>The Problem Two different keys may hash to the same index (collision). The hash table needs a strategy to store both values at the same index.</summary>
    <published>2026-04-30T00:00:00.000Z</published>
    <updated>2026-04-30T00:00:00.000Z</updated>
    <publishedTime>Apr 30, 2026</publishedTime>
    <updatedTime>Apr 30, 2026</updatedTime>
    <category term="systems" label="systems" />
<category term="data-structures" label="data-structures" />
    <author>
      <name>Animesh Mishra</name>
      <email>animesh.mishra818@gmail.com</email>
    </author>
    <content type="html">&lt;h2 id=&quot;the-problem&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;The Problem&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#the-problem&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;Two different keys may hash to the same index (collision). The hash table needs a strategy to store both values at the same index.&lt;/p&gt;
&lt;h2 id=&quot;core-idea&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Core Idea&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#core-idea&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;Collision resolution techniques handle cases where multiple keys map to the same hash table index, using either chaining (linked lists) or probing (search for next available slot).&lt;/p&gt;
&lt;h2 id=&quot;how-it-works&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;How It Works&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#how-it-works&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;Two main approaches:&lt;/p&gt;
&lt;p dir=&quot;auto&quot;&gt;&lt;strong&gt;1. Separate Chaining&lt;/strong&gt;: Each index has a linked list of all key-value pairs that hashed there
&lt;strong&gt;2. Open Addressing (Probing)&lt;/strong&gt;: Find another empty slot using a probe sequence&lt;/p&gt;
&lt;div class=&quot;graphviz-container&quot; style=&quot;display: flex; justify-content: center; margin: 1.5rem 0; overflow-x: auto;&quot; dir=&quot;auto&quot;&gt;&lt;!--?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?--&gt;

&lt;!-- Generated by graphviz version 15.1.0 (0)
 --&gt;
&lt;!-- Title: collision Pages: 1 --&gt;
&lt;svg width=&quot;349pt&quot; height=&quot;195pt&quot; viewBox=&quot;0.00 0.00 349.00 195.00&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; xmlns:xlink=&quot;http://www.w3.org/1999/xlink&quot;&gt;
&lt;g id=&quot;graph0&quot; class=&quot;graph&quot; transform=&quot;scale(1 1) rotate(0) translate(4 191.2)&quot;&gt;
&lt;title&gt;collision&lt;/title&gt;
&lt;polygon fill=&quot;white&quot; stroke=&quot;none&quot; points=&quot;-4,4 -4,-191.2 344.54,-191.2 344.54,4 -4,4&quot;&gt;&lt;/polygon&gt;
&lt;g id=&quot;clust1&quot; class=&quot;cluster&quot;&gt;
&lt;title&gt;cluster_chain&lt;/title&gt;
&lt;polygon fill=&quot;none&quot; stroke=&quot;black&quot; points=&quot;8,-8 8,-179.2 158,-179.2 158,-8 8,-8&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;83&quot; y=&quot;-162.6&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Separate Chaining&lt;/text&gt;
&lt;/g&gt;
&lt;g id=&quot;clust2&quot; class=&quot;cluster&quot;&gt;
&lt;title&gt;cluster_probe&lt;/title&gt;
&lt;polygon fill=&quot;none&quot; stroke=&quot;black&quot; points=&quot;166,-10.8 166,-179.2 320,-179.2 320,-10.8 166,-10.8&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;243&quot; y=&quot;-162.6&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Linear Probing&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Idx --&gt;
&lt;g id=&quot;node1&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Idx&lt;/title&gt;
&lt;polygon fill=&quot;lightblue&quot; stroke=&quot;black&quot; points=&quot;112.19,-146.4 53.81,-146.4 53.81,-110.4 112.19,-110.4 112.19,-146.4&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;83&quot; y=&quot;-124.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Index 3&lt;/text&gt;
&lt;/g&gt;
&lt;!-- List --&gt;
&lt;g id=&quot;node2&quot; class=&quot;node&quot;&gt;
&lt;title&gt;List&lt;/title&gt;
&lt;polygon fill=&quot;lightgreen&quot; stroke=&quot;black&quot; points=&quot;150.09,-57.6 15.91,-57.6 15.91,-16 150.09,-16 150.09,-57.6&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;83&quot; y=&quot;-41&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Linked List&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;83&quot; y=&quot;-24.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;(Alice, Bob, Charlie)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Idx&amp;#45;&amp;gt;List --&gt;
&lt;g id=&quot;edge1&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Idx-&gt;List&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M83,-110.12C83,-98.56 83,-83 83,-69.28&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;86.5,-69.35 83,-59.35 79.5,-69.35 86.5,-69.35&quot;&gt;&lt;/polygon&gt;
&lt;/g&gt;
&lt;!-- T0 --&gt;
&lt;g id=&quot;node3&quot; class=&quot;node&quot;&gt;
&lt;title&gt;T0&lt;/title&gt;
&lt;polygon fill=&quot;lightyellow&quot; stroke=&quot;black&quot; points=&quot;234.35,-146.4 173.65,-146.4 173.65,-110.4 234.35,-110.4 234.35,-146.4&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;204&quot; y=&quot;-124.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;3: Alice&lt;/text&gt;
&lt;/g&gt;
&lt;!-- T1 --&gt;
&lt;g id=&quot;node4&quot; class=&quot;node&quot;&gt;
&lt;title&gt;T1&lt;/title&gt;
&lt;polygon fill=&quot;lightgreen&quot; stroke=&quot;black&quot; points=&quot;311.85,-54.8 174.15,-54.8 174.15,-18.8 311.85,-18.8 311.85,-54.8&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;243&quot; y=&quot;-32.6&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;4: Bob ← probed here&lt;/text&gt;
&lt;/g&gt;
&lt;!-- T0&amp;#45;&amp;gt;T1 --&gt;
&lt;g id=&quot;edge2&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;T0-&gt;T1&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M211.52,-110.12C217.02,-97.48 224.6,-80.06 230.95,-65.49&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;234.12,-66.98 234.9,-56.41 227.7,-64.18 234.12,-66.98&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;283.19&quot; y=&quot;-79.8&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;collision, probe next&lt;/text&gt;
&lt;/g&gt;
&lt;/g&gt;
&lt;/svg&gt;
&lt;/div&gt;
&lt;h2 id=&quot;key-properties&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Key Properties&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#key-properties&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Separate Chaining&lt;/strong&gt;: Simple, performance degrades with long chains&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Linear Probing&lt;/strong&gt;: Fast when table isn’t full, but causes clustering&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Quadratic Probing&lt;/strong&gt;: Reduces clustering, but may not probe all slots&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Double Hashing&lt;/strong&gt;: Uses second hash function, best open addressing method&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;connections&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Connections&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#connections&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Built from:&lt;/strong&gt; &lt;a href=&quot;../../hashing&quot; class=&quot;internal alias&quot; data-slug=&quot;hashing&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Hashing&lt;/a&gt;, &lt;a href=&quot;../../hash-function&quot; class=&quot;internal alias&quot; data-slug=&quot;hash-function&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Hash Function&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Builds into:&lt;/strong&gt; &lt;a href=&quot;../../separate-chaining&quot; class=&quot;internal alias&quot; data-slug=&quot;separate-chaining&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Separate Chaining&lt;/a&gt;, &lt;a href=&quot;../../linear-probing&quot; class=&quot;internal alias&quot; data-slug=&quot;linear-probing&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Linear Probing&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../double-hashing&quot; class=&quot;internal alias&quot; data-slug=&quot;double-hashing&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Double Hashing&lt;/a&gt;, &lt;a href=&quot;../../quadratic-probing&quot; class=&quot;internal alias&quot; data-slug=&quot;quadratic-probing&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Quadratic Probing&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Contrasts with:&lt;/strong&gt; &lt;a href=&quot;../../hash-function&quot; class=&quot;internal alias&quot; data-slug=&quot;hash-function&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Hash Function&lt;/a&gt; (prevents vs handles collisions)&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;edge-cases--gotchas&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Edge Cases &amp;#x26; Gotchas&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#edge-cases--gotchas&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;Long chains in chaining → degrades to O(n) search&lt;/li&gt;
&lt;li&gt;Clustering in probing → many consecutive occupied slots&lt;/li&gt;
&lt;li&gt;Deletion in open addressing is tricky (can’t just remove, need tombstones)&lt;/li&gt;
&lt;li&gt;Load factor &gt; 0.7 → performance drops sharply&lt;/li&gt;
&lt;/ul&gt;</content>
  </entry><entry>
    <title>counting-semaphore</title>
    <link href="https://animishraa05.github.io/wiki/io/counting-semaphore" />
    <link rel="alternate" type="text/markdown" href="https://animishraa05.github.io/wiki/io/counting-semaphore.md" />
    <summary>The Problem Some resources have multiple identical instances (e.g., 3 printers, 5 buffer slots).</summary>
    <published>2026-04-30T00:00:00.000Z</published>
    <updated>2026-04-30T00:00:00.000Z</updated>
    <publishedTime>Apr 30, 2026</publishedTime>
    <updatedTime>Apr 30, 2026</updatedTime>
    <category term="systems" label="systems" />
<category term="concurrency" label="concurrency" />
    <author>
      <name>Animesh Mishra</name>
      <email>animesh.mishra818@gmail.com</email>
    </author>
    <content type="html">&lt;h2 id=&quot;the-problem&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;The Problem&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#the-problem&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;Some resources have multiple identical instances (e.g., 3 printers, 5 buffer slots). Binary semaphore can’t handle this — we need to track how many instances are available.&lt;/p&gt;
&lt;h2 id=&quot;core-idea&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Core Idea&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#core-idea&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;A counting semaphore can take values 0 to N, where N is the number of available resources in the pool.&lt;/p&gt;
&lt;h2 id=&quot;how-it-works&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;How It Works&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#how-it-works&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ol dir=&quot;auto&quot;&gt;
&lt;li&gt;Initialize semaphore to N (number of available resources)&lt;/li&gt;
&lt;li&gt;Process requests resource: &lt;code class=&quot;notranslate&quot;&gt;wait(S)&lt;/code&gt; → S—&lt;/li&gt;
&lt;li&gt;If S becomes negative, process blocks (no resources available)&lt;/li&gt;
&lt;li&gt;Process releases: &lt;code class=&quot;notranslate&quot;&gt;signal(S)&lt;/code&gt; → S++, wake up a blocked process&lt;/li&gt;
&lt;/ol&gt;
&lt;div class=&quot;graphviz-container&quot; style=&quot;display: flex; justify-content: center; margin: 1.5rem 0; overflow-x: auto;&quot; dir=&quot;auto&quot;&gt;&lt;!--?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?--&gt;

&lt;!-- Generated by graphviz version 15.1.0 (0)
 --&gt;
&lt;!-- Title: counting_sem Pages: 1 --&gt;
&lt;svg width=&quot;282pt&quot; height=&quot;230pt&quot; viewBox=&quot;0.00 0.00 282.00 230.00&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; xmlns:xlink=&quot;http://www.w3.org/1999/xlink&quot;&gt;
&lt;g id=&quot;graph0&quot; class=&quot;graph&quot; transform=&quot;scale(1 1) rotate(0) translate(4 225.6)&quot;&gt;
&lt;title&gt;counting_sem&lt;/title&gt;
&lt;polygon fill=&quot;white&quot; stroke=&quot;none&quot; points=&quot;-4,4 -4,-225.6 277.67,-225.6 277.67,4 -4,4&quot;&gt;&lt;/polygon&gt;
&lt;!-- Pool --&gt;
&lt;g id=&quot;node1&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Pool&lt;/title&gt;
&lt;polygon fill=&quot;lightblue&quot; stroke=&quot;black&quot; points=&quot;102.82,-221.6 0,-221.6 0,-180 102.82,-180 102.82,-221.6&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;51.41&quot; y=&quot;-205&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Resource Pool&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;51.41&quot; y=&quot;-188.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;N = 3 instances&lt;/text&gt;
&lt;/g&gt;
&lt;!-- S --&gt;
&lt;g id=&quot;node2&quot; class=&quot;node&quot;&gt;
&lt;title&gt;S&lt;/title&gt;
&lt;polygon fill=&quot;orange&quot; stroke=&quot;black&quot; points=&quot;273.67,-128.8 161.5,-128.8 161.5,-92.8 273.67,-92.8 273.67,-128.8&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;217.59&quot; y=&quot;-106.6&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Semaphore S = 3&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Pool&amp;#45;&amp;gt;S --&gt;
&lt;g id=&quot;edge1&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Pool-&gt;S&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M90.9,-179.7C115.59,-166.17 147.68,-148.58 173.25,-134.56&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;174.65,-137.78 181.73,-129.91 171.28,-131.64 174.65,-137.78&quot;&gt;&lt;/polygon&gt;
&lt;/g&gt;
&lt;!-- P1 --&gt;
&lt;g id=&quot;node3&quot; class=&quot;node&quot;&gt;
&lt;title&gt;P1&lt;/title&gt;
&lt;polygon fill=&quot;lightgreen&quot; stroke=&quot;black&quot; points=&quot;86.05,-161.6 16.78,-161.6 16.78,-120 86.05,-120 86.05,-161.6&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;51.41&quot; y=&quot;-145&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Process 1&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;51.41&quot; y=&quot;-128.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;wait(S)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- P1&amp;#45;&amp;gt;S --&gt;
&lt;g id=&quot;edge2&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;P1-&gt;S&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M86.43,-134.58C104.82,-131.22 128.19,-126.95 150.04,-122.96&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;150.59,-126.42 159.8,-121.18 149.33,-119.53 150.59,-126.42&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;132.16&quot; y=&quot;-131.8&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;S=2&lt;/text&gt;
&lt;/g&gt;
&lt;!-- P2 --&gt;
&lt;g id=&quot;node4&quot; class=&quot;node&quot;&gt;
&lt;title&gt;P2&lt;/title&gt;
&lt;polygon fill=&quot;lightgreen&quot; stroke=&quot;black&quot; points=&quot;86.05,-101.6 16.78,-101.6 16.78,-60 86.05,-60 86.05,-101.6&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;51.41&quot; y=&quot;-85&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Process 2&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;51.41&quot; y=&quot;-68.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;wait(S)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- P2&amp;#45;&amp;gt;S --&gt;
&lt;g id=&quot;edge3&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;P2-&gt;S&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M86.43,-87.02C104.82,-90.38 128.19,-94.65 150.04,-98.64&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;149.33,-102.07 159.8,-100.42 150.59,-95.18 149.33,-102.07&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;132.16&quot; y=&quot;-100.9&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;S=1&lt;/text&gt;
&lt;/g&gt;
&lt;!-- P3 --&gt;
&lt;g id=&quot;node5&quot; class=&quot;node&quot;&gt;
&lt;title&gt;P3&lt;/title&gt;
&lt;polygon fill=&quot;lightgreen&quot; stroke=&quot;black&quot; points=&quot;86.05,-41.6 16.78,-41.6 16.78,0 86.05,0 86.05,-41.6&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;51.41&quot; y=&quot;-25&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Process 3&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;51.41&quot; y=&quot;-8.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;wait(S)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- P3&amp;#45;&amp;gt;S --&gt;
&lt;g id=&quot;edge4&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;P3-&gt;S&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M86.43,-39.45C111.5,-53.19 145.8,-71.99 172.9,-86.85&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;171.11,-89.86 181.57,-91.6 174.48,-83.73 171.11,-89.86&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;132.16&quot; y=&quot;-72.7&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;S=0&lt;/text&gt;
&lt;/g&gt;
&lt;/g&gt;
&lt;/svg&gt;
&lt;/div&gt;
&lt;h2 id=&quot;key-properties&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Key Properties&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#key-properties&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;Value range: 0 to N (N = resource count)&lt;/li&gt;
&lt;li&gt;Used for resource management (buffer slots, printer pool)&lt;/li&gt;
&lt;li&gt;Negative value = number of blocked processes&lt;/li&gt;
&lt;li&gt;Classic use: producer-consumer bounded buffer&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;connections&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Connections&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#connections&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Built from:&lt;/strong&gt; &lt;a href=&quot;../../semaphore&quot; class=&quot;internal alias&quot; data-slug=&quot;semaphore&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Semaphore&lt;/a&gt;, &lt;a href=&quot;../../producer-consumer&quot; class=&quot;internal alias&quot; data-slug=&quot;producer-consumer&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Producer-Consumer Problem&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Builds into:&lt;/strong&gt; &lt;a href=&quot;../../reader-writer&quot; class=&quot;internal alias&quot; data-slug=&quot;reader-writer&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Reader-Writer Problem&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../binary-semaphore&quot; class=&quot;internal alias&quot; data-slug=&quot;binary-semaphore&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Binary Semaphore&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Contrasts with:&lt;/strong&gt; &lt;a href=&quot;../../mutex&quot; class=&quot;internal alias&quot; data-slug=&quot;mutex&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Mutex&lt;/a&gt; (mutex is just binary semaphore)&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;edge-cases--gotchas&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Edge Cases &amp;#x26; Gotchas&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#edge-cases--gotchas&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;Initializing to wrong N causes resource leaks or errors&lt;/li&gt;
&lt;li&gt;Must ensure signal() is called exactly once per wait()&lt;/li&gt;
&lt;li&gt;Priority inversion can happen with multiple priority levels&lt;/li&gt;
&lt;/ul&gt;</content>
  </entry><entry>
    <title>demand-paging</title>
    <link href="https://animishraa05.github.io/wiki/io/demand-paging" />
    <link rel="alternate" type="text/markdown" href="https://animishraa05.github.io/wiki/io/demand-paging.md" />
    <summary>The Problem Loading an entire process into RAM at startup is wasteful — many pages may never be used.</summary>
    <published>2026-04-30T00:00:00.000Z</published>
    <updated>2026-04-30T00:00:00.000Z</updated>
    <publishedTime>Apr 30, 2026</publishedTime>
    <updatedTime>Apr 30, 2026</updatedTime>
    <category term="systems" label="systems" />
<category term="memory" label="memory" />
    <author>
      <name>Animesh Mishra</name>
      <email>animesh.mishra818@gmail.com</email>
    </author>
    <content type="html">&lt;h2 id=&quot;the-problem&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;The Problem&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#the-problem&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;Loading an entire process into RAM at startup is wasteful — many pages may never be used. We need a way to load pages only when they’re actually needed.&lt;/p&gt;
&lt;h2 id=&quot;core-idea&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Core Idea&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#core-idea&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;Demand paging loads pages from disk only when they are first accessed (on-demand), reducing RAM usage and startup time.&lt;/p&gt;
&lt;h2 id=&quot;how-it-works&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;How It Works&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#how-it-works&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ol dir=&quot;auto&quot;&gt;
&lt;li&gt;Process starts, page table marked with all pages “not present”&lt;/li&gt;
&lt;li&gt;Process runs, accesses first page → page fault&lt;/li&gt;
&lt;li&gt;OS loads that page from disk into RAM&lt;/li&gt;
&lt;li&gt;Subsequent accesses hit RAM (no fault)&lt;/li&gt;
&lt;li&gt;If RAM is full, evicts a page (LRU, FIFO, etc.)&lt;/li&gt;
&lt;/ol&gt;
&lt;div class=&quot;graphviz-container&quot; style=&quot;display: flex; justify-content: center; margin: 1.5rem 0; overflow-x: auto;&quot; dir=&quot;auto&quot;&gt;&lt;!--?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?--&gt;

&lt;!-- Generated by graphviz version 15.1.0 (0)
 --&gt;
&lt;!-- Title: demand Pages: 1 --&gt;
&lt;svg width=&quot;656pt&quot; height=&quot;50pt&quot; viewBox=&quot;0.00 0.00 656.00 50.00&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; xmlns:xlink=&quot;http://www.w3.org/1999/xlink&quot;&gt;
&lt;g id=&quot;graph0&quot; class=&quot;graph&quot; transform=&quot;scale(1 1) rotate(0) translate(4 45.6)&quot;&gt;
&lt;title&gt;demand&lt;/title&gt;
&lt;polygon fill=&quot;white&quot; stroke=&quot;none&quot; points=&quot;-4,4 -4,-45.6 652.49,-45.6 652.49,4 -4,4&quot;&gt;&lt;/polygon&gt;
&lt;!-- Proc --&gt;
&lt;g id=&quot;node1&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Proc&lt;/title&gt;
&lt;polygon fill=&quot;lightyellow&quot; stroke=&quot;black&quot; points=&quot;91.41,-41.6 0,-41.6 0,0 91.41,0 91.41,-41.6&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;45.71&quot; y=&quot;-25&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Process&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;45.71&quot; y=&quot;-8.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;needs page X&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Fault --&gt;
&lt;g id=&quot;node2&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Fault&lt;/title&gt;
&lt;polygon fill=&quot;salmon&quot; stroke=&quot;black&quot; points=&quot;276.77,-41.6 163.17,-41.6 163.17,0 276.77,0 276.77,-41.6&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;219.97&quot; y=&quot;-25&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Page Fault&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;219.97&quot; y=&quot;-8.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;page not in RAM&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Proc&amp;#45;&amp;gt;Fault --&gt;
&lt;g id=&quot;edge1&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Proc-&gt;Fault&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M91.52,-20.8C109.85,-20.8 131.46,-20.8 151.63,-20.8&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;151.46,-24.3 161.46,-20.8 151.46,-17.3 151.46,-24.3&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;127.29&quot; y=&quot;-25&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;access&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Load --&gt;
&lt;g id=&quot;node3&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Load&lt;/title&gt;
&lt;polygon fill=&quot;lightblue&quot; stroke=&quot;black&quot; points=&quot;483.91,-41.6 370.32,-41.6 370.32,0 483.91,0 483.91,-41.6&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;427.12&quot; y=&quot;-25&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;OS loads&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;427.12&quot; y=&quot;-8.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;page X from disk&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Fault&amp;#45;&amp;gt;Load --&gt;
&lt;g id=&quot;edge2&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Fault-&gt;Load&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M277.03,-20.8C302.24,-20.8 332.21,-20.8 358.65,-20.8&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;358.61,-24.3 368.61,-20.8 358.61,-17.3 358.61,-24.3&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;323.55&quot; y=&quot;-25&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;trap to OS&lt;/text&gt;
&lt;/g&gt;
&lt;!-- RAM --&gt;
&lt;g id=&quot;node4&quot; class=&quot;node&quot;&gt;
&lt;title&gt;RAM&lt;/title&gt;
&lt;polygon fill=&quot;lightgreen&quot; stroke=&quot;black&quot; points=&quot;648.49,-41.6 520.91,-41.6 520.91,0 648.49,0 648.49,-41.6&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;584.7&quot; y=&quot;-25&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;RAM&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;584.7&quot; y=&quot;-8.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;page X now present&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Load&amp;#45;&amp;gt;RAM --&gt;
&lt;g id=&quot;edge3&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Load-&gt;RAM&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M484.29,-20.8C492.36,-20.8 500.78,-20.8 509.15,-20.8&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;508.97,-24.3 518.97,-20.8 508.97,-17.3 508.97,-24.3&quot;&gt;&lt;/polygon&gt;
&lt;/g&gt;
&lt;/g&gt;
&lt;/svg&gt;
&lt;/div&gt;
&lt;h2 id=&quot;key-properties&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Key Properties&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#key-properties&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;Lazy loading: pages loaded only when needed&lt;/li&gt;
&lt;li&gt;Reduces initial RAM usage&lt;/li&gt;
&lt;li&gt;First access is slow (disk read), subsequent fast&lt;/li&gt;
&lt;li&gt;Basis for virtual memory systems&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;connections&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Connections&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#connections&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Built from:&lt;/strong&gt; &lt;a href=&quot;../../wiki/io/paging&quot; class=&quot;internal alias&quot; data-slug=&quot;wiki/io/paging&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Paging&lt;/a&gt;, &lt;a href=&quot;../../page-fault&quot; class=&quot;internal alias&quot; data-slug=&quot;page-fault&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Page Fault&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Builds into:&lt;/strong&gt; &lt;a href=&quot;../../virtual-memory&quot; class=&quot;internal alias&quot; data-slug=&quot;virtual-memory&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Virtual Memory&lt;/a&gt;, &lt;a href=&quot;../../wiki/io/thrashing&quot; class=&quot;internal alias&quot; data-slug=&quot;wiki/io/thrashing&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Thrashing&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../swap-space&quot; class=&quot;internal alias&quot; data-slug=&quot;swap-space&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Swap Space&lt;/a&gt;, &lt;a href=&quot;../../page-replacement&quot; class=&quot;internal alias&quot; data-slug=&quot;page-replacement&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Page Replacement&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Contrasts with:&lt;/strong&gt; &lt;a href=&quot;../../prepaging&quot; class=&quot;internal alias&quot; data-slug=&quot;prepaging&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Prepaging&lt;/a&gt; (load pages before needed)&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;edge-cases--gotchas&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Edge Cases &amp;#x26; Gotchas&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#edge-cases--gotchas&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;Too many page faults = thrashing&lt;/li&gt;
&lt;li&gt;Page fault handling overhead (~1ms for disk read)&lt;/li&gt;
&lt;li&gt;Critical processes may need pages locked in RAM (mlock)&lt;/li&gt;
&lt;/ul&gt;</content>
  </entry><entry>
    <title>device-controller</title>
    <link href="https://animishraa05.github.io/wiki/io/device-controller" />
    <link rel="alternate" type="text/markdown" href="https://animishraa05.github.io/wiki/io/device-controller.md" />
    <summary>The Problem The CPU cannot directly manipulate hardware signals (move disk arm, read magnetic flux).</summary>
    <published>2026-04-30T00:00:00.000Z</published>
    <updated>2026-04-30T00:00:00.000Z</updated>
    <publishedTime>Apr 30, 2026</publishedTime>
    <updatedTime>Apr 30, 2026</updatedTime>
    <category term="systems" label="systems" />
<category term="io" label="io" />
    <author>
      <name>Animesh Mishra</name>
      <email>animesh.mishra818@gmail.com</email>
    </author>
    <content type="html">&lt;h2 id=&quot;the-problem&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;The Problem&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#the-problem&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;The CPU cannot directly manipulate hardware signals (move disk arm, read magnetic flux). It needs a hardware intermediary that understands both the CPU’s bus interface and the device’s physical interface.&lt;/p&gt;
&lt;h2 id=&quot;core-idea&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Core Idea&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#core-idea&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;A device controller is a hardware component that interfaces between the system bus and the physical I/O device, containing registers for commands, data, and status, plus local buffers for data transfer.&lt;/p&gt;
&lt;h2 id=&quot;how-it-works&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;How It Works&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#how-it-works&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ol dir=&quot;auto&quot;&gt;
&lt;li&gt;CPU (via driver) writes commands and parameters to controller’s registers&lt;/li&gt;
&lt;li&gt;Controller parses registers to determine operation (read/write/seek)&lt;/li&gt;
&lt;li&gt;Controller executes operation on the physical device&lt;/li&gt;
&lt;li&gt;Data transfers to/from controller’s local buffer&lt;/li&gt;
&lt;li&gt;Controller raises interrupt when operation completes&lt;/li&gt;
&lt;li&gt;CPU reads status register to check success/failure&lt;/li&gt;
&lt;/ol&gt;
&lt;div class=&quot;graphviz-container&quot; style=&quot;display: flex; justify-content: center; margin: 1.5rem 0; overflow-x: auto;&quot; dir=&quot;auto&quot;&gt;&lt;!--?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?--&gt;

&lt;!-- Generated by graphviz version 15.1.0 (0)
 --&gt;
&lt;!-- Title: controller Pages: 1 --&gt;
&lt;svg width=&quot;846pt&quot; height=&quot;168pt&quot; viewBox=&quot;0.00 0.00 846.00 168.00&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; xmlns:xlink=&quot;http://www.w3.org/1999/xlink&quot;&gt;
&lt;g id=&quot;graph0&quot; class=&quot;graph&quot; transform=&quot;scale(1 1) rotate(0) translate(4 163.8)&quot;&gt;
&lt;title&gt;controller&lt;/title&gt;
&lt;polygon fill=&quot;white&quot; stroke=&quot;none&quot; points=&quot;-4,4 -4,-163.8 842.45,-163.8 842.45,4 -4,4&quot;&gt;&lt;/polygon&gt;
&lt;g id=&quot;clust1&quot; class=&quot;cluster&quot;&gt;
&lt;title&gt;cluster_ctrl&lt;/title&gt;
&lt;polygon fill=&quot;none&quot; stroke=&quot;black&quot; points=&quot;406.15,-68.8 406.15,-151.8 830.45,-151.8 830.45,-68.8 406.15,-68.8&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;618.3&quot; y=&quot;-135.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Device Controller&lt;/text&gt;
&lt;/g&gt;
&lt;!-- CPU --&gt;
&lt;g id=&quot;node1&quot; class=&quot;node&quot;&gt;
&lt;title&gt;CPU&lt;/title&gt;
&lt;polygon fill=&quot;lightyellow&quot; stroke=&quot;black&quot; points=&quot;54,-115.8 0,-115.8 0,-79.8 54,-79.8 54,-115.8&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;27&quot; y=&quot;-93.6&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;CPU&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Bus --&gt;
&lt;g id=&quot;node2&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Bus&lt;/title&gt;
&lt;polygon fill=&quot;lightblue&quot; stroke=&quot;black&quot; points=&quot;298.45,-118.6 188.37,-118.6 188.37,-77 298.45,-77 298.45,-118.6&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;243.41&quot; y=&quot;-102&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;System Bus&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;243.41&quot; y=&quot;-85.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;(Data/Addr/Ctrl)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- CPU&amp;#45;&amp;gt;Bus --&gt;
&lt;g id=&quot;edge3&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;CPU-&gt;Bus&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M54.29,-97.8C84.55,-97.8 135.36,-97.8 176.55,-97.8&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;176.38,-101.3 186.38,-97.8 176.38,-94.3 176.38,-101.3&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;121.18&quot; y=&quot;-102&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;writes commands&lt;/text&gt;
&lt;/g&gt;
&lt;!-- CtrlRegs --&gt;
&lt;g id=&quot;node3&quot; class=&quot;node&quot;&gt;
&lt;title&gt;CtrlRegs&lt;/title&gt;
&lt;polygon fill=&quot;lightgrey&quot; stroke=&quot;black&quot; points=&quot;533.57,-118.6 414.15,-118.6 414.15,-77 533.57,-77 533.57,-118.6&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;473.86&quot; y=&quot;-102&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Control Registers&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;473.86&quot; y=&quot;-85.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;(command, status)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Bus&amp;#45;&amp;gt;CtrlRegs --&gt;
&lt;g id=&quot;edge4&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Bus-&gt;CtrlRegs&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M298.84,-97.8C330.02,-97.8 369.49,-97.8 402.95,-97.8&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;402.53,-101.3 412.53,-97.8 402.53,-94.3 402.53,-101.3&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;356.3&quot; y=&quot;-102&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;register writes&lt;/text&gt;
&lt;/g&gt;
&lt;!-- CtrlRegs&amp;#45;&amp;gt;Bus --&gt;
&lt;g id=&quot;edge7&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;CtrlRegs-&gt;Bus&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; stroke-dasharray=&quot;5 2&quot; d=&quot;M413.71,-80.1C407.81,-78.84 401.89,-77.77 396.15,-77 361.04,-72.32 351.52,-72.04 316.45,-77 314.28,-77.31 312.08,-77.67 309.86,-78.06&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;309.3,-74.61 300.22,-80.07 310.72,-81.46 309.3,-74.61&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;356.3&quot; y=&quot;-81.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;interrupt&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Logic --&gt;
&lt;g id=&quot;node5&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Logic&lt;/title&gt;
&lt;polygon fill=&quot;lightgrey&quot; stroke=&quot;black&quot; points=&quot;676.56,-118.6 574.66,-118.6 574.66,-77 676.56,-77 676.56,-118.6&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;625.61&quot; y=&quot;-102&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Control Logic&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;625.61&quot; y=&quot;-85.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;(state machine)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- CtrlRegs&amp;#45;&amp;gt;Logic --&gt;
&lt;g id=&quot;edge1&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;CtrlRegs-&gt;Logic&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M534.04,-97.8C543.58,-97.8 553.46,-97.8 563.05,-97.8&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;563.04,-101.3 573.04,-97.8 563.04,-94.3 563.04,-101.3&quot;&gt;&lt;/polygon&gt;
&lt;/g&gt;
&lt;!-- DataBuf --&gt;
&lt;g id=&quot;node4&quot; class=&quot;node&quot;&gt;
&lt;title&gt;DataBuf&lt;/title&gt;
&lt;polygon fill=&quot;lightgrey&quot; stroke=&quot;black&quot; points=&quot;822.45,-118.6 739.98,-118.6 739.98,-77 822.45,-77 822.45,-118.6&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;781.21&quot; y=&quot;-102&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Data Buffer&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;781.21&quot; y=&quot;-85.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;(local)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Logic&amp;#45;&amp;gt;DataBuf --&gt;
&lt;g id=&quot;edge2&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Logic-&gt;DataBuf&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M676.91,-97.8C693.4,-97.8 711.75,-97.8 728.36,-97.8&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;728.02,-101.3 738.02,-97.8 728.02,-94.3 728.02,-101.3&quot;&gt;&lt;/polygon&gt;
&lt;/g&gt;
&lt;!-- Device --&gt;
&lt;g id=&quot;node6&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Device&lt;/title&gt;
&lt;polygon fill=&quot;lightgray&quot; stroke=&quot;black&quot; points=&quot;680.66,-41.6 570.57,-41.6 570.57,0 680.66,0 680.66,-41.6&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;625.61&quot; y=&quot;-25&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;I/O Device&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;625.61&quot; y=&quot;-8.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;(e.g., Disk, NIC)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Logic&amp;#45;&amp;gt;Device --&gt;
&lt;g id=&quot;edge5&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Logic-&gt;Device&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M625.61,-76.52C625.61,-69.34 625.61,-61.15 625.61,-53.31&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;629.11,-53.35 625.61,-43.35 622.11,-53.35 629.11,-53.35&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;614.21&quot; y=&quot;-55.1&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;physical signals&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Device&amp;#45;&amp;gt;DataBuf --&gt;
&lt;g id=&quot;edge6&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Device-&gt;DataBuf&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; stroke-dasharray=&quot;5 2&quot; d=&quot;M668.99,-42.04C687.66,-51.4 709.75,-62.47 729.3,-72.28&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;727.7,-75.39 738.21,-76.74 730.84,-69.13 727.7,-75.39&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;710.32&quot; y=&quot;-72.66&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;data&lt;/text&gt;
&lt;/g&gt;
&lt;/g&gt;
&lt;/svg&gt;
&lt;/div&gt;
&lt;h2 id=&quot;key-properties&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Key Properties&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#key-properties&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;Contains three types of registers: control, data, and status&lt;/li&gt;
&lt;li&gt;Has local buffer to hold data during transfer&lt;/li&gt;
&lt;li&gt;Can operate asynchronously from CPU (using DMA)&lt;/li&gt;
&lt;li&gt;Sits on the system bus, addressed like memory (memory-mapped I/O)&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;connections&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Connections&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#connections&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Built from:&lt;/strong&gt; &lt;a href=&quot;../../system-bus&quot; class=&quot;internal alias&quot; data-slug=&quot;system-bus&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;System Bus&lt;/a&gt;, &lt;a href=&quot;../../io-system&quot; class=&quot;internal alias&quot; data-slug=&quot;io-system&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;O System&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Builds into:&lt;/strong&gt; &lt;a href=&quot;../../io-request-to-hardware&quot; class=&quot;internal alias&quot; data-slug=&quot;io-request-to-hardware&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;O Request to Hardware Operation&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../device-driver&quot; class=&quot;internal alias&quot; data-slug=&quot;device-driver&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Device Driver&lt;/a&gt;, &lt;a href=&quot;../../dma&quot; class=&quot;internal alias&quot; data-slug=&quot;dma&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;DMA&lt;/a&gt;, &lt;a href=&quot;../../interrupt-handler&quot; class=&quot;internal alias&quot; data-slug=&quot;interrupt-handler&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Interrupt Handler&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Contrasts with:&lt;/strong&gt; &lt;a href=&quot;../../device-driver&quot; class=&quot;internal alias&quot; data-slug=&quot;device-driver&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Device Driver&lt;/a&gt; (software vs hardware)&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;edge-cases--gotchas&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Edge Cases &amp;#x26; Gotchas&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#edge-cases--gotchas&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;Register addresses vary by device — driver must know the correct addresses&lt;/li&gt;
&lt;li&gt;Local buffer size limits transfer size per operation&lt;/li&gt;
&lt;li&gt;Status register must be read before another command is issued&lt;/li&gt;
&lt;li&gt;Some controllers have buggy implementations causing race conditions&lt;/li&gt;
&lt;/ul&gt;</content>
  </entry><entry>
    <title>device-driver</title>
    <link href="https://animishraa05.github.io/wiki/io/device-driver" />
    <link rel="alternate" type="text/markdown" href="https://animishraa05.github.io/wiki/io/device-driver.md" />
    <summary>The Problem Each hardware device has unique control mechanisms, register layouts, and command sets.</summary>
    <published>2026-04-30T00:00:00.000Z</published>
    <updated>2026-04-30T00:00:00.000Z</updated>
    <publishedTime>Apr 30, 2026</publishedTime>
    <updatedTime>Apr 30, 2026</updatedTime>
    <category term="systems" label="systems" />
<category term="io" label="io" />
    <author>
      <name>Animesh Mishra</name>
      <email>animesh.mishra818@gmail.com</email>
    </author>
    <content type="html">&lt;h2 id=&quot;the-problem&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;The Problem&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#the-problem&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;Each hardware device has unique control mechanisms, register layouts, and command sets. The OS cannot contain code for every possible device — it would be enormous and impossible to maintain.&lt;/p&gt;
&lt;h2 id=&quot;core-idea&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Core Idea&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#core-idea&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;A device driver is a software module that translates generic OS I/O commands into device-specific instructions, acting as the intermediary between the OS and hardware.&lt;/p&gt;
&lt;h2 id=&quot;how-it-works&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;How It Works&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#how-it-works&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ol dir=&quot;auto&quot;&gt;
&lt;li&gt;OS sends a generic I/O request (e.g., “read sector 120”) to the driver&lt;/li&gt;
&lt;li&gt;Driver translates this into device-specific commands and register writes&lt;/li&gt;
&lt;li&gt;Driver writes commands to the device controller’s registers&lt;/li&gt;
&lt;li&gt;Driver may set up DMA transfers or prepare for interrupt notification&lt;/li&gt;
&lt;li&gt;On completion, driver processes the interrupt and updates OS state&lt;/li&gt;
&lt;/ol&gt;
&lt;div class=&quot;graphviz-container&quot; style=&quot;display: flex; justify-content: center; margin: 1.5rem 0; overflow-x: auto;&quot; dir=&quot;auto&quot;&gt;&lt;!--?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?--&gt;

&lt;!-- Generated by graphviz version 15.1.0 (0)
 --&gt;
&lt;!-- Title: device_driver Pages: 1 --&gt;
&lt;svg width=&quot;811pt&quot; height=&quot;68pt&quot; viewBox=&quot;0.00 0.00 811.00 68.00&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; xmlns:xlink=&quot;http://www.w3.org/1999/xlink&quot;&gt;
&lt;g id=&quot;graph0&quot; class=&quot;graph&quot; transform=&quot;scale(1 1) rotate(0) translate(4 64.02)&quot;&gt;
&lt;title&gt;device_driver&lt;/title&gt;
&lt;polygon fill=&quot;white&quot; stroke=&quot;none&quot; points=&quot;-4,4 -4,-64.02 806.57,-64.02 806.57,4 -4,4&quot;&gt;&lt;/polygon&gt;
&lt;!-- OS --&gt;
&lt;g id=&quot;node1&quot; class=&quot;node&quot;&gt;
&lt;title&gt;OS&lt;/title&gt;
&lt;polygon fill=&quot;lightyellow&quot; stroke=&quot;black&quot; points=&quot;116.71,-44.42 0,-44.42 0,-8.42 116.71,-8.42 116.71,-44.42&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;58.35&quot; y=&quot;-22.22&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Operating System&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Driver --&gt;
&lt;g id=&quot;node2&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Driver&lt;/title&gt;
&lt;polygon fill=&quot;lightgreen&quot; stroke=&quot;black&quot; points=&quot;348.29,-47.22 252.61,-47.22 252.61,-5.62 348.29,-5.62 348.29,-47.22&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;300.45&quot; y=&quot;-30.62&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Device Driver&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;300.45&quot; y=&quot;-13.82&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;(Software)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- OS&amp;#45;&amp;gt;Driver --&gt;
&lt;g id=&quot;edge1&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;OS-&gt;Driver&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M117.17,-26.42C154.64,-26.42 203.3,-26.42 240.91,-26.42&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;240.69,-29.92 250.69,-26.42 240.69,-22.92 240.69,-29.92&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;184.66&quot; y=&quot;-47.42&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;generic command&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;184.66&quot; y=&quot;-30.62&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;(e.g., read sector)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Driver&amp;#45;&amp;gt;OS --&gt;
&lt;g id=&quot;edge6&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Driver-&gt;OS&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; stroke-dasharray=&quot;5 2&quot; d=&quot;M252.41,-9.46C246.48,-7.88 240.45,-6.53 234.61,-5.62 190.74,1.25 178.71,0.35 134.71,-5.62 132.54,-5.91 130.34,-6.25 128.14,-6.63&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;127.66,-3.15 118.52,-8.51 129.01,-10.02 127.66,-3.15&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;184.66&quot; y=&quot;-9.82&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;completion status&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Regs --&gt;
&lt;g id=&quot;node3&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Regs&lt;/title&gt;
&lt;polygon fill=&quot;orange&quot; stroke=&quot;black&quot; points=&quot;608.66,-47.22 491.97,-47.22 491.97,-5.62 608.66,-5.62 608.66,-47.22&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;550.32&quot; y=&quot;-30.62&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Device Controller&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;550.32&quot; y=&quot;-13.82&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Registers&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Driver&amp;#45;&amp;gt;Regs --&gt;
&lt;g id=&quot;edge2&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Driver-&gt;Regs&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M348.65,-26.42C385.97,-26.42 438.58,-26.42 480.57,-26.42&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;480.32,-29.92 490.32,-26.42 480.32,-22.92 480.32,-29.92&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;420.13&quot; y=&quot;-47.42&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;specific commands&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;420.13&quot; y=&quot;-30.62&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;&amp;#x26; register writes&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Regs&amp;#45;&amp;gt;Driver --&gt;
&lt;g id=&quot;edge5&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Regs-&gt;Driver&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; stroke-dasharray=&quot;5 2&quot; d=&quot;M491.65,-8.81C485.72,-7.51 479.76,-6.4 473.97,-5.62 426.55,0.81 413.57,1.78 366.29,-5.62 364.1,-5.96 361.88,-6.36 359.65,-6.82&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;358.89,-3.4 349.96,-9.11 360.5,-10.21 358.89,-3.4&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;420.13&quot; y=&quot;-9.82&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;interrupt&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Device --&gt;
&lt;g id=&quot;node4&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Device&lt;/title&gt;
&lt;polygon fill=&quot;lightgray&quot; stroke=&quot;black&quot; points=&quot;802.57,-47.22 739.13,-47.22 739.13,-5.62 802.57,-5.62 802.57,-47.22&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;770.85&quot; y=&quot;-30.62&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Physical&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;770.85&quot; y=&quot;-13.82&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Device&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Regs&amp;#45;&amp;gt;Device --&gt;
&lt;g id=&quot;edge3&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Regs-&gt;Device&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M609.02,-26.42C646.23,-26.42 693.8,-26.42 727.53,-26.42&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;727.33,-29.92 737.33,-26.42 727.33,-22.92 727.33,-29.92&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;673.89&quot; y=&quot;-30.62&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;hardware signals&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Device&amp;#45;&amp;gt;Regs --&gt;
&lt;g id=&quot;edge4&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Device-&gt;Regs&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; stroke-dasharray=&quot;5 2&quot; d=&quot;M738.73,-10.96C733.01,-8.74 726.98,-6.81 721.13,-5.62 679.99,2.8 668.26,0.02 626.66,-5.62 624.49,-5.91 622.3,-6.25 620.09,-6.63&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;619.61,-3.15 610.47,-8.51 620.96,-10.02 619.61,-3.15&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;673.89&quot; y=&quot;-9.82&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;status/interrupt&lt;/text&gt;
&lt;/g&gt;
&lt;/g&gt;
&lt;/svg&gt;
&lt;/div&gt;
&lt;h2 id=&quot;key-properties&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Key Properties&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#key-properties&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;Runs in kernel mode with privileged access&lt;/li&gt;
&lt;li&gt;Device-specific but presents uniform interface to OS&lt;/li&gt;
&lt;li&gt;Handles device initialization, error detection, and status reporting&lt;/li&gt;
&lt;li&gt;Four main types: character, block, network, and virtual drivers&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;connections&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Connections&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#connections&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Built from:&lt;/strong&gt; &lt;a href=&quot;../../io-system&quot; class=&quot;internal alias&quot; data-slug=&quot;io-system&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;O System&lt;/a&gt;, &lt;a href=&quot;../../device-controller&quot; class=&quot;internal alias&quot; data-slug=&quot;device-controller&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Device Controller&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Builds into:&lt;/strong&gt; &lt;a href=&quot;../../io-request-to-hardware&quot; class=&quot;internal alias&quot; data-slug=&quot;io-request-to-hardware&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;O Request to Hardware Operation&lt;/a&gt;, &lt;a href=&quot;../../io-software-structure&quot; class=&quot;internal alias&quot; data-slug=&quot;io-software-structure&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;O Software Structure&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../character-driver&quot; class=&quot;internal alias&quot; data-slug=&quot;character-driver&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Character Driver&lt;/a&gt;, &lt;a href=&quot;../../block-driver&quot; class=&quot;internal alias&quot; data-slug=&quot;block-driver&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Block Driver&lt;/a&gt;, &lt;a href=&quot;../../network-driver&quot; class=&quot;internal alias&quot; data-slug=&quot;network-driver&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Network Driver&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Contrasts with:&lt;/strong&gt; &lt;a href=&quot;../../user-level-io-software&quot; class=&quot;internal alias&quot; data-slug=&quot;user-level-io-software&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;O Software&lt;/a&gt; (lives in user space, not kernel)&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;edge-cases--gotchas&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Edge Cases &amp;#x26; Gotchas&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#edge-cases--gotchas&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;A buggy driver can cause kernel panics or system crashes&lt;/li&gt;
&lt;li&gt;Driver must handle concurrent requests properly (reentrant code)&lt;/li&gt;
&lt;li&gt;Missing drivers result in “unknown device” errors&lt;/li&gt;
&lt;li&gt;Driver version must match kernel version exactly&lt;/li&gt;
&lt;/ul&gt;</content>
  </entry><entry>
    <title>device-independent-io-software</title>
    <link href="https://animishraa05.github.io/wiki/io/device-independent-io-software" />
    <link rel="alternate" type="text/markdown" href="https://animishraa05.github.io/wiki/io/device-independent-io-software.md" />
    <summary>The Problem Different devices have different characteristics (block vs character, seekable vs sequential), but applications want a uniform interface.</summary>
    <published>2026-04-30T00:00:00.000Z</published>
    <updated>2026-04-30T00:00:00.000Z</updated>
    <publishedTime>Apr 30, 2026</publishedTime>
    <updatedTime>Apr 30, 2026</updatedTime>
    <category term="systems" label="systems" />
<category term="io" label="io" />
    <author>
      <name>Animesh Mishra</name>
      <email>animesh.mishra818@gmail.com</email>
    </author>
    <content type="html">&lt;h2 id=&quot;the-problem&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;The Problem&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#the-problem&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;Different devices have different characteristics (block vs character, seekable vs sequential), but applications want a uniform interface. The OS needs a layer that handles common I/O concerns regardless of device type.&lt;/p&gt;
&lt;h2 id=&quot;core-idea&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Core Idea&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#core-idea&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;The I/O software layer that provides a uniform interface to user-level software, handling device naming, protection, buffering, and error reporting independent of specific hardware.&lt;/p&gt;
&lt;h2 id=&quot;how-it-works&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;How It Works&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#how-it-works&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ol dir=&quot;auto&quot;&gt;
&lt;li&gt;Receives I/O request from user-level software&lt;/li&gt;
&lt;li&gt;Identifies which device to use based on file/device name&lt;/li&gt;
&lt;li&gt;Manages buffering and caching for efficiency&lt;/li&gt;
&lt;li&gt;Handles device allocation/deallocation (e.g., exclusive printer access)&lt;/li&gt;
&lt;li&gt;Reports errors in a consistent way&lt;/li&gt;
&lt;li&gt;Passes request to the appropriate device driver&lt;/li&gt;
&lt;/ol&gt;
&lt;div class=&quot;graphviz-container&quot; style=&quot;display: flex; justify-content: center; margin: 1.5rem 0; overflow-x: auto;&quot; dir=&quot;auto&quot;&gt;&lt;!--?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?--&gt;

&lt;!-- Generated by graphviz version 15.1.0 (0)
 --&gt;
&lt;!-- Title: dev_indep Pages: 1 --&gt;
&lt;svg width=&quot;209pt&quot; height=&quot;272pt&quot; viewBox=&quot;0.00 0.00 209.00 272.00&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; xmlns:xlink=&quot;http://www.w3.org/1999/xlink&quot;&gt;
&lt;g id=&quot;graph0&quot; class=&quot;graph&quot; transform=&quot;scale(1 1) rotate(0) translate(4 268)&quot;&gt;
&lt;title&gt;dev_indep&lt;/title&gt;
&lt;polygon fill=&quot;white&quot; stroke=&quot;none&quot; points=&quot;-4,4 -4,-268 205.08,-268 205.08,4 -4,4&quot;&gt;&lt;/polygon&gt;
&lt;!-- Upper --&gt;
&lt;g id=&quot;node1&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Upper&lt;/title&gt;
&lt;polygon fill=&quot;lightyellow&quot; stroke=&quot;black&quot; points=&quot;133.38,-264 32.26,-264 32.26,-222.4 133.38,-222.4 133.38,-264&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;82.82&quot; y=&quot;-247.4&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;User-Level I/O&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;82.82&quot; y=&quot;-230.6&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;System Calls&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Indep --&gt;
&lt;g id=&quot;node2&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Indep&lt;/title&gt;
&lt;polygon fill=&quot;lightblue&quot; stroke=&quot;black&quot; points=&quot;165.64,-169.6 0,-169.6 0,-111.2 165.64,-111.2 165.64,-169.6&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;82.82&quot; y=&quot;-153&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Device-Independent Layer&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;82.82&quot; y=&quot;-136.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;buffering, naming,&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;82.82&quot; y=&quot;-119.4&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;error handling, protection&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Upper&amp;#45;&amp;gt;Indep --&gt;
&lt;g id=&quot;edge1&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Upper-&gt;Indep&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M34.89,-221.98C28.35,-217.18 22.52,-211.37 18.54,-204.4 13.18,-195.04 15.39,-186.14 21.47,-178.14&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;23.98,-180.58 28.36,-170.93 18.92,-175.74 23.98,-180.58&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;72.18&quot; y=&quot;-191.8&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;generic I/O request&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Indep&amp;#45;&amp;gt;Upper --&gt;
&lt;g id=&quot;edge3&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Indep-&gt;Upper&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; stroke-dasharray=&quot;5 2&quot; d=&quot;M115.19,-169.89C119.53,-175.31 123.33,-181.28 125.82,-187.6 128.55,-194.55 128.9,-197.6 125.82,-204.4 124.3,-207.75 122.33,-210.92 120.06,-213.9&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;117.66,-211.33 113.54,-221.09 122.85,-216.03 117.66,-211.33&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;164.54&quot; y=&quot;-191.8&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;error/success&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Drivers --&gt;
&lt;g id=&quot;node3&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Drivers&lt;/title&gt;
&lt;polygon fill=&quot;lightgreen&quot; stroke=&quot;black&quot; points=&quot;133.38,-41.6 32.26,-41.6 32.26,0 133.38,0 133.38,-41.6&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;82.82&quot; y=&quot;-25&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Device Drivers&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;82.82&quot; y=&quot;-8.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;(per-device)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Indep&amp;#45;&amp;gt;Drivers --&gt;
&lt;g id=&quot;edge2&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Indep-&gt;Drivers&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M82.82,-110.93C82.82,-93.51 82.82,-71.19 82.82,-53.24&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;86.32,-53.42 82.82,-43.42 79.32,-53.42 86.32,-53.42&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;123.05&quot; y=&quot;-80.6&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;routed to&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;123.05&quot; y=&quot;-63.8&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;specific driver&lt;/text&gt;
&lt;/g&gt;
&lt;/g&gt;
&lt;/svg&gt;
&lt;/div&gt;
&lt;h2 id=&quot;key-properties&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Key Properties&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#key-properties&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;Makes all devices look the same to upper layers&lt;/li&gt;
&lt;li&gt;Handles naming (/dev/sda, COM1, etc.)&lt;/li&gt;
&lt;li&gt;Manages buffer cache for block devices&lt;/li&gt;
&lt;li&gt;Enforces access control (permissions)&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;connections&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Connections&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#connections&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Built from:&lt;/strong&gt; &lt;a href=&quot;../../io-software-structure&quot; class=&quot;internal alias&quot; data-slug=&quot;io-software-structure&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;O Software Structure&lt;/a&gt;, &lt;a href=&quot;../../user-level-io-software&quot; class=&quot;internal alias&quot; data-slug=&quot;user-level-io-software&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;O Software&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Builds into:&lt;/strong&gt; &lt;a href=&quot;../../io-request-to-hardware&quot; class=&quot;internal alias&quot; data-slug=&quot;io-request-to-hardware&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;O Request to Hardware Operation&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../io-system&quot; class=&quot;internal alias&quot; data-slug=&quot;io-system&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;O System&lt;/a&gt;, &lt;a href=&quot;../../device-driver&quot; class=&quot;internal alias&quot; data-slug=&quot;device-driver&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Device Driver&lt;/a&gt;, &lt;a href=&quot;../../buffering&quot; class=&quot;internal alias&quot; data-slug=&quot;buffering&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Buffering&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Contrasts with:&lt;/strong&gt; &lt;a href=&quot;../../interrupt-handler&quot; class=&quot;internal alias&quot; data-slug=&quot;interrupt-handler&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Interrupt Handler&lt;/a&gt; (lower layer, device-specific events)&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;edge-cases--gotchas&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Edge Cases &amp;#x26; Gotchas&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#edge-cases--gotchas&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;Buffer cache size affects performance — too small means frequent disk reads&lt;/li&gt;
&lt;li&gt;Error reporting must be consistent across device types&lt;/li&gt;
&lt;li&gt;Device naming conventions vary by OS (Linux vs Windows)&lt;/li&gt;
&lt;/ul&gt;</content>
  </entry><entry>
    <title>disk-management</title>
    <link href="https://animishraa05.github.io/wiki/io/disk-management" />
    <link rel="alternate" type="text/markdown" href="https://animishraa05.github.io/wiki/io/disk-management.md" />
    <summary>The Problem A raw disk is just a collection of sectors — the OS needs to organize it into usable storage: divide it into partitions, create file systems, and handle errors.</summary>
    <published>2026-04-30T00:00:00.000Z</published>
    <updated>2026-04-30T00:00:00.000Z</updated>
    <publishedTime>Apr 30, 2026</publishedTime>
    <updatedTime>Apr 30, 2026</updatedTime>
    <category term="systems" label="systems" />
<category term="storage" label="storage" />
    <author>
      <name>Animesh Mishra</name>
      <email>animesh.mishra818@gmail.com</email>
    </author>
    <content type="html">&lt;h2 id=&quot;the-problem&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;The Problem&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#the-problem&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;A raw disk is just a collection of sectors — the OS needs to organize it into usable storage: divide it into partitions, create file systems, and handle errors.&lt;/p&gt;
&lt;h2 id=&quot;core-idea&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Core Idea&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#core-idea&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;Disk management encompasses partitioning (dividing disks), formatting (creating file systems), and error handling (bad block management).&lt;/p&gt;
&lt;h2 id=&quot;how-it-works&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;How It Works&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#how-it-works&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ol dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Partitioning&lt;/strong&gt;: Divide disk into logical sections, each can have different file system&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Formatting&lt;/strong&gt;: Create file system structures (superblock, inodes, bitmaps)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Bad Block Management&lt;/strong&gt;: Detect and remap damaged sectors&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Free Space Management&lt;/strong&gt;: Track unused sectors for new allocations&lt;/li&gt;
&lt;/ol&gt;
&lt;div class=&quot;graphviz-container&quot; style=&quot;display: flex; justify-content: center; margin: 1.5rem 0; overflow-x: auto;&quot; dir=&quot;auto&quot;&gt;&lt;!--?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?--&gt;

&lt;!-- Generated by graphviz version 15.1.0 (0)
 --&gt;
&lt;!-- Title: disk_mgmt Pages: 1 --&gt;
&lt;svg width=&quot;148pt&quot; height=&quot;282pt&quot; viewBox=&quot;0.00 0.00 148.00 282.00&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; xmlns:xlink=&quot;http://www.w3.org/1999/xlink&quot;&gt;
&lt;g id=&quot;graph0&quot; class=&quot;graph&quot; transform=&quot;scale(1 1) rotate(0) translate(4 278.4)&quot;&gt;
&lt;title&gt;disk_mgmt&lt;/title&gt;
&lt;polygon fill=&quot;white&quot; stroke=&quot;none&quot; points=&quot;-4,4 -4,-278.4 143.61,-278.4 143.61,4 -4,4&quot;&gt;&lt;/polygon&gt;
&lt;!-- Raw --&gt;
&lt;g id=&quot;node1&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Raw&lt;/title&gt;
&lt;polygon fill=&quot;lightgray&quot; stroke=&quot;black&quot; points=&quot;114.54,-274.4 25.07,-274.4 25.07,-232.8 114.54,-232.8 114.54,-274.4&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;69.8&quot; y=&quot;-257.8&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Raw Disk&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;69.8&quot; y=&quot;-241&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;(sectors 0-N)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Part --&gt;
&lt;g id=&quot;node2&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Part&lt;/title&gt;
&lt;polygon fill=&quot;lightblue&quot; stroke=&quot;black&quot; points=&quot;134.96,-196.8 4.65,-196.8 4.65,-155.2 134.96,-155.2 134.96,-196.8&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;69.8&quot; y=&quot;-180.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Partitioning&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;69.8&quot; y=&quot;-163.4&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;/dev/sda1, /dev/sda2&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Raw&amp;#45;&amp;gt;Part --&gt;
&lt;g id=&quot;edge1&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Raw-&gt;Part&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M69.8,-232.34C69.8,-224.99 69.8,-216.51 69.8,-208.43&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;73.3,-208.57 69.8,-198.57 66.3,-208.57 73.3,-208.57&quot;&gt;&lt;/polygon&gt;
&lt;/g&gt;
&lt;!-- Format --&gt;
&lt;g id=&quot;node3&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Format&lt;/title&gt;
&lt;polygon fill=&quot;lightgreen&quot; stroke=&quot;black&quot; points=&quot;138.86,-119.2 0.75,-119.2 0.75,-77.6 138.86,-77.6 138.86,-119.2&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;69.8&quot; y=&quot;-102.6&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Formatting&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;69.8&quot; y=&quot;-85.8&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;(ext4, NTFS, FAT32)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Part&amp;#45;&amp;gt;Format --&gt;
&lt;g id=&quot;edge2&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Part-&gt;Format&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M69.8,-154.74C69.8,-147.39 69.8,-138.91 69.8,-130.83&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;73.3,-130.97 69.8,-120.97 66.3,-130.97 73.3,-130.97&quot;&gt;&lt;/polygon&gt;
&lt;/g&gt;
&lt;!-- Maint --&gt;
&lt;g id=&quot;node4&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Maint&lt;/title&gt;
&lt;polygon fill=&quot;orange&quot; stroke=&quot;black&quot; points=&quot;139.61,-41.6 0,-41.6 0,0 139.61,0 139.61,-41.6&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;69.8&quot; y=&quot;-25&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Maintenance&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;69.8&quot; y=&quot;-8.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;bad blocks, free space&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Format&amp;#45;&amp;gt;Maint --&gt;
&lt;g id=&quot;edge3&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Format-&gt;Maint&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M69.8,-77.14C69.8,-69.79 69.8,-61.31 69.8,-53.23&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;73.3,-53.37 69.8,-43.37 66.3,-53.37 73.3,-53.37&quot;&gt;&lt;/polygon&gt;
&lt;/g&gt;
&lt;/g&gt;
&lt;/svg&gt;
&lt;/div&gt;
&lt;h2 id=&quot;key-properties&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Key Properties&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#key-properties&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;Partition table types: MBR (old, 2TB limit) vs GPT (modern, no practical limit)&lt;/li&gt;
&lt;li&gt;Formatting writes file system metadata (superblock, inode tables)&lt;/li&gt;
&lt;li&gt;Bad blocks detected at format time or during runtime&lt;/li&gt;
&lt;li&gt;File system choice affects performance and features&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;connections&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Connections&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#connections&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Built from:&lt;/strong&gt; &lt;a href=&quot;../../disk-structure&quot; class=&quot;internal alias&quot; data-slug=&quot;disk-structure&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Disk Structure&lt;/a&gt;, &lt;a href=&quot;../../disk-scheduling&quot; class=&quot;internal alias&quot; data-slug=&quot;disk-scheduling&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Disk Scheduling&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Builds into:&lt;/strong&gt; &lt;a href=&quot;../../swap-space&quot; class=&quot;internal alias&quot; data-slug=&quot;swap-space&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Swap Space&lt;/a&gt;, &lt;a href=&quot;../../raid&quot; class=&quot;internal alias&quot; data-slug=&quot;raid&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;RAID&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../partitioning&quot; class=&quot;internal alias&quot; data-slug=&quot;partitioning&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Partitioning&lt;/a&gt;, &lt;a href=&quot;../../formatting&quot; class=&quot;internal alias&quot; data-slug=&quot;formatting&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Formatting&lt;/a&gt;, &lt;a href=&quot;../../bad-block&quot; class=&quot;internal alias&quot; data-slug=&quot;bad-block&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Bb Block Management&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Contrasts with:&lt;/strong&gt; &lt;a href=&quot;../../io-system&quot; class=&quot;internal alias&quot; data-slug=&quot;io-system&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;O System&lt;/a&gt; (higher-level abstraction)&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;edge-cases--gotchas&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Edge Cases &amp;#x26; Gotchas&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#edge-cases--gotchas&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;Formatting erases all data — always backup first&lt;/li&gt;
&lt;li&gt;Some file systems (ZFS) do their own bad block management&lt;/li&gt;
&lt;li&gt;Partition alignment matters for SSD performance (4K alignment)&lt;/li&gt;
&lt;/ul&gt;</content>
  </entry><entry>
    <title>Disk Scheduling Algorithms — Performance and Trade-offs</title>
    <link href="https://animishraa05.github.io/wiki/io/disk-scheduling-compared" />
    <link rel="alternate" type="text/markdown" href="https://animishraa05.github.io/wiki/io/disk-scheduling-compared.md" />
    <summary>Framing Compare disk scheduling algorithms — FCFS, SSTF, SCAN, C-SCAN, LOOK, and C-LOOK — analyzing seek time reduction, fairness, and practical performance.</summary>
    <published>2026-04-30T00:00:00.000Z</published>
    <updated>2026-04-30T00:00:00.000Z</updated>
    <publishedTime>Apr 30, 2026</publishedTime>
    <updatedTime>Apr 30, 2026</updatedTime>
    <category term="systems" label="systems" />
<category term="storage" label="storage" />
    <author>
      <name>Animesh Mishra</name>
      <email>animesh.mishra818@gmail.com</email>
    </author>
    <content type="html">&lt;h2 id=&quot;framing&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Framing&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#framing&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;Compare disk scheduling algorithms — &lt;strong&gt;FCFS&lt;/strong&gt;, &lt;strong&gt;SSTF&lt;/strong&gt;, &lt;strong&gt;SCAN&lt;/strong&gt;, &lt;strong&gt;C-SCAN&lt;/strong&gt;, &lt;strong&gt;LOOK&lt;/strong&gt;, and &lt;strong&gt;C-LOOK&lt;/strong&gt; — analyzing seek time reduction, fairness, and practical performance.&lt;/p&gt;
&lt;h2 id=&quot;comparison&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Comparison&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#comparison&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Algorithm&lt;/th&gt;
&lt;th&gt;Avg Seek&lt;/th&gt;
&lt;th&gt;Starvation&lt;/th&gt;
&lt;th&gt;Wait Time Uniformity&lt;/th&gt;
&lt;th&gt;Notes&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;FCFS&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Worst&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;td&gt;Poor&lt;/td&gt;
&lt;td&gt;Simple, fair, but slow&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;SSTF&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Better&lt;/td&gt;
&lt;td&gt;Yes (edge tracks)&lt;/td&gt;
&lt;td&gt;Poor&lt;/td&gt;
&lt;td&gt;Greedy, may starve&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;SCAN&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Good&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;td&gt;Medium&lt;/td&gt;
&lt;td&gt;Elevator, reverses at end&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;C-SCAN&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Good&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;td&gt;Better&lt;/td&gt;
&lt;td&gt;One direction only&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;LOOK&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Good&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;td&gt;Medium&lt;/td&gt;
&lt;td&gt;Stops at last request&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;C-LOOK&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Good&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;td&gt;Best&lt;/td&gt;
&lt;td&gt;One direction, stops at last&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;h2 id=&quot;key-insights&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Key Insights&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#key-insights&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ol dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;FCFS is fair but slow&lt;/strong&gt; — no optimization, serves as baseline&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;SSTF minimizes seek&lt;/strong&gt; but can starve requests at disk edges (greedy = not globally optimal)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;SCAN (elevator) eliminates starvation&lt;/strong&gt; by sweeping back and forth, like an elevator serving floors&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;C-SCAN improves uniformity&lt;/strong&gt; — always goes in one direction, jumps back (no service on return)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;LOOK is practical SCAN&lt;/strong&gt; — doesn’t go to physical disk end if no requests there&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;C-LOOK is best practical&lt;/strong&gt; — combines C-SCAN uniformity with LOOK efficiency&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&quot;synthesis&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Synthesis&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#synthesis&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;Modern systems typically use &lt;strong&gt;LOOK or C-LOOK&lt;/strong&gt; (often called “deadline” or “noop” schedulers). The SCAN family beats FCFS and SSTF by eliminating starvation while maintaining good performance. Modern disks also do internal scheduling (NCQ) that may override OS scheduling.&lt;/p&gt;
&lt;h2 id=&quot;connections&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Connections&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#connections&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;a href=&quot;../../disk-scheduling&quot; class=&quot;internal alias&quot; data-slug=&quot;disk-scheduling&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Disk Scheduling&lt;/a&gt; — overview of all algorithms&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;../../fcfs&quot; class=&quot;internal alias&quot; data-slug=&quot;fcfs&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;FCFS&lt;/a&gt; — first come first serve&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;../../sstf&quot; class=&quot;internal alias&quot; data-slug=&quot;sstf&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;SSTF&lt;/a&gt; — shortest seek time first&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;../../scan-scheduling&quot; class=&quot;internal alias&quot; data-slug=&quot;scan-scheduling&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;SCAN&lt;/a&gt; — elevator algorithm&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;../../c-scan&quot; class=&quot;internal alias&quot; data-slug=&quot;c-scan&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;C-SCAN&lt;/a&gt; — circular SCAN&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;../../look-scheduling&quot; class=&quot;internal alias&quot; data-slug=&quot;look-scheduling&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;LOOK&lt;/a&gt; — SCAN variant&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;../../c-look&quot; class=&quot;internal alias&quot; data-slug=&quot;c-look&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;C-LOOK&lt;/a&gt; — C-SCAN variant&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;../../disk-structure&quot; class=&quot;internal alias&quot; data-slug=&quot;disk-structure&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Disk Structure&lt;/a&gt; — why seek time matters&lt;/li&gt;
&lt;/ul&gt;</content>
  </entry><entry>
    <title>disk-scheduling</title>
    <link href="https://animishraa05.github.io/wiki/io/disk-scheduling" />
    <link rel="alternate" type="text/markdown" href="https://animishraa05.github.io/wiki/io/disk-scheduling.md" />
    <summary>The Problem Disk access is slow (milliseconds) compared to CPU/RAM (nanoseconds). The mechanical seek time (moving the disk arm) dominates.</summary>
    <published>2026-04-30T00:00:00.000Z</published>
    <updated>2026-04-30T00:00:00.000Z</updated>
    <publishedTime>Apr 30, 2026</publishedTime>
    <updatedTime>Apr 30, 2026</updatedTime>
    <category term="systems" label="systems" />
<category term="storage" label="storage" />
    <author>
      <name>Animesh Mishra</name>
      <email>animesh.mishra818@gmail.com</email>
    </author>
    <content type="html">&lt;h2 id=&quot;the-problem&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;The Problem&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#the-problem&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;Disk access is slow (milliseconds) compared to CPU/RAM (nanoseconds). The mechanical seek time (moving the disk arm) dominates. With multiple I/O requests, the order of servicing them greatly affects performance.&lt;/p&gt;
&lt;h2 id=&quot;core-idea&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Core Idea&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#core-idea&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;Disk scheduling algorithms decide the order to service pending I/O requests to minimize seek time and improve throughput.&lt;/p&gt;
&lt;h2 id=&quot;how-it-works&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;How It Works&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#how-it-works&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;Common algorithms:&lt;/p&gt;
&lt;ol dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;FCFS&lt;/strong&gt;: Process requests in arrival order (simple, but can be slow)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;SSTF&lt;/strong&gt;: Pick closest request first (minimizes seek, but may starve)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;SCAN (Elevator)&lt;/strong&gt;: Move in one direction, service requests, reverse at end&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;C-SCAN&lt;/strong&gt;: Like SCAN but only services in one direction, jumps back&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;LOOK/C-LOOK&lt;/strong&gt;: Like SCAN/C-SCAN but stops at last request (not end of disk)&lt;/li&gt;
&lt;/ol&gt;
&lt;div class=&quot;graphviz-container&quot; style=&quot;display: flex; justify-content: center; margin: 1.5rem 0; overflow-x: auto;&quot; dir=&quot;auto&quot;&gt;&lt;!--?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?--&gt;

&lt;!-- Generated by graphviz version 15.1.0 (0)
 --&gt;
&lt;!-- Title: disk_sched Pages: 1 --&gt;
&lt;svg width=&quot;492pt&quot; height=&quot;50pt&quot; viewBox=&quot;0.00 0.00 492.00 50.00&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; xmlns:xlink=&quot;http://www.w3.org/1999/xlink&quot;&gt;
&lt;g id=&quot;graph0&quot; class=&quot;graph&quot; transform=&quot;scale(1 1) rotate(0) translate(4 45.6)&quot;&gt;
&lt;title&gt;disk_sched&lt;/title&gt;
&lt;polygon fill=&quot;white&quot; stroke=&quot;none&quot; points=&quot;-4,4 -4,-45.6 487.78,-45.6 487.78,4 -4,4&quot;&gt;&lt;/polygon&gt;
&lt;!-- Queue --&gt;
&lt;g id=&quot;node1&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Queue&lt;/title&gt;
&lt;polygon fill=&quot;lightyellow&quot; stroke=&quot;black&quot; points=&quot;105.02,-41.6 0,-41.6 0,0 105.02,0 105.02,-41.6&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;52.51&quot; y=&quot;-25&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Request Queue&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;52.51&quot; y=&quot;-8.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;(track numbers)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Algo --&gt;
&lt;g id=&quot;node2&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Algo&lt;/title&gt;
&lt;polygon fill=&quot;lightblue&quot; stroke=&quot;black&quot; points=&quot;220.01,-41.6 141.02,-41.6 141.02,0 220.01,0 220.01,-41.6&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;180.51&quot; y=&quot;-25&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Scheduling&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;180.51&quot; y=&quot;-8.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Algorithm&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Queue&amp;#45;&amp;gt;Algo --&gt;
&lt;g id=&quot;edge1&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Queue-&gt;Algo&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M105.49,-20.8C113.41,-20.8 121.58,-20.8 129.46,-20.8&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;129.23,-24.3 139.23,-20.8 129.23,-17.3 129.23,-24.3&quot;&gt;&lt;/polygon&gt;
&lt;/g&gt;
&lt;!-- Order --&gt;
&lt;g id=&quot;node3&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Order&lt;/title&gt;
&lt;polygon fill=&quot;lightgreen&quot; stroke=&quot;black&quot; points=&quot;350.14,-41.6 256.01,-41.6 256.01,0 350.14,0 350.14,-41.6&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;303.07&quot; y=&quot;-25&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Service Order&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;303.07&quot; y=&quot;-8.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;(e.g., SSTF)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Algo&amp;#45;&amp;gt;Order --&gt;
&lt;g id=&quot;edge2&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Algo-&gt;Order&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M220.32,-20.8C228,-20.8 236.2,-20.8 244.35,-20.8&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;244.25,-24.3 254.25,-20.8 244.25,-17.3 244.25,-24.3&quot;&gt;&lt;/polygon&gt;
&lt;/g&gt;
&lt;!-- Disk --&gt;
&lt;g id=&quot;node4&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Disk&lt;/title&gt;
&lt;polygon fill=&quot;orange&quot; stroke=&quot;black&quot; points=&quot;483.78,-41.6 386.14,-41.6 386.14,0 483.78,0 483.78,-41.6&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;434.96&quot; y=&quot;-25&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Disk Arm&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;434.96&quot; y=&quot;-8.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;seeks to tracks&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Order&amp;#45;&amp;gt;Disk --&gt;
&lt;g id=&quot;edge3&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Order-&gt;Disk&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M350.6,-20.8C358.42,-20.8 366.62,-20.8 374.71,-20.8&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;374.5,-24.3 384.5,-20.8 374.5,-17.3 374.5,-24.3&quot;&gt;&lt;/polygon&gt;
&lt;/g&gt;
&lt;/g&gt;
&lt;/svg&gt;
&lt;/div&gt;
&lt;h2 id=&quot;key-properties&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Key Properties&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#key-properties&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;SSTF reduces average seek but can starve distant requests&lt;/li&gt;
&lt;li&gt;SCAN gives uniform wait times (like elevator algorithm)&lt;/li&gt;
&lt;li&gt;C-SCAN provides more uniform wait than SCAN&lt;/li&gt;
&lt;li&gt;LOOK is more efficient (doesn’t go to disk end unnecessarily)&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;connections&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Connections&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#connections&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Built from:&lt;/strong&gt; &lt;a href=&quot;../../disk-structure&quot; class=&quot;internal alias&quot; data-slug=&quot;disk-structure&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Disk Structure&lt;/a&gt;, &lt;a href=&quot;../../io-system&quot; class=&quot;internal alias&quot; data-slug=&quot;io-system&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;O System&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Builds into:&lt;/strong&gt; &lt;a href=&quot;../../disk-management&quot; class=&quot;internal alias&quot; data-slug=&quot;disk-management&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Disk Management&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../fcfs&quot; class=&quot;internal alias&quot; data-slug=&quot;fcfs&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;FCFS&lt;/a&gt;, &lt;a href=&quot;../../sstf&quot; class=&quot;internal alias&quot; data-slug=&quot;sstf&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;SSTF&lt;/a&gt;, &lt;a href=&quot;../../scan-scheduling&quot; class=&quot;internal alias&quot; data-slug=&quot;scan-scheduling&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;SCAN&lt;/a&gt;, &lt;a href=&quot;../../c-scan&quot; class=&quot;internal alias&quot; data-slug=&quot;c-scan&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;C-SCAN&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Contrasts with:&lt;/strong&gt; &lt;a href=&quot;../../swap-space&quot; class=&quot;internal alias&quot; data-slug=&quot;swap-space&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Swap Space&lt;/a&gt; (different disk usage pattern)&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;edge-cases--gotchas&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Edge Cases &amp;#x26; Gotchas&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#edge-cases--gotchas&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;SSTF can cause starvation for requests at disk edges&lt;/li&gt;
&lt;li&gt;Request merging (adjacent sectors) can improve throughput&lt;/li&gt;
&lt;li&gt;Modern disks do their own scheduling (NCQ) — OS scheduling may be ignored&lt;/li&gt;
&lt;/ul&gt;</content>
  </entry><entry>
    <title>disk-structure</title>
    <link href="https://animishraa05.github.io/wiki/io/disk-structure" />
    <link rel="alternate" type="text/markdown" href="https://animishraa05.github.io/wiki/io/disk-structure.md" />
    <summary>The Problem Data on a hard disk isn’t stored as a linear sequence — it’s physically organized on spinning platters with magnetic surfaces.</summary>
    <published>2026-04-30T00:00:00.000Z</published>
    <updated>2026-04-30T00:00:00.000Z</updated>
    <publishedTime>Apr 30, 2026</publishedTime>
    <updatedTime>Apr 30, 2026</updatedTime>
    <category term="systems" label="systems" />
<category term="storage" label="storage" />
    <author>
      <name>Animesh Mishra</name>
      <email>animesh.mishra818@gmail.com</email>
    </author>
    <content type="html">&lt;h2 id=&quot;the-problem&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;The Problem&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#the-problem&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;Data on a hard disk isn’t stored as a linear sequence — it’s physically organized on spinning platters with magnetic surfaces. The OS needs to understand this geometry to efficiently locate and access data.&lt;/p&gt;
&lt;h2 id=&quot;core-idea&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Core Idea&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#core-idea&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;A hard disk consists of platters, tracks, sectors, cylinders, and read/write heads — the physical organization that determines how data is addressed and accessed.&lt;/p&gt;
&lt;h2 id=&quot;how-it-works&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;How It Works&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#how-it-works&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;A hard disk is organized as:&lt;/p&gt;
&lt;ol dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Platters&lt;/strong&gt;: Circular magnetic disks stacked on a spindle&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Tracks&lt;/strong&gt;: Concentric rings on each platter surface&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Sectors&lt;/strong&gt;: Smallest storage unit on a track (typically 512B or 4KB)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Cylinder&lt;/strong&gt;: Set of aligned tracks across all platters&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Read/Write Head&lt;/strong&gt;: Moves across platters to access data&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Disk Arm&lt;/strong&gt;: Moves heads to the correct track&lt;/li&gt;
&lt;/ol&gt;
&lt;div class=&quot;graphviz-container&quot; style=&quot;display: flex; justify-content: center; margin: 1.5rem 0; overflow-x: auto;&quot; dir=&quot;auto&quot;&gt;&lt;!--?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?--&gt;

&lt;!-- Generated by graphviz version 15.1.0 (0)
 --&gt;
&lt;!-- Title: disk Pages: 1 --&gt;
&lt;svg width=&quot;498pt&quot; height=&quot;261pt&quot; viewBox=&quot;0.00 0.00 498.00 261.00&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; xmlns:xlink=&quot;http://www.w3.org/1999/xlink&quot;&gt;
&lt;g id=&quot;graph0&quot; class=&quot;graph&quot; transform=&quot;scale(1 1) rotate(0) translate(4 257.4)&quot;&gt;
&lt;title&gt;disk&lt;/title&gt;
&lt;polygon fill=&quot;white&quot; stroke=&quot;none&quot; points=&quot;-4,4 -4,-257.4 494,-257.4 494,4 -4,4&quot;&gt;&lt;/polygon&gt;
&lt;g id=&quot;clust1&quot; class=&quot;cluster&quot;&gt;
&lt;title&gt;cluster_disk&lt;/title&gt;
&lt;polygon fill=&quot;none&quot; stroke=&quot;black&quot; points=&quot;8,-8 8,-90.4 482,-90.4 482,-8 8,-8&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;245&quot; y=&quot;-73.8&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Hard Disk&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Platter --&gt;
&lt;g id=&quot;node1&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Platter&lt;/title&gt;
&lt;polygon fill=&quot;lightblue&quot; stroke=&quot;black&quot; points=&quot;119.74,-57.6 16.26,-57.6 16.26,-16 119.74,-16 119.74,-57.6&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;68&quot; y=&quot;-41&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Platter&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;68&quot; y=&quot;-24.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;(magnetic disk)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Track --&gt;
&lt;g id=&quot;node2&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Track&lt;/title&gt;
&lt;polygon fill=&quot;lightgreen&quot; stroke=&quot;black&quot; points=&quot;247.84,-57.6 138.16,-57.6 138.16,-16 247.84,-16 247.84,-57.6&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;193&quot; y=&quot;-41&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Track&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;193&quot; y=&quot;-24.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;(concentric ring)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Sector --&gt;
&lt;g id=&quot;node3&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Sector&lt;/title&gt;
&lt;polygon fill=&quot;yellow&quot; stroke=&quot;black&quot; points=&quot;352,-57.6 266,-57.6 266,-16 352,-16 352,-57.6&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;309&quot; y=&quot;-41&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Sector&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;309&quot; y=&quot;-24.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;(512B/4KB)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Cylinder --&gt;
&lt;g id=&quot;node4&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Cylinder&lt;/title&gt;
&lt;polygon fill=&quot;orange&quot; stroke=&quot;black&quot; points=&quot;473.73,-57.6 370.27,-57.6 370.27,-16 473.73,-16 473.73,-57.6&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;422&quot; y=&quot;-41&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Cylinder&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;422&quot; y=&quot;-24.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;(aligned tracks)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Arm --&gt;
&lt;g id=&quot;node5&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Arm&lt;/title&gt;
&lt;polygon fill=&quot;salmon&quot; stroke=&quot;black&quot; points=&quot;241.25,-253.4 144.75,-253.4 144.75,-211.8 241.25,-211.8 241.25,-253.4&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;193&quot; y=&quot;-236.8&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Disk Arm&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;193&quot; y=&quot;-220&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;positions head&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Head --&gt;
&lt;g id=&quot;node6&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Head&lt;/title&gt;
&lt;polygon fill=&quot;lightyellow&quot; stroke=&quot;black&quot; points=&quot;249.78,-174.8 136.22,-174.8 136.22,-133.2 249.78,-133.2 249.78,-174.8&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;193&quot; y=&quot;-158.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Read/Write Head&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;193&quot; y=&quot;-141.4&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;reads/writes&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Arm&amp;#45;&amp;gt;Head --&gt;
&lt;g id=&quot;edge1&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Arm-&gt;Head&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M193,-211.47C193,-203.88 193,-195.05 193,-186.66&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;196.5,-186.77 193,-176.77 189.5,-186.77 196.5,-186.77&quot;&gt;&lt;/polygon&gt;
&lt;/g&gt;
&lt;!-- Head&amp;#45;&amp;gt;Track --&gt;
&lt;g id=&quot;edge2&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Head-&gt;Track&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; stroke-dasharray=&quot;5 2&quot; d=&quot;M193,-132.93C193,-115.45 193,-89.79 193,-69.52&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;196.5,-69.54 193,-59.54 189.5,-69.54 196.5,-69.54&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;210.88&quot; y=&quot;-102.6&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;access&lt;/text&gt;
&lt;/g&gt;
&lt;/g&gt;
&lt;/svg&gt;
&lt;/div&gt;
&lt;h2 id=&quot;key-properties&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Key Properties&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#key-properties&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;Data addressed by CHS: Cylinder, Head, Sector&lt;/li&gt;
&lt;li&gt;Access time = seek time + rotational delay + transfer time&lt;/li&gt;
&lt;li&gt;Tracks are numbered from outer (0) to inner&lt;/li&gt;
&lt;li&gt;Multiple platters increase capacity without increasing form factor&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;connections&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Connections&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#connections&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Built from:&lt;/strong&gt; &lt;a href=&quot;../../io-devices&quot; class=&quot;internal alias&quot; data-slug=&quot;io-devices&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;O Devices&lt;/a&gt;, &lt;a href=&quot;../../block-driver&quot; class=&quot;internal alias&quot; data-slug=&quot;block-driver&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Block Driver&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Builds into:&lt;/strong&gt; &lt;a href=&quot;../../disk-scheduling&quot; class=&quot;internal alias&quot; data-slug=&quot;disk-scheduling&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Disk Scheduling&lt;/a&gt;, &lt;a href=&quot;../../disk-management&quot; class=&quot;internal alias&quot; data-slug=&quot;disk-management&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Disk Management&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../cylinder&quot; class=&quot;internal alias&quot; data-slug=&quot;cylinder&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Cylinder&lt;/a&gt;, &lt;a href=&quot;../../track&quot; class=&quot;internal alias&quot; data-slug=&quot;track&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Track&lt;/a&gt;, &lt;a href=&quot;../../sector&quot; class=&quot;internal alias&quot; data-slug=&quot;sector&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Sector&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Contrasts with:&lt;/strong&gt; &lt;a href=&quot;../../ssd&quot; class=&quot;internal alias&quot; data-slug=&quot;ssd&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;SSD&lt;/a&gt; (no moving parts, different structure)&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;edge-cases--gotchas&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Edge Cases &amp;#x26; Gotchas&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#edge-cases--gotchas&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;Sectors aren’t always 512B — modern disks use 4KB physical sectors&lt;/li&gt;
&lt;li&gt;Zone bit recording: outer tracks have more sectors than inner tracks&lt;/li&gt;
&lt;li&gt;Bad sectors must be remapped (handled by disk firmware)&lt;/li&gt;
&lt;/ul&gt;</content>
  </entry><entry>
    <title>dma</title>
    <link href="https://animishraa05.github.io/wiki/io/dma" />
    <link rel="alternate" type="text/markdown" href="https://animishraa05.github.io/wiki/io/dma.md" />
    <summary>The Problem In normal I/O, the CPU must transfer each byte/word between device and memory.</summary>
    <published>2026-04-30T00:00:00.000Z</published>
    <updated>2026-04-30T00:00:00.000Z</updated>
    <publishedTime>Apr 30, 2026</publishedTime>
    <updatedTime>Apr 30, 2026</updatedTime>
    <category term="systems" label="systems" />
<category term="io" label="io" />
    <author>
      <name>Animesh Mishra</name>
      <email>animesh.mishra818@gmail.com</email>
    </author>
    <content type="html">&lt;h2 id=&quot;the-problem&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;The Problem&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#the-problem&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;In normal I/O, the CPU must transfer each byte/word between device and memory. For large transfers (disk reads, network packets), this wastes CPU cycles on simple copy operations.&lt;/p&gt;
&lt;h2 id=&quot;core-idea&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Core Idea&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#core-idea&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;DMA allows I/O devices to transfer data directly to/from memory without CPU intervention, freeing the CPU for other tasks during data transfer.&lt;/p&gt;
&lt;h2 id=&quot;how-it-works&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;How It Works&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#how-it-works&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ol dir=&quot;auto&quot;&gt;
&lt;li&gt;CPU programs the DMA controller: memory address, transfer size, direction (read/write)&lt;/li&gt;
&lt;li&gt;DMA controller takes control of the system bus&lt;/li&gt;
&lt;li&gt;Device transfers data directly to/from memory via DMA&lt;/li&gt;
&lt;li&gt;DMA controller increments address and decrements count for each transfer&lt;/li&gt;
&lt;li&gt;When transfer completes, DMA raises an interrupt to notify CPU&lt;/li&gt;
&lt;/ol&gt;
&lt;div class=&quot;graphviz-container&quot; style=&quot;display: flex; justify-content: center; margin: 1.5rem 0; overflow-x: auto;&quot; dir=&quot;auto&quot;&gt;&lt;!--?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?--&gt;

&lt;!-- Generated by graphviz version 15.1.0 (0)
 --&gt;
&lt;!-- Title: dma Pages: 1 --&gt;
&lt;svg width=&quot;228pt&quot; height=&quot;255pt&quot; viewBox=&quot;0.00 0.00 228.00 255.00&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; xmlns:xlink=&quot;http://www.w3.org/1999/xlink&quot;&gt;
&lt;g id=&quot;graph0&quot; class=&quot;graph&quot; transform=&quot;scale(1 1) rotate(0) translate(4 251.2)&quot;&gt;
&lt;title&gt;dma&lt;/title&gt;
&lt;polygon fill=&quot;white&quot; stroke=&quot;none&quot; points=&quot;-4,4 -4,-251.2 223.91,-251.2 223.91,4 -4,4&quot;&gt;&lt;/polygon&gt;
&lt;!-- CPU --&gt;
&lt;g id=&quot;node1&quot; class=&quot;node&quot;&gt;
&lt;title&gt;CPU&lt;/title&gt;
&lt;polygon fill=&quot;lightyellow&quot; stroke=&quot;black&quot; points=&quot;154.16,-247.2 49.11,-247.2 49.11,-205.6 154.16,-205.6 154.16,-247.2&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;101.63&quot; y=&quot;-230.6&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;CPU&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;101.63&quot; y=&quot;-213.8&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;programs DMA&lt;/text&gt;
&lt;/g&gt;
&lt;!-- DMAC --&gt;
&lt;g id=&quot;node2&quot; class=&quot;node&quot;&gt;
&lt;title&gt;DMAC&lt;/title&gt;
&lt;polygon fill=&quot;orange&quot; stroke=&quot;black&quot; points=&quot;178.06,-136 25.21,-136 25.21,-94.4 178.06,-94.4 178.06,-136&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;101.63&quot; y=&quot;-119.4&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;DMA Controller&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;101.63&quot; y=&quot;-102.6&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;address, count, direction&lt;/text&gt;
&lt;/g&gt;
&lt;!-- CPU&amp;#45;&amp;gt;DMAC --&gt;
&lt;g id=&quot;edge1&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;CPU-&gt;DMAC&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M65.59,-205.17C59.76,-200.22 54.53,-194.36 51.15,-187.6 44.47,-174.25 44.47,-167.35 51.15,-154 52.84,-150.62 55,-147.47 57.45,-144.54&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;59.91,-147.04 64.52,-137.5 54.97,-142.08 59.91,-147.04&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;91.39&quot; y=&quot;-166.6&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;setup registers&lt;/text&gt;
&lt;/g&gt;
&lt;!-- DMAC&amp;#45;&amp;gt;CPU --&gt;
&lt;g id=&quot;edge4&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;DMAC-&gt;CPU&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;green&quot; stroke-dasharray=&quot;5 2&quot; d=&quot;M121.55,-136.26C125.67,-141.61 129.43,-147.67 131.63,-154 136.55,-168.1 136.55,-173.5 131.63,-187.6 130.63,-190.47 129.31,-193.28 127.79,-196&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;green&quot; stroke=&quot;green&quot; points=&quot;125.03,-193.82 122.39,-204.08 130.85,-197.71 125.03,-193.82&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;159.42&quot; y=&quot;-175&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;interrupt&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;159.42&quot; y=&quot;-158.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;done&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Mem --&gt;
&lt;g id=&quot;node3&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Mem&lt;/title&gt;
&lt;polygon fill=&quot;lightblue&quot; stroke=&quot;black&quot; points=&quot;97.27,-41.6 0,-41.6 0,0 97.27,0 97.27,-41.6&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;48.63&quot; y=&quot;-25&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Main Memory&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;48.63&quot; y=&quot;-8.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;(buffer)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- DMAC&amp;#45;&amp;gt;Mem --&gt;
&lt;g id=&quot;edge2&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;DMAC-&gt;Mem&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;red&quot; d=&quot;M70.46,-94.22C64.63,-89.09 59.22,-83.11 55.51,-76.4 51.63,-69.38 49.56,-61.09 48.52,-53.11&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;red&quot; stroke=&quot;red&quot; points=&quot;52.03,-53.06 47.77,-43.36 45.05,-53.6 52.03,-53.06&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;94.57&quot; y=&quot;-63.8&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;direct transfer&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Device --&gt;
&lt;g id=&quot;node4&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Device&lt;/title&gt;
&lt;polygon fill=&quot;lightgray&quot; stroke=&quot;black&quot; points=&quot;195.52,-41.6 115.75,-41.6 115.75,0 195.52,0 195.52,-41.6&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;155.63&quot; y=&quot;-25&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;I/O Device&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;155.63&quot; y=&quot;-8.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;(disk, NIC)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- DMAC&amp;#45;&amp;gt;Device --&gt;
&lt;g id=&quot;edge3&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;DMAC-&gt;Device&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;red&quot; d=&quot;M120.84,-93.92C125.4,-88.49 129.99,-82.44 133.63,-76.4 138.1,-69 142.01,-60.53 145.25,-52.51&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;red&quot; stroke=&quot;red&quot; points=&quot;148.43,-53.99 148.71,-43.4 141.89,-51.51 148.43,-53.99&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;180.85&quot; y=&quot;-63.8&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;direct transfer&lt;/text&gt;
&lt;/g&gt;
&lt;/g&gt;
&lt;/svg&gt;
&lt;/div&gt;
&lt;h2 id=&quot;key-properties&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Key Properties&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#key-properties&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;Transfers data at memory bus speeds (very fast)&lt;/li&gt;
&lt;li&gt;CPU is free during transfer (can run other processes)&lt;/li&gt;
&lt;li&gt;Requires DMA controller hardware (additional cost)&lt;/li&gt;
&lt;li&gt;Best for high-speed, large block transfers&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;connections&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Connections&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#connections&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Built from:&lt;/strong&gt; &lt;a href=&quot;../../io-system&quot; class=&quot;internal alias&quot; data-slug=&quot;io-system&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;O System&lt;/a&gt;, &lt;a href=&quot;../../system-bus&quot; class=&quot;internal alias&quot; data-slug=&quot;system-bus&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;System Bus&lt;/a&gt;, &lt;a href=&quot;../../device-controller&quot; class=&quot;internal alias&quot; data-slug=&quot;device-controller&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Device Controller&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Builds into:&lt;/strong&gt; &lt;a href=&quot;../../io-request-to-hardware&quot; class=&quot;internal alias&quot; data-slug=&quot;io-request-to-hardware&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;O Request to Hardware Operation&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../polling&quot; class=&quot;internal alias&quot; data-slug=&quot;polling&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Polling&lt;/a&gt;, &lt;a href=&quot;../../interrupt-handler&quot; class=&quot;internal alias&quot; data-slug=&quot;interrupt-handler&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Interrupt Handler&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Contrasts with:&lt;/strong&gt; &lt;a href=&quot;../../user-level-io-software&quot; class=&quot;internal alias&quot; data-slug=&quot;user-level-io-software&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;O Software&lt;/a&gt; (CPU still involved in non-DMA I/O)&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;edge-cases--gotchas&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Edge Cases &amp;#x26; Gotchas&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#edge-cases--gotchas&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;DMA and CPU both need system bus — bus arbitration required&lt;/li&gt;
&lt;li&gt;Wrong DMA setup (bad address/size) can corrupt memory&lt;/li&gt;
&lt;li&gt;Some systems have limited DMA channels (resource contention)&lt;/li&gt;
&lt;li&gt;Cache coherency issues — CPU cache may not see DMA-written data&lt;/li&gt;
&lt;/ul&gt;</content>
  </entry><entry>
    <title>double-hashing</title>
    <link href="https://animishraa05.github.io/wiki/io/double-hashing" />
    <link rel="alternate" type="text/markdown" href="https://animishraa05.github.io/wiki/io/double-hashing.md" />
    <summary>The Problem Quadratic probing still has secondary clustering (keys with same initial hash follow same probe sequence).</summary>
    <published>2026-04-30T00:00:00.000Z</published>
    <updated>2026-04-30T00:00:00.000Z</updated>
    <publishedTime>Apr 30, 2026</publishedTime>
    <updatedTime>Apr 30, 2026</updatedTime>
    <category term="systems" label="systems" />
<category term="data-structures" label="data-structures" />
    <author>
      <name>Animesh Mishra</name>
      <email>animesh.mishra818@gmail.com</email>
    </author>
    <content type="html">&lt;h2 id=&quot;the-problem&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;The Problem&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#the-problem&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;Quadratic probing still has secondary clustering (keys with same initial hash follow same probe sequence). We need a way to give each key a unique probe sequence.&lt;/p&gt;
&lt;h2 id=&quot;core-idea&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Core Idea&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#core-idea&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;Double hashing uses two hash functions: the second hash determines the step size for probing, giving each key a unique probe sequence.&lt;/p&gt;
&lt;h2 id=&quot;how-it-works&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;How It Works&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#how-it-works&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ol dir=&quot;auto&quot;&gt;
&lt;li&gt;Compute h₁(k) = initial position&lt;/li&gt;
&lt;li&gt;Compute h₂(k) = step size (must be non-zero)&lt;/li&gt;
&lt;li&gt;Probe sequence: h₁(k), h₁(k)+h₂(k), h₁(k)+2h₂(k), …&lt;/li&gt;
&lt;li&gt;Each key has different step size → different probe sequence&lt;/li&gt;
&lt;/ol&gt;
&lt;div class=&quot;graphviz-container&quot; style=&quot;display: flex; justify-content: center; margin: 1.5rem 0; overflow-x: auto;&quot; dir=&quot;auto&quot;&gt;&lt;!--?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?--&gt;

&lt;!-- Generated by graphviz version 15.1.0 (0)
 --&gt;
&lt;!-- Title: doublehash Pages: 1 --&gt;
&lt;svg width=&quot;170pt&quot; height=&quot;206pt&quot; viewBox=&quot;0.00 0.00 170.00 206.00&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; xmlns:xlink=&quot;http://www.w3.org/1999/xlink&quot;&gt;
&lt;g id=&quot;graph0&quot; class=&quot;graph&quot; transform=&quot;scale(1 1) rotate(0) translate(4 201.8)&quot;&gt;
&lt;title&gt;doublehash&lt;/title&gt;
&lt;polygon fill=&quot;white&quot; stroke=&quot;none&quot; points=&quot;-4,4 -4,-201.8 165.72,-201.8 165.72,4 -4,4&quot;&gt;&lt;/polygon&gt;
&lt;!-- K --&gt;
&lt;g id=&quot;node1&quot; class=&quot;node&quot;&gt;
&lt;title&gt;K&lt;/title&gt;
&lt;polygon fill=&quot;lightyellow&quot; stroke=&quot;black&quot; points=&quot;106.86,-197.8 52.86,-197.8 52.86,-161.8 106.86,-161.8 106.86,-197.8&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;79.86&quot; y=&quot;-175.6&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Key k&lt;/text&gt;
&lt;/g&gt;
&lt;!-- H1 --&gt;
&lt;g id=&quot;node2&quot; class=&quot;node&quot;&gt;
&lt;title&gt;H1&lt;/title&gt;
&lt;polygon fill=&quot;lightblue&quot; stroke=&quot;black&quot; points=&quot;71.72,-124.8 0,-124.8 0,-88.8 71.72,-88.8 71.72,-124.8&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;35.86&quot; y=&quot;-102.6&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;h₁(k) = 3&lt;/text&gt;
&lt;/g&gt;
&lt;!-- K&amp;#45;&amp;gt;H1 --&gt;
&lt;g id=&quot;edge1&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;K-&gt;H1&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M69.21,-161.61C64.18,-153.5 58.07,-143.64 52.45,-134.58&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;55.45,-132.77 47.21,-126.12 49.5,-136.46 55.45,-132.77&quot;&gt;&lt;/polygon&gt;
&lt;/g&gt;
&lt;!-- H2 --&gt;
&lt;g id=&quot;node3&quot; class=&quot;node&quot;&gt;
&lt;title&gt;H2&lt;/title&gt;
&lt;polygon fill=&quot;orange&quot; stroke=&quot;black&quot; points=&quot;161.72,-124.8 90,-124.8 90,-88.8 161.72,-88.8 161.72,-124.8&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;125.86&quot; y=&quot;-102.6&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;h₂(k) = 5&lt;/text&gt;
&lt;/g&gt;
&lt;!-- K&amp;#45;&amp;gt;H2 --&gt;
&lt;g id=&quot;edge2&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;K-&gt;H2&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M91,-161.61C96.31,-153.42 102.78,-143.42 108.7,-134.28&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;111.5,-136.39 114,-126.1 105.63,-132.59 111.5,-136.39&quot;&gt;&lt;/polygon&gt;
&lt;/g&gt;
&lt;!-- Seq --&gt;
&lt;g id=&quot;node4&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Seq&lt;/title&gt;
&lt;polygon fill=&quot;lightgreen&quot; stroke=&quot;black&quot; points=&quot;144.64,-36 15.08,-36 15.08,0 144.64,0 144.64,-36&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;79.86&quot; y=&quot;-13.8&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Probe: 3, 8, 13, 18...&lt;/text&gt;
&lt;/g&gt;
&lt;!-- H1&amp;#45;&amp;gt;Seq --&gt;
&lt;g id=&quot;edge3&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;H1-&gt;Seq&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M44.55,-88.65C50.66,-76.6 58.96,-60.23 65.98,-46.39&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;68.95,-48.26 70.35,-37.76 62.71,-45.1 68.95,-48.26&quot;&gt;&lt;/polygon&gt;
&lt;/g&gt;
&lt;!-- H2&amp;#45;&amp;gt;Seq --&gt;
&lt;g id=&quot;edge4&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;H2-&gt;Seq&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M116.77,-88.65C110.39,-76.6 101.71,-60.23 94.38,-46.39&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;97.57,-44.94 89.8,-37.75 91.39,-48.22 97.57,-44.94&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;130.89&quot; y=&quot;-58.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;step size&lt;/text&gt;
&lt;/g&gt;
&lt;/g&gt;
&lt;/svg&gt;
&lt;/div&gt;
&lt;h2 id=&quot;key-properties&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Key Properties&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#key-properties&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;Best open addressing method (least clustering)&lt;/li&gt;
&lt;li&gt;Probes all slots if table size is prime and h₂(k) is non-zero&lt;/li&gt;
&lt;li&gt;More computation (two hash functions)&lt;/li&gt;
&lt;li&gt;Step size must be non-zero and relatively prime to table size&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;connections&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Connections&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#connections&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Built from:&lt;/strong&gt; &lt;a href=&quot;../../hashing&quot; class=&quot;internal alias&quot; data-slug=&quot;hashing&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Hashing&lt;/a&gt;, &lt;a href=&quot;../../hash-function&quot; class=&quot;internal alias&quot; data-slug=&quot;hash-function&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Hash Function&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Builds into:&lt;/strong&gt; &lt;a href=&quot;../../collision-resolution&quot; class=&quot;internal alias&quot; data-slug=&quot;collision-resolution&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Collision Resolution&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../linear-probing&quot; class=&quot;internal alias&quot; data-slug=&quot;linear-probing&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Linear Probing&lt;/a&gt;, &lt;a href=&quot;../../quadratic-probing&quot; class=&quot;internal alias&quot; data-slug=&quot;quadratic-probing&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Quadratic Probing&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Contrasts with:&lt;/strong&gt; &lt;a href=&quot;../../quadratic-probing&quot; class=&quot;internal alias&quot; data-slug=&quot;quadratic-probing&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Quadratic Probing&lt;/a&gt; (two hashes vs one quadratic)&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;edge-cases--gotchas&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Edge Cases &amp;#x26; Gotchas&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#edge-cases--gotchas&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;h₂(k) must never be 0 (would infinite loop)&lt;/li&gt;
&lt;li&gt;Table size should be prime for complete coverage&lt;/li&gt;
&lt;li&gt;Most complex to implement of the three probing methods&lt;/li&gt;
&lt;/ul&gt;</content>
  </entry><entry>
    <title>fcfs</title>
    <link href="https://animishraa05.github.io/wiki/io/fcfs" />
    <link rel="alternate" type="text/markdown" href="https://animishraa05.github.io/wiki/io/fcfs.md" />
    <summary>The Problem When multiple I/O requests arrive for disk access, we need a simple, fair way to decide the order of servicing them.</summary>
    <published>2026-04-30T00:00:00.000Z</published>
    <updated>2026-04-30T00:00:00.000Z</updated>
    <publishedTime>Apr 30, 2026</publishedTime>
    <updatedTime>Apr 30, 2026</updatedTime>
    <category term="systems" label="systems" />
<category term="storage" label="storage" />
    <author>
      <name>Animesh Mishra</name>
      <email>animesh.mishra818@gmail.com</email>
    </author>
    <content type="html">&lt;h2 id=&quot;the-problem&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;The Problem&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#the-problem&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;When multiple I/O requests arrive for disk access, we need a simple, fair way to decide the order of servicing them.&lt;/p&gt;
&lt;h2 id=&quot;core-idea&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Core Idea&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#core-idea&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;FCFS (First Come First Serve) processes disk I/O requests in the exact order they arrive, like a queue at a store.&lt;/p&gt;
&lt;h2 id=&quot;how-it-works&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;How It Works&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#how-it-works&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ol dir=&quot;auto&quot;&gt;
&lt;li&gt;Request queue maintains arrival order&lt;/li&gt;
&lt;li&gt;Disk arm services requests in FIFO order&lt;/li&gt;
&lt;li&gt;No reordering or optimization&lt;/li&gt;
&lt;/ol&gt;
&lt;div class=&quot;graphviz-container&quot; style=&quot;display: flex; justify-content: center; margin: 1.5rem 0; overflow-x: auto;&quot; dir=&quot;auto&quot;&gt;&lt;!--?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?--&gt;

&lt;!-- Generated by graphviz version 15.1.0 (0)
 --&gt;
&lt;!-- Title: fcfs Pages: 1 --&gt;
&lt;svg width=&quot;426pt&quot; height=&quot;50pt&quot; viewBox=&quot;0.00 0.00 426.00 50.00&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; xmlns:xlink=&quot;http://www.w3.org/1999/xlink&quot;&gt;
&lt;g id=&quot;graph0&quot; class=&quot;graph&quot; transform=&quot;scale(1 1) rotate(0) translate(4 45.6)&quot;&gt;
&lt;title&gt;fcfs&lt;/title&gt;
&lt;polygon fill=&quot;white&quot; stroke=&quot;none&quot; points=&quot;-4,4 -4,-45.6 421.86,-45.6 421.86,4 -4,4&quot;&gt;&lt;/polygon&gt;
&lt;!-- Queue --&gt;
&lt;g id=&quot;node1&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Queue&lt;/title&gt;
&lt;polygon fill=&quot;lightyellow&quot; stroke=&quot;black&quot; points=&quot;116.32,-41.6 0,-41.6 0,0 116.32,0 116.32,-41.6&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;58.16&quot; y=&quot;-25&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Request Queue&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;58.16&quot; y=&quot;-8.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;[100, 50, 150, 30]&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Order --&gt;
&lt;g id=&quot;node2&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Order&lt;/title&gt;
&lt;polygon fill=&quot;lightgreen&quot; stroke=&quot;black&quot; points=&quot;290.82,-41.6 152.32,-41.6 152.32,0 290.82,0 290.82,-41.6&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;221.57&quot; y=&quot;-25&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Service Order&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;221.57&quot; y=&quot;-8.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;100 → 50 → 150 → 30&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Queue&amp;#45;&amp;gt;Order --&gt;
&lt;g id=&quot;edge1&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Queue-&gt;Order&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M116.52,-20.8C124.35,-20.8 132.49,-20.8 140.62,-20.8&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;140.56,-24.3 150.56,-20.8 140.56,-17.3 140.56,-24.3&quot;&gt;&lt;/polygon&gt;
&lt;/g&gt;
&lt;!-- Disk --&gt;
&lt;g id=&quot;node3&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Disk&lt;/title&gt;
&lt;polygon fill=&quot;orange&quot; stroke=&quot;black&quot; points=&quot;417.86,-41.6 326.82,-41.6 326.82,0 417.86,0 417.86,-41.6&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;372.34&quot; y=&quot;-25&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Disk Arm&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;372.34&quot; y=&quot;-8.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;follows order&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Order&amp;#45;&amp;gt;Disk --&gt;
&lt;g id=&quot;edge2&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Order-&gt;Disk&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M291.3,-20.8C299.38,-20.8 307.55,-20.8 315.43,-20.8&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;315.2,-24.3 325.2,-20.8 315.2,-17.3 315.2,-24.3&quot;&gt;&lt;/polygon&gt;
&lt;/g&gt;
&lt;/g&gt;
&lt;/svg&gt;
&lt;/div&gt;
&lt;h2 id=&quot;key-properties&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Key Properties&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#key-properties&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;Simplest disk scheduling algorithm&lt;/li&gt;
&lt;li&gt;Fair (no starvation)&lt;/li&gt;
&lt;li&gt;Can be very inefficient (long seek times)&lt;/li&gt;
&lt;li&gt;Example: queue [100, 50, 150, 30] → services in that order&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;connections&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Connections&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#connections&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Built from:&lt;/strong&gt; &lt;a href=&quot;../../disk-scheduling&quot; class=&quot;internal alias&quot; data-slug=&quot;disk-scheduling&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Disk Scheduling&lt;/a&gt;, &lt;a href=&quot;../../disk-structure&quot; class=&quot;internal alias&quot; data-slug=&quot;disk-structure&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Disk Structure&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Builds into:&lt;/strong&gt; &lt;a href=&quot;../../sstf&quot; class=&quot;internal alias&quot; data-slug=&quot;sstf&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;SSTF&lt;/a&gt;, &lt;a href=&quot;../../scan-scheduling&quot; class=&quot;internal alias&quot; data-slug=&quot;scan-scheduling&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;SCAN&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../disk-structure&quot; class=&quot;internal alias&quot; data-slug=&quot;disk-structure&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Disk Structure&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Contrasts with:&lt;/strong&gt; &lt;a href=&quot;../../sstf&quot; class=&quot;internal alias&quot; data-slug=&quot;sstf&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;SSTF&lt;/a&gt; (optimizes vs simple FIFO)&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;edge-cases--gotchas&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Edge Cases &amp;#x26; Gotchas&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#edge-cases--gotchas&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;Can cause wild swings across disk (poor performance)&lt;/li&gt;
&lt;li&gt;No consideration of seek distance&lt;/li&gt;
&lt;li&gt;Simple but often impractical for real systems&lt;/li&gt;
&lt;/ul&gt;</content>
  </entry><entry>
    <title>hash-function</title>
    <link href="https://animishraa05.github.io/wiki/io/hash-function" />
    <link rel="alternate" type="text/markdown" href="https://animishraa05.github.io/wiki/io/hash-function.md" />
    <summary>The Problem We need a deterministic way to convert arbitrary-sized keys (strings, numbers) into fixed-size array indices for O(1) lookup.</summary>
    <published>2026-04-30T00:00:00.000Z</published>
    <updated>2026-04-30T00:00:00.000Z</updated>
    <publishedTime>Apr 30, 2026</publishedTime>
    <updatedTime>Apr 30, 2026</updatedTime>
    <category term="systems" label="systems" />
<category term="data-structures" label="data-structures" />
    <author>
      <name>Animesh Mishra</name>
      <email>animesh.mishra818@gmail.com</email>
    </author>
    <content type="html">&lt;h2 id=&quot;the-problem&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;The Problem&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#the-problem&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;We need a deterministic way to convert arbitrary-sized keys (strings, numbers) into fixed-size array indices for O(1) lookup.&lt;/p&gt;
&lt;h2 id=&quot;core-idea&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Core Idea&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#core-idea&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;A hash function maps keys to integer values (array indices) such that equal keys always produce the same hash value, and the distribution is as uniform as possible.&lt;/p&gt;
&lt;h2 id=&quot;how-it-works&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;How It Works&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#how-it-works&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ol dir=&quot;auto&quot;&gt;
&lt;li&gt;Take input key (string, number, object)&lt;/li&gt;
&lt;li&gt;Apply mathematical transformation (e.g., modulo, multiplication, bit shifting)&lt;/li&gt;
&lt;li&gt;Output is an integer in range [0, table_size-1]&lt;/li&gt;
&lt;li&gt;Good hash functions minimize collisions&lt;/li&gt;
&lt;/ol&gt;
&lt;div class=&quot;graphviz-container&quot; style=&quot;display: flex; justify-content: center; margin: 1.5rem 0; overflow-x: auto;&quot; dir=&quot;auto&quot;&gt;&lt;!--?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?--&gt;

&lt;!-- Generated by graphviz version 15.1.0 (0)
 --&gt;
&lt;!-- Title: hash_fn Pages: 1 --&gt;
&lt;svg width=&quot;387pt&quot; height=&quot;220pt&quot; viewBox=&quot;0.00 0.00 387.00 220.00&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; xmlns:xlink=&quot;http://www.w3.org/1999/xlink&quot;&gt;
&lt;g id=&quot;graph0&quot; class=&quot;graph&quot; transform=&quot;scale(1 1) rotate(0) translate(4 216)&quot;&gt;
&lt;title&gt;hash_fn&lt;/title&gt;
&lt;polygon fill=&quot;white&quot; stroke=&quot;none&quot; points=&quot;-4,4 -4,-216 383,-216 383,4 -4,4&quot;&gt;&lt;/polygon&gt;
&lt;g id=&quot;clust1&quot; class=&quot;cluster&quot;&gt;
&lt;title&gt;cluster_output&lt;/title&gt;
&lt;polygon fill=&quot;none&quot; stroke=&quot;black&quot; points=&quot;8,-8 8,-84.8 371,-84.8 371,-8 8,-8&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;189.5&quot; y=&quot;-68.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Hash Values&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Input --&gt;
&lt;g id=&quot;node1&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Input&lt;/title&gt;
&lt;polygon fill=&quot;lightyellow&quot; stroke=&quot;black&quot; points=&quot;211.87,-212 104.13,-212 104.13,-170.4 211.87,-170.4 211.87,-212&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;158&quot; y=&quot;-195.4&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Input Keys&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;158&quot; y=&quot;-178.6&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;&#039;Alice&#039;, 42, &#039;Bob&#039;&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Function --&gt;
&lt;g id=&quot;node2&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Function&lt;/title&gt;
&lt;polygon fill=&quot;orange&quot; stroke=&quot;black&quot; points=&quot;207.03,-134.4 108.97,-134.4 108.97,-92.8 207.03,-92.8 207.03,-134.4&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;158&quot; y=&quot;-117.8&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Hash Function&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;158&quot; y=&quot;-101&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;h(key)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Input&amp;#45;&amp;gt;Function --&gt;
&lt;g id=&quot;edge1&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Input-&gt;Function&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M158,-169.94C158,-162.59 158,-154.11 158,-146.03&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;161.5,-146.17 158,-136.17 154.5,-146.17 161.5,-146.17&quot;&gt;&lt;/polygon&gt;
&lt;/g&gt;
&lt;!-- H1 --&gt;
&lt;g id=&quot;node3&quot; class=&quot;node&quot;&gt;
&lt;title&gt;H1&lt;/title&gt;
&lt;polygon fill=&quot;lightgreen&quot; stroke=&quot;black&quot; points=&quot;105.79,-52 16.21,-52 16.21,-16 105.79,-16 105.79,-52&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;61&quot; y=&quot;-29.8&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;h(&#039;Alice&#039;) = 3&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Function&amp;#45;&amp;gt;H1 --&gt;
&lt;g id=&quot;edge2&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Function-&gt;H1&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M125.65,-92.54C121.99,-90.03 118.37,-87.41 115,-84.8 105.32,-77.3 95.31,-68.42 86.57,-60.25&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;89.08,-57.8 79.42,-53.44 84.25,-62.87 89.08,-57.8&quot;&gt;&lt;/polygon&gt;
&lt;/g&gt;
&lt;!-- H2 --&gt;
&lt;g id=&quot;node4&quot; class=&quot;node&quot;&gt;
&lt;title&gt;H2&lt;/title&gt;
&lt;polygon fill=&quot;lightgreen&quot; stroke=&quot;black&quot; points=&quot;192.11,-52 123.89,-52 123.89,-16 192.11,-16 192.11,-52&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;158&quot; y=&quot;-29.8&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;h(42) = 7&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Function&amp;#45;&amp;gt;H2 --&gt;
&lt;g id=&quot;edge3&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Function-&gt;H2&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M158,-92.62C158,-83.84 158,-73.36 158,-63.77&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;161.5,-63.79 158,-53.79 154.5,-63.79 161.5,-63.79&quot;&gt;&lt;/polygon&gt;
&lt;/g&gt;
&lt;!-- H3 --&gt;
&lt;g id=&quot;node5&quot; class=&quot;node&quot;&gt;
&lt;title&gt;H3&lt;/title&gt;
&lt;polygon fill=&quot;salmon&quot; stroke=&quot;black&quot; points=&quot;363.49,-52 210.51,-52 210.51,-16 363.49,-16 363.49,-52&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;287&quot; y=&quot;-29.8&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;h(&#039;Bob&#039;) = 3 ← collision!&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Function&amp;#45;&amp;gt;H3 --&gt;
&lt;g id=&quot;edge4&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Function-&gt;H3&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M191.56,-92.41C208.94,-81.96 230.26,-69.13 248.33,-58.26&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;249.93,-61.38 256.7,-53.23 246.32,-55.39 249.93,-61.38&quot;&gt;&lt;/polygon&gt;
&lt;/g&gt;
&lt;/g&gt;
&lt;/svg&gt;
&lt;/div&gt;
&lt;h2 id=&quot;key-properties&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Key Properties&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#key-properties&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;Deterministic: same key → same hash always&lt;/li&gt;
&lt;li&gt;Uniform distribution minimizes collisions&lt;/li&gt;
&lt;li&gt;Fast to compute (shouldn’t be slower than the data structure it serves)&lt;/li&gt;
&lt;li&gt;Examples: division method, multiplication method, universal hashing&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;connections&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Connections&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#connections&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Built from:&lt;/strong&gt; &lt;a href=&quot;../../hashing&quot; class=&quot;internal alias&quot; data-slug=&quot;hashing&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Hashing&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Builds into:&lt;/strong&gt; &lt;a href=&quot;../../separate-chaining&quot; class=&quot;internal alias&quot; data-slug=&quot;separate-chaining&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Separate Chaining&lt;/a&gt;, &lt;a href=&quot;../../linear-probing&quot; class=&quot;internal alias&quot; data-slug=&quot;linear-probing&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Linear Probing&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../collision-resolution&quot; class=&quot;internal alias&quot; data-slug=&quot;collision-resolution&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Collision Resolution&lt;/a&gt;, &lt;a href=&quot;../../load-factor&quot; class=&quot;internal alias&quot; data-slug=&quot;load-factor&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Load Factor&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Contrasts with:&lt;/strong&gt; &lt;a href=&quot;../../random-number-generator&quot; class=&quot;internal alias&quot; data-slug=&quot;random-number-generator&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Random Number Generator&lt;/a&gt; (hash is deterministic, not random)&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;edge-cases--gotchas&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Edge Cases &amp;#x26; Gotchas&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#edge-cases--gotchas&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;Poor hash functions cause clustering (many collisions)&lt;/li&gt;
&lt;li&gt;String hashing must handle variable lengths&lt;/li&gt;
&lt;li&gt;Cryptographic hash functions are overkill for hash tables (too slow)&lt;/li&gt;
&lt;li&gt;Changing hash function requires rehashing entire table&lt;/li&gt;
&lt;/ul&gt;</content>
  </entry><entry>
    <title>Hashing Performance — Collision Resolution Techniques Compared</title>
    <link href="https://animishraa05.github.io/wiki/io/hashing-performance" />
    <link rel="alternate" type="text/markdown" href="https://animishraa05.github.io/wiki/io/hashing-performance.md" />
    <summary>Framing Compare four collision resolution techniques for hash tables: separate chaining, linear probing, quadratic probing, and double hashing — analyzing their performance, clustering behavior, and practical trade-offs.</summary>
    <published>2026-04-30T00:00:00.000Z</published>
    <updated>2026-04-30T00:00:00.000Z</updated>
    <publishedTime>Apr 30, 2026</publishedTime>
    <updatedTime>Apr 30, 2026</updatedTime>
    <category term="systems" label="systems" />
<category term="data-structures" label="data-structures" />
    <author>
      <name>Animesh Mishra</name>
      <email>animesh.mishra818@gmail.com</email>
    </author>
    <content type="html">&lt;h2 id=&quot;framing&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Framing&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#framing&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;Compare four collision resolution techniques for hash tables: &lt;strong&gt;separate chaining&lt;/strong&gt;, &lt;strong&gt;linear probing&lt;/strong&gt;, &lt;strong&gt;quadratic probing&lt;/strong&gt;, and &lt;strong&gt;double hashing&lt;/strong&gt; — analyzing their performance, clustering behavior, and practical trade-offs.&lt;/p&gt;
&lt;h2 id=&quot;comparison&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Comparison&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#comparison&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Technique&lt;/th&gt;
&lt;th&gt;Best Case&lt;/th&gt;
&lt;th&gt;Average Case&lt;/th&gt;
&lt;th&gt;Worst Case&lt;/th&gt;
&lt;th&gt;Clustering&lt;/th&gt;
&lt;th&gt;Deletion&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Separate Chaining&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;O(1)&lt;/td&gt;
&lt;td&gt;O(1)&lt;/td&gt;
&lt;td&gt;O(n)&lt;/td&gt;
&lt;td&gt;None&lt;/td&gt;
&lt;td&gt;Easy&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Linear Probing&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;O(1)&lt;/td&gt;
&lt;td&gt;O(1)&lt;/td&gt;
&lt;td&gt;O(n)&lt;/td&gt;
&lt;td&gt;Primary clustering&lt;/td&gt;
&lt;td&gt;Tombstones&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Quadratic Probing&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;O(1)&lt;/td&gt;
&lt;td&gt;O(1)&lt;/td&gt;
&lt;td&gt;O(n)&lt;/td&gt;
&lt;td&gt;Secondary clustering&lt;/td&gt;
&lt;td&gt;Tombstones&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Double Hashing&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;O(1)&lt;/td&gt;
&lt;td&gt;O(1)&lt;/td&gt;
&lt;td&gt;O(n)&lt;/td&gt;
&lt;td&gt;Minimal&lt;/td&gt;
&lt;td&gt;Tombstones&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;h2 id=&quot;key-insights&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Key Insights&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#key-insights&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ol dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Separate chaining is simplest&lt;/strong&gt; — each slot has a linked list; performance depends on chain length (load factor α)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Linear probing causes primary clustering&lt;/strong&gt; — long runs of occupied slots form, increasing probe lengths&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Quadratic probing reduces primary clustering&lt;/strong&gt; but causes secondary clustering (same initial hash = same probe sequence)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Double hashing is best&lt;/strong&gt; — different step size per key eliminates most clustering, probes all slots if table size is prime&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Load factor α ≤ 0.7&lt;/strong&gt; is critical — all methods degrade rapidly above this threshold&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Open addressing (probing) uses less memory&lt;/strong&gt; (no linked list pointers) but requires more careful load factor management&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&quot;synthesis&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Synthesis&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#synthesis&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;The choice depends on use case: &lt;strong&gt;separate chaining&lt;/strong&gt; for simplicity and easy deletion; &lt;strong&gt;double hashing&lt;/strong&gt; for best theoretical performance; &lt;strong&gt;linear probing&lt;/strong&gt; only for very low load factors. All methods require good hash functions and load factor monitoring.&lt;/p&gt;
&lt;h2 id=&quot;connections&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Connections&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#connections&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;a href=&quot;../../hashing&quot; class=&quot;internal alias&quot; data-slug=&quot;hashing&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Hashing&lt;/a&gt; — the fundamental technique&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;../../separate-chaining&quot; class=&quot;internal alias&quot; data-slug=&quot;separate-chaining&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Separate Chaining&lt;/a&gt; — linked lists at each slot&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;../../linear-probing&quot; class=&quot;internal alias&quot; data-slug=&quot;linear-probing&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Linear Probing&lt;/a&gt; — probe next slot&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;../../quadratic-probing&quot; class=&quot;internal alias&quot; data-slug=&quot;quadratic-probing&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Quadratic Probing&lt;/a&gt; — probe with i² skip&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;../../double-hashing&quot; class=&quot;internal alias&quot; data-slug=&quot;double-hashing&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Double Hashing&lt;/a&gt; — two hash functions&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;../../load-factor&quot; class=&quot;internal alias&quot; data-slug=&quot;load-factor&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Load Factor&lt;/a&gt; — critical for all methods&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;../../hash-function&quot; class=&quot;internal alias&quot; data-slug=&quot;hash-function&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Hash Function&lt;/a&gt; — quality affects all methods&lt;/li&gt;
&lt;/ul&gt;</content>
  </entry><entry>
    <title>hashing</title>
    <link href="https://animishraa05.github.io/wiki/io/hashing" />
    <link rel="alternate" type="text/markdown" href="https://animishraa05.github.io/wiki/io/hashing.md" />
    <summary>The Problem Searching an array or list takes O(n) time.</summary>
    <published>2026-04-30T00:00:00.000Z</published>
    <updated>2026-04-30T00:00:00.000Z</updated>
    <publishedTime>Apr 30, 2026</publishedTime>
    <updatedTime>Apr 30, 2026</updatedTime>
    <category term="systems" label="systems" />
<category term="data-structures" label="data-structures" />
    <author>
      <name>Animesh Mishra</name>
      <email>animesh.mishra818@gmail.com</email>
    </author>
    <content type="html">&lt;h2 id=&quot;the-problem&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;The Problem&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#the-problem&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;Searching an array or list takes O(n) time. For large datasets, we need O(1) average-case lookup by “scattering” data to computed positions.&lt;/p&gt;
&lt;h2 id=&quot;core-idea&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Core Idea&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#core-idea&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;Hashing uses a hash function to map keys to array indices, providing O(1) average-case insert, search, and delete operations.&lt;/p&gt;
&lt;h2 id=&quot;how-it-works&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;How It Works&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#how-it-works&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ol dir=&quot;auto&quot;&gt;
&lt;li&gt;Hash function computes index: &lt;code class=&quot;notranslate&quot;&gt;hash(key) % table_size&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Key-value pair is stored at that index&lt;/li&gt;
&lt;li&gt;To search: compute hash of key, go directly to index&lt;/li&gt;
&lt;li&gt;Collisions (two keys → same index) handled by collision resolution&lt;/li&gt;
&lt;/ol&gt;
&lt;div class=&quot;graphviz-container&quot; style=&quot;display: flex; justify-content: center; margin: 1.5rem 0; overflow-x: auto;&quot; dir=&quot;auto&quot;&gt;&lt;!--?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?--&gt;

&lt;!-- Generated by graphviz version 15.1.0 (0)
 --&gt;
&lt;!-- Title: hashing Pages: 1 --&gt;
&lt;svg width=&quot;469pt&quot; height=&quot;50pt&quot; viewBox=&quot;0.00 0.00 469.00 50.00&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; xmlns:xlink=&quot;http://www.w3.org/1999/xlink&quot;&gt;
&lt;g id=&quot;graph0&quot; class=&quot;graph&quot; transform=&quot;scale(1 1) rotate(0) translate(4 45.6)&quot;&gt;
&lt;title&gt;hashing&lt;/title&gt;
&lt;polygon fill=&quot;white&quot; stroke=&quot;none&quot; points=&quot;-4,4 -4,-45.6 465.23,-45.6 465.23,4 -4,4&quot;&gt;&lt;/polygon&gt;
&lt;!-- Key --&gt;
&lt;g id=&quot;node1&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Key&lt;/title&gt;
&lt;polygon fill=&quot;lightyellow&quot; stroke=&quot;black&quot; points=&quot;87.9,-41.6 0,-41.6 0,0 87.9,0 87.9,-41.6&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;43.95&quot; y=&quot;-25&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Key&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;43.95&quot; y=&quot;-8.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;(e.g., &#039;Alice&#039;)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Hash --&gt;
&lt;g id=&quot;node2&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Hash&lt;/title&gt;
&lt;polygon fill=&quot;orange&quot; stroke=&quot;black&quot; points=&quot;221.95,-41.6 123.9,-41.6 123.9,0 221.95,0 221.95,-41.6&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;172.93&quot; y=&quot;-25&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Hash Function&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;172.93&quot; y=&quot;-8.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;h(key)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Key&amp;#45;&amp;gt;Hash --&gt;
&lt;g id=&quot;edge1&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Key-&gt;Hash&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M88.29,-20.8C96.01,-20.8 104.17,-20.8 112.24,-20.8&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;112.04,-24.3 122.04,-20.8 112.04,-17.3 112.04,-24.3&quot;&gt;&lt;/polygon&gt;
&lt;/g&gt;
&lt;!-- Index --&gt;
&lt;g id=&quot;node3&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Index&lt;/title&gt;
&lt;polygon fill=&quot;lightgreen&quot; stroke=&quot;black&quot; points=&quot;319.05,-41.6 257.95,-41.6 257.95,0 319.05,0 319.05,-41.6&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;288.5&quot; y=&quot;-25&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Index&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;288.5&quot; y=&quot;-8.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;(0..N-1)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Hash&amp;#45;&amp;gt;Index --&gt;
&lt;g id=&quot;edge2&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Hash-&gt;Index&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M222.42,-20.8C230.35,-20.8 238.5,-20.8 246.23,-20.8&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;246.05,-24.3 256.05,-20.8 246.05,-17.3 246.05,-24.3&quot;&gt;&lt;/polygon&gt;
&lt;/g&gt;
&lt;!-- Table --&gt;
&lt;g id=&quot;node4&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Table&lt;/title&gt;
&lt;polygon fill=&quot;lightblue&quot; stroke=&quot;black&quot; points=&quot;461.23,-41.6 355.05,-41.6 355.05,0 461.23,0 461.23,-41.6&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;408.14&quot; y=&quot;-25&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Hash Table&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;408.14&quot; y=&quot;-8.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;array of buckets&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Index&amp;#45;&amp;gt;Table --&gt;
&lt;g id=&quot;edge3&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Index-&gt;Table&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M319.49,-20.8C326.88,-20.8 335.09,-20.8 343.42,-20.8&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;343.29,-24.3 353.29,-20.8 343.29,-17.3 343.29,-24.3&quot;&gt;&lt;/polygon&gt;
&lt;/g&gt;
&lt;/g&gt;
&lt;/svg&gt;
&lt;/div&gt;
&lt;h2 id=&quot;key-properties&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Key Properties&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#key-properties&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;Best/average case: O(1) for insert, search, delete&lt;/li&gt;
&lt;li&gt;Worst case: O(n) when all keys collide&lt;/li&gt;
&lt;li&gt;Performance depends on hash function quality and load factor&lt;/li&gt;
&lt;li&gt;Load factor α = elements / table_size (keep α ≤ 0.7)&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;connections&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Connections&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#connections&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Built from:&lt;/strong&gt; &lt;a href=&quot;../../hash-function&quot; class=&quot;internal alias&quot; data-slug=&quot;hash-function&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Hash Function&lt;/a&gt;, &lt;a href=&quot;../../collision-resolution&quot; class=&quot;internal alias&quot; data-slug=&quot;collision-resolution&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Collision Resolution&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Builds into:&lt;/strong&gt; &lt;a href=&quot;../../separate-chaining&quot; class=&quot;internal alias&quot; data-slug=&quot;separate-chaining&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Separate Chaining&lt;/a&gt;, &lt;a href=&quot;../../linear-probing&quot; class=&quot;internal alias&quot; data-slug=&quot;linear-probing&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Linear Probing&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../load-factor&quot; class=&quot;internal alias&quot; data-slug=&quot;load-factor&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Load Factor&lt;/a&gt;, &lt;a href=&quot;../../double-hashing&quot; class=&quot;internal alias&quot; data-slug=&quot;double-hashing&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Double Hashing&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Contrasts with:&lt;/strong&gt; &lt;a href=&quot;../../Private/Daily/computer-science/algorithms/binary-search-tree&quot; class=&quot;internal alias&quot; data-slug=&quot;Private/Daily/computer-science/algorithms/binary-search-tree&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Binary Search Tree&lt;/a&gt; (O(log n) vs average O(1))&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;edge-cases--gotchas&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Edge Cases &amp;#x26; Gotchas&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#edge-cases--gotchas&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;Bad hash function causes many collisions → degrades to O(n)&lt;/li&gt;
&lt;li&gt;High load factor (&gt;0.7) dramatically increases collisions&lt;/li&gt;
&lt;li&gt;Rehashing needed when table gets too full&lt;/li&gt;
&lt;li&gt;Worst case: all keys hash to same index&lt;/li&gt;
&lt;/ul&gt;</content>
  </entry><entry>
    <title>interrupt-handler</title>
    <link href="https://animishraa05.github.io/wiki/io/interrupt-handler" />
    <link rel="alternate" type="text/markdown" href="https://animishraa05.github.io/wiki/io/interrupt-handler.md" />
    <summary>The Problem If the CPU polls devices (checks repeatedly if they’re done), it wastes cycles when devices are slow.</summary>
    <published>2026-04-30T00:00:00.000Z</published>
    <updated>2026-04-30T00:00:00.000Z</updated>
    <publishedTime>Apr 30, 2026</publishedTime>
    <updatedTime>Apr 30, 2026</updatedTime>
    <category term="systems" label="systems" />
<category term="io" label="io" />
    <author>
      <name>Animesh Mishra</name>
      <email>animesh.mishra818@gmail.com</email>
    </author>
    <content type="html">&lt;h2 id=&quot;the-problem&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;The Problem&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#the-problem&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;If the CPU polls devices (checks repeatedly if they’re done), it wastes cycles when devices are slow. The CPU should be free to do other work while waiting for I/O, and only handle the device when it’s actually ready.&lt;/p&gt;
&lt;h2 id=&quot;core-idea&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Core Idea&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#core-idea&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;A special function that executes when a device raises an interrupt, allowing the CPU to respond asynchronously to I/O completion without busy-waiting.&lt;/p&gt;
&lt;h2 id=&quot;how-it-works&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;How It Works&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#how-it-works&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ol dir=&quot;auto&quot;&gt;
&lt;li&gt;Device completes operation and raises an interrupt signal on the control bus&lt;/li&gt;
&lt;li&gt;CPU pauses current work, saves context (registers, program counter)&lt;/li&gt;
&lt;li&gt;CPU jumps to the interrupt handler (addressed by interrupt vector)&lt;/li&gt;
&lt;li&gt;Handler reads device status register to confirm completion&lt;/li&gt;
&lt;li&gt;Handler copies data from device buffer to memory (or vice versa)&lt;/li&gt;
&lt;li&gt;Handler wakes up any process waiting for this I/O&lt;/li&gt;
&lt;li&gt;CPU restores context and resumes previous work&lt;/li&gt;
&lt;/ol&gt;
&lt;div class=&quot;graphviz-container&quot; style=&quot;display: flex; justify-content: center; margin: 1.5rem 0; overflow-x: auto;&quot; dir=&quot;auto&quot;&gt;&lt;!--?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?--&gt;

&lt;!-- Generated by graphviz version 15.1.0 (0)
 --&gt;
&lt;!-- Title: interrupt Pages: 1 --&gt;
&lt;svg width=&quot;215pt&quot; height=&quot;350pt&quot; viewBox=&quot;0.00 0.00 215.00 350.00&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; xmlns:xlink=&quot;http://www.w3.org/1999/xlink&quot;&gt;
&lt;g id=&quot;graph0&quot; class=&quot;graph&quot; transform=&quot;scale(1 1) rotate(0) translate(4 345.6)&quot;&gt;
&lt;title&gt;interrupt&lt;/title&gt;
&lt;polygon fill=&quot;white&quot; stroke=&quot;none&quot; points=&quot;-4,4 -4,-345.6 211.49,-345.6 211.49,4 -4,4&quot;&gt;&lt;/polygon&gt;
&lt;!-- CPU --&gt;
&lt;g id=&quot;node1&quot; class=&quot;node&quot;&gt;
&lt;title&gt;CPU&lt;/title&gt;
&lt;polygon fill=&quot;lightyellow&quot; stroke=&quot;black&quot; points=&quot;115.91,-247.2 0,-247.2 0,-205.6 115.91,-205.6 115.91,-247.2&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;57.95&quot; y=&quot;-230.6&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;CPU&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;57.95&quot; y=&quot;-213.8&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;executing process&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Handler --&gt;
&lt;g id=&quot;node3&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Handler&lt;/title&gt;
&lt;polygon fill=&quot;salmon&quot; stroke=&quot;black&quot; points=&quot;114.74,-136 1.17,-136 1.17,-94.4 114.74,-94.4 114.74,-136&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;57.95&quot; y=&quot;-119.4&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Interrupt Handler&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;57.95&quot; y=&quot;-102.6&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;(ISR)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- CPU&amp;#45;&amp;gt;Handler --&gt;
&lt;g id=&quot;edge2&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;CPU-&gt;Handler&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M21.36,-205.26C15.44,-200.3 10.13,-194.41 6.69,-187.6 -0.04,-174.27 -0.04,-167.33 6.69,-154 8.47,-150.49 10.74,-147.22 13.33,-144.2&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;15.59,-146.9 20.28,-137.4 10.69,-141.89 15.59,-146.9&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;47.32&quot; y=&quot;-175&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;context switch&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;47.32&quot; y=&quot;-158.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;to ISR&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Device --&gt;
&lt;g id=&quot;node2&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Device&lt;/title&gt;
&lt;polygon fill=&quot;orange&quot; stroke=&quot;black&quot; points=&quot;105.41,-341.6 10.49,-341.6 10.49,-300 105.41,-300 105.41,-341.6&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;57.95&quot; y=&quot;-325&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Device&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;57.95&quot; y=&quot;-308.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;completes I/O&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Device&amp;#45;&amp;gt;CPU --&gt;
&lt;g id=&quot;edge1&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Device-&gt;CPU&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;red&quot; stroke-dasharray=&quot;5 2&quot; d=&quot;M57.95,-299.75C57.95,-287.76 57.95,-272.27 57.95,-258.7&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;red&quot; stroke=&quot;red&quot; points=&quot;61.45,-258.92 57.95,-248.92 54.45,-258.92 61.45,-258.92&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;100.53&quot; y=&quot;-269.4&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;interrupt signal&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Handler&amp;#45;&amp;gt;CPU --&gt;
&lt;g id=&quot;edge4&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Handler-&gt;CPU&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; stroke-dasharray=&quot;5 2&quot; d=&quot;M77.87,-136.26C81.99,-141.61 85.75,-147.67 87.95,-154 92.87,-168.1 92.87,-173.5 87.95,-187.6 86.95,-190.47 85.64,-193.28 84.11,-196&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;81.35,-193.82 78.71,-204.08 87.17,-197.71 81.35,-193.82&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;149.56&quot; y=&quot;-166.6&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;return from interrupt&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Process --&gt;
&lt;g id=&quot;node4&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Process&lt;/title&gt;
&lt;polygon fill=&quot;lightgreen&quot; stroke=&quot;black&quot; points=&quot;111.64,-41.6 4.27,-41.6 4.27,0 111.64,0 111.64,-41.6&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;57.95&quot; y=&quot;-25&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Waiting Process&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;57.95&quot; y=&quot;-8.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;woken up&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Handler&amp;#45;&amp;gt;Process --&gt;
&lt;g id=&quot;edge3&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Handler-&gt;Process&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; stroke-dasharray=&quot;5 2&quot; d=&quot;M57.95,-94.15C57.95,-82.16 57.95,-66.67 57.95,-53.1&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;61.45,-53.32 57.95,-43.32 54.45,-53.32 61.45,-53.32&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;87.88&quot; y=&quot;-63.8&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;wake_up()&lt;/text&gt;
&lt;/g&gt;
&lt;/g&gt;
&lt;/svg&gt;
&lt;/div&gt;
&lt;h2 id=&quot;key-properties&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Key Properties&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#key-properties&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;Runs in kernel mode with high priority&lt;/li&gt;
&lt;li&gt;Must execute quickly (other interrupts may be masked)&lt;/li&gt;
&lt;li&gt;Can’t block or sleep (would hang the system)&lt;/li&gt;
&lt;li&gt;Shares data with the interrupted process via kernel structures&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;connections&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Connections&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#connections&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Built from:&lt;/strong&gt; &lt;a href=&quot;../../io-software-structure&quot; class=&quot;internal alias&quot; data-slug=&quot;io-software-structure&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;O Software Structure&lt;/a&gt;, &lt;a href=&quot;../../device-controller&quot; class=&quot;internal alias&quot; data-slug=&quot;device-controller&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Device Controller&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Builds into:&lt;/strong&gt; &lt;a href=&quot;../../io-request-to-hardware&quot; class=&quot;internal alias&quot; data-slug=&quot;io-request-to-hardware&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;O Request to Hardware Operation&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../io-system&quot; class=&quot;internal alias&quot; data-slug=&quot;io-system&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;O System&lt;/a&gt;, &lt;a href=&quot;../../polling&quot; class=&quot;internal alias&quot; data-slug=&quot;polling&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Polling&lt;/a&gt;, &lt;a href=&quot;../../dma&quot; class=&quot;internal alias&quot; data-slug=&quot;dma&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;DMA&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Contrasts with:&lt;/strong&gt; &lt;a href=&quot;../../user-level-io-software&quot; class=&quot;internal alias&quot; data-slug=&quot;user-level-io-software&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;O Software&lt;/a&gt; (runs in user space, not in interrupt context)&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;edge-cases--gotchas&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Edge Cases &amp;#x26; Gotchas&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#edge-cases--gotchas&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;Interrupt handlers can’t allocate memory or sleep (leads to deadlock)&lt;/li&gt;
&lt;li&gt;Nested interrupts require careful stack management&lt;/li&gt;
&lt;li&gt;Lost interrupts (device interrupts before handler is registered) cause hangs&lt;/li&gt;
&lt;li&gt;Interrupt storms (too many rapid interrupts) can freeze the system&lt;/li&gt;
&lt;/ul&gt;</content>
  </entry><entry>
    <title>io-devices</title>
    <link href="https://animishraa05.github.io/wiki/io/io-devices" />
    <link rel="alternate" type="text/markdown" href="https://animishraa05.github.io/wiki/io/io-devices.md" />
    <summary>The Problem The CPU needs to interact with many different types of external hardware — keyboards, disks, printers, network cards — each with different speeds, data formats, and interfaces.</summary>
    <published>2026-04-30T00:00:00.000Z</published>
    <updated>2026-04-30T00:00:00.000Z</updated>
    <publishedTime>Apr 30, 2026</publishedTime>
    <updatedTime>Apr 30, 2026</updatedTime>
    <category term="systems" label="systems" />
<category term="io" label="io" />
    <author>
      <name>Animesh Mishra</name>
      <email>animesh.mishra818@gmail.com</email>
    </author>
    <content type="html">&lt;h2 id=&quot;the-problem&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;The Problem&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#the-problem&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;The CPU needs to interact with many different types of external hardware — keyboards, disks, printers, network cards — each with different speeds, data formats, and interfaces. The OS must classify and manage them appropriately.&lt;/p&gt;
&lt;h2 id=&quot;core-idea&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Core Idea&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#core-idea&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;I/O devices are classified by their function (input/output/storage/communication) and data transfer mode (block vs character vs stream), determining how the OS handles them.&lt;/p&gt;
&lt;h2 id=&quot;how-it-works&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;How It Works&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#how-it-works&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;Devices are classified into:&lt;/p&gt;
&lt;ol dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;By function&lt;/strong&gt;: Input (keyboard), Output (monitor), Storage (disk), Communication (NIC)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;By data transfer&lt;/strong&gt;: Block devices (disk, fixed-size blocks), Character devices (keyboard, stream of bytes), Stream devices (audio/video)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;By speed&lt;/strong&gt;: Slow (keyboard), Medium (disk), Fast (GPU, network)&lt;/li&gt;
&lt;/ol&gt;
&lt;div class=&quot;graphviz-container&quot; style=&quot;display: flex; justify-content: center; margin: 1.5rem 0; overflow-x: auto;&quot; dir=&quot;auto&quot;&gt;&lt;!--?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?--&gt;

&lt;!-- Generated by graphviz version 15.1.0 (0)
 --&gt;
&lt;!-- Title: io_devices Pages: 1 --&gt;
&lt;svg width=&quot;708pt&quot; height=&quot;106pt&quot; viewBox=&quot;0.00 0.00 708.00 106.00&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; xmlns:xlink=&quot;http://www.w3.org/1999/xlink&quot;&gt;
&lt;g id=&quot;graph0&quot; class=&quot;graph&quot; transform=&quot;scale(1 1) rotate(0) translate(4 102.4)&quot;&gt;
&lt;title&gt;io_devices&lt;/title&gt;
&lt;polygon fill=&quot;white&quot; stroke=&quot;none&quot; points=&quot;-4,4 -4,-102.4 704,-102.4 704,4 -4,4&quot;&gt;&lt;/polygon&gt;
&lt;g id=&quot;clust1&quot; class=&quot;cluster&quot;&gt;
&lt;title&gt;cluster_input&lt;/title&gt;
&lt;polygon fill=&quot;none&quot; stroke=&quot;black&quot; points=&quot;8,-10.8 8,-87.6 168,-87.6 168,-10.8 8,-10.8&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;88&quot; y=&quot;-71&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Input Devices&lt;/text&gt;
&lt;/g&gt;
&lt;g id=&quot;clust2&quot; class=&quot;cluster&quot;&gt;
&lt;title&gt;cluster_output&lt;/title&gt;
&lt;polygon fill=&quot;none&quot; stroke=&quot;black&quot; points=&quot;176,-10.8 176,-87.6 326,-87.6 326,-10.8 176,-10.8&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;251&quot; y=&quot;-71&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Output Devices&lt;/text&gt;
&lt;/g&gt;
&lt;g id=&quot;clust3&quot; class=&quot;cluster&quot;&gt;
&lt;title&gt;cluster_storage&lt;/title&gt;
&lt;polygon fill=&quot;none&quot; stroke=&quot;black&quot; points=&quot;334,-8 334,-90.4 572,-90.4 572,-8 334,-8&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;453&quot; y=&quot;-73.8&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Storage Devices&lt;/text&gt;
&lt;/g&gt;
&lt;g id=&quot;clust4&quot; class=&quot;cluster&quot;&gt;
&lt;title&gt;cluster_comm&lt;/title&gt;
&lt;polygon fill=&quot;none&quot; stroke=&quot;black&quot; points=&quot;580,-8 580,-90.4 692,-90.4 692,-8 580,-8&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;636&quot; y=&quot;-73.8&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Communication&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Keyboard --&gt;
&lt;g id=&quot;node1&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Keyboard&lt;/title&gt;
&lt;polygon fill=&quot;lightgreen&quot; stroke=&quot;black&quot; points=&quot;87.6,-54.8 16.4,-54.8 16.4,-18.8 87.6,-18.8 87.6,-54.8&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;52&quot; y=&quot;-32.6&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Keyboard&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Mouse --&gt;
&lt;g id=&quot;node2&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Mouse&lt;/title&gt;
&lt;polygon fill=&quot;lightgreen&quot; stroke=&quot;black&quot; points=&quot;160.06,-54.8 105.94,-54.8 105.94,-18.8 160.06,-18.8 160.06,-54.8&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;133&quot; y=&quot;-32.6&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Mouse&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Monitor --&gt;
&lt;g id=&quot;node3&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Monitor&lt;/title&gt;
&lt;polygon fill=&quot;lightyellow&quot; stroke=&quot;black&quot; points=&quot;245.94,-54.8 184.06,-54.8 184.06,-18.8 245.94,-18.8 245.94,-54.8&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;215&quot; y=&quot;-32.6&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Monitor&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Printer --&gt;
&lt;g id=&quot;node4&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Printer&lt;/title&gt;
&lt;polygon fill=&quot;lightyellow&quot; stroke=&quot;black&quot; points=&quot;318.05,-54.8 263.95,-54.8 263.95,-18.8 318.05,-18.8 318.05,-54.8&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;291&quot; y=&quot;-32.6&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Printer&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Disk --&gt;
&lt;g id=&quot;node5&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Disk&lt;/title&gt;
&lt;polygon fill=&quot;lightblue&quot; stroke=&quot;black&quot; points=&quot;443.95,-57.6 342.05,-57.6 342.05,-16 443.95,-16 443.95,-57.6&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;393&quot; y=&quot;-41&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Hard Disk&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;393&quot; y=&quot;-24.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;(Block Device)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- SSD --&gt;
&lt;g id=&quot;node6&quot; class=&quot;node&quot;&gt;
&lt;title&gt;SSD&lt;/title&gt;
&lt;polygon fill=&quot;lightblue&quot; stroke=&quot;black&quot; points=&quot;563.95,-57.6 462.05,-57.6 462.05,-16 563.95,-16 563.95,-57.6&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;513&quot; y=&quot;-41&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;SSD&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;513&quot; y=&quot;-24.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;(Block Device)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- NIC --&gt;
&lt;g id=&quot;node7&quot; class=&quot;node&quot;&gt;
&lt;title&gt;NIC&lt;/title&gt;
&lt;polygon fill=&quot;orange&quot; stroke=&quot;black&quot; points=&quot;683.85,-57.6 588.15,-57.6 588.15,-16 683.85,-16 683.85,-57.6&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;636&quot; y=&quot;-41&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Network Card&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;636&quot; y=&quot;-24.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;(Stream)&lt;/text&gt;
&lt;/g&gt;
&lt;/g&gt;
&lt;/svg&gt;
&lt;/div&gt;
&lt;h2 id=&quot;key-properties&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Key Properties&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#key-properties&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;Block devices transfer fixed-size blocks (512B, 4KB), seekable&lt;/li&gt;
&lt;li&gt;Character devices transfer bytes sequentially, not seekable&lt;/li&gt;
&lt;li&gt;Speed varies from very slow (keyboard) to very fast (10GbE NIC)&lt;/li&gt;
&lt;li&gt;Hybrid devices exist (touchscreen = input + output)&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;connections&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Connections&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#connections&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Built from:&lt;/strong&gt; &lt;a href=&quot;../../io-system&quot; class=&quot;internal alias&quot; data-slug=&quot;io-system&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;O System&lt;/a&gt;, &lt;a href=&quot;../../device-driver&quot; class=&quot;internal alias&quot; data-slug=&quot;device-driver&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Device Driver&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Builds into:&lt;/strong&gt; &lt;a href=&quot;../../block-driver&quot; class=&quot;internal alias&quot; data-slug=&quot;block-driver&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Block Driver&lt;/a&gt;, &lt;a href=&quot;../../character-driver&quot; class=&quot;internal alias&quot; data-slug=&quot;character-driver&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Character Driver&lt;/a&gt;, &lt;a href=&quot;../../network-driver&quot; class=&quot;internal alias&quot; data-slug=&quot;network-driver&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Network Driver&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../device-controller&quot; class=&quot;internal alias&quot; data-slug=&quot;device-controller&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Device Controller&lt;/a&gt;, &lt;a href=&quot;../../system-bus&quot; class=&quot;internal alias&quot; data-slug=&quot;system-bus&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;System Bus&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Contrasts with:&lt;/strong&gt; &lt;a href=&quot;../../cpu&quot; class=&quot;internal alias&quot; data-slug=&quot;cpu&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;CPU&lt;/a&gt; (computes, not I/O)&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;edge-cases--gotchas&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Edge Cases &amp;#x26; Gotchas&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#edge-cases--gotchas&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;Some devices are both input and output (touchscreen, modem)&lt;/li&gt;
&lt;li&gt;Block devices may emulate character devices for certain operations&lt;/li&gt;
&lt;li&gt;Device classification blurs with modern hardware (GPU does both compute and output)&lt;/li&gt;
&lt;/ul&gt;</content>
  </entry><entry>
    <title>io-request-to-hardware</title>
    <link href="https://animishraa05.github.io/wiki/io/io-request-to-hardware" />
    <link rel="alternate" type="text/markdown" href="https://animishraa05.github.io/wiki/io/io-request-to-hardware.md" />
    <summary>The Problem When an application calls read(&amp;quot;data.txt&amp;quot;), how does this high-level request end up causing a disk head to move and data to appear in memory? The journey from software request to hardware action is complex.</summary>
    <published>2026-04-30T00:00:00.000Z</published>
    <updated>2026-04-30T00:00:00.000Z</updated>
    <publishedTime>Apr 30, 2026</publishedTime>
    <updatedTime>Apr 30, 2026</updatedTime>
    <category term="systems" label="systems" />
<category term="io" label="io" />
    <author>
      <name>Animesh Mishra</name>
      <email>animesh.mishra818@gmail.com</email>
    </author>
    <content type="html">&lt;h2 id=&quot;the-problem&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;The Problem&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#the-problem&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;When an application calls &lt;code class=&quot;notranslate&quot;&gt;read(&quot;data.txt&quot;)&lt;/code&gt;, how does this high-level request end up causing a disk head to move and data to appear in memory? The journey from software request to hardware action is complex.&lt;/p&gt;
&lt;h2 id=&quot;core-idea&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Core Idea&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#core-idea&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;Transforming an I/O request into hardware operation is a multi-step process where the request flows down through I/O software layers, gets translated into hardware commands, executes on the device, and returns data via interrupts.&lt;/p&gt;
&lt;h2 id=&quot;how-it-works&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;How It Works&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#how-it-works&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ol dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Application&lt;/strong&gt; calls &lt;code class=&quot;notranslate&quot;&gt;fopen(&quot;data.txt&quot;, &quot;r&quot;)&lt;/code&gt; or &lt;code class=&quot;notranslate&quot;&gt;read(fd, buf, size)&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;OS&lt;/strong&gt; checks file permissions, locates file on disk, allocates buffer&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Device-Independent Layer&lt;/strong&gt; determines which device and driver to use, handles buffering&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Device Driver&lt;/strong&gt; translates “read sector 120” into register writes for the disk controller&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Device Controller&lt;/strong&gt; executes: seeks to track, waits for sector, reads data&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Interrupt&lt;/strong&gt; signals completion; CPU processes interrupt, copies data to user buffer&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Application&lt;/strong&gt; resumes with data available&lt;/li&gt;
&lt;/ol&gt;
&lt;div class=&quot;graphviz-container&quot; style=&quot;display: flex; justify-content: center; margin: 1.5rem 0; overflow-x: auto;&quot; dir=&quot;auto&quot;&gt;&lt;!--?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?--&gt;

&lt;!-- Generated by graphviz version 15.1.0 (0)
 --&gt;
&lt;!-- Title: io_flow Pages: 1 --&gt;
&lt;svg width=&quot;188pt&quot; height=&quot;537pt&quot; viewBox=&quot;0.00 0.00 188.00 537.00&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; xmlns:xlink=&quot;http://www.w3.org/1999/xlink&quot;&gt;
&lt;g id=&quot;graph0&quot; class=&quot;graph&quot; transform=&quot;scale(1 1) rotate(0) translate(4 533)&quot;&gt;
&lt;title&gt;io_flow&lt;/title&gt;
&lt;polygon fill=&quot;white&quot; stroke=&quot;none&quot; points=&quot;-4,4 -4,-533 183.64,-533 183.64,4 -4,4&quot;&gt;&lt;/polygon&gt;
&lt;!-- App --&gt;
&lt;g id=&quot;node1&quot; class=&quot;node&quot;&gt;
&lt;title&gt;App&lt;/title&gt;
&lt;polygon fill=&quot;lightyellow&quot; stroke=&quot;black&quot; points=&quot;144.07,-529 35.56,-529 35.56,-487.4 144.07,-487.4 144.07,-529&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;89.82&quot; y=&quot;-512.4&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;1. Application&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;89.82&quot; y=&quot;-495.6&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;fopen/read/write&lt;/text&gt;
&lt;/g&gt;
&lt;!-- OS --&gt;
&lt;g id=&quot;node2&quot; class=&quot;node&quot;&gt;
&lt;title&gt;OS&lt;/title&gt;
&lt;polygon fill=&quot;lightblue&quot; stroke=&quot;black&quot; points=&quot;165.29,-450.4 14.35,-450.4 14.35,-408.8 165.29,-408.8 165.29,-450.4&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;89.82&quot; y=&quot;-433.8&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;2. OS Checks&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;89.82&quot; y=&quot;-417&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;permissions, file lookup&lt;/text&gt;
&lt;/g&gt;
&lt;!-- App&amp;#45;&amp;gt;OS --&gt;
&lt;g id=&quot;edge1&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;App-&gt;OS&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M89.82,-487.07C89.82,-479.48 89.82,-470.65 89.82,-462.26&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;93.32,-462.37 89.82,-452.37 86.32,-462.37 93.32,-462.37&quot;&gt;&lt;/polygon&gt;
&lt;/g&gt;
&lt;!-- Indep --&gt;
&lt;g id=&quot;node3&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Indep&lt;/title&gt;
&lt;polygon fill=&quot;lightcyan&quot; stroke=&quot;black&quot; points=&quot;179.64,-371.8 0,-371.8 0,-330.2 179.64,-330.2 179.64,-371.8&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;89.82&quot; y=&quot;-355.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;3. Device-Independent Layer&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;89.82&quot; y=&quot;-338.4&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;buffering, device selection&lt;/text&gt;
&lt;/g&gt;
&lt;!-- OS&amp;#45;&amp;gt;Indep --&gt;
&lt;g id=&quot;edge2&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;OS-&gt;Indep&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M89.82,-408.47C89.82,-400.88 89.82,-392.05 89.82,-383.66&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;93.32,-383.77 89.82,-373.77 86.32,-383.77 93.32,-383.77&quot;&gt;&lt;/polygon&gt;
&lt;/g&gt;
&lt;!-- Driver --&gt;
&lt;g id=&quot;node4&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Driver&lt;/title&gt;
&lt;polygon fill=&quot;lightgreen&quot; stroke=&quot;black&quot; points=&quot;174.21,-293.2 5.42,-293.2 5.42,-251.6 174.21,-251.6 174.21,-293.2&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;89.82&quot; y=&quot;-276.6&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;4. Device Driver&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;89.82&quot; y=&quot;-259.8&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;translate to HW commands&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Indep&amp;#45;&amp;gt;Driver --&gt;
&lt;g id=&quot;edge3&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Indep-&gt;Driver&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M89.82,-329.87C89.82,-322.28 89.82,-313.45 89.82,-305.06&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;93.32,-305.17 89.82,-295.17 86.32,-305.17 93.32,-305.17&quot;&gt;&lt;/polygon&gt;
&lt;/g&gt;
&lt;!-- Ctrl --&gt;
&lt;g id=&quot;node5&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Ctrl&lt;/title&gt;
&lt;polygon fill=&quot;orange&quot; stroke=&quot;black&quot; points=&quot;155.73,-214.6 23.91,-214.6 23.91,-173 155.73,-173 155.73,-214.6&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;89.82&quot; y=&quot;-198&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;5. Device Controller&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;89.82&quot; y=&quot;-181.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;execute on hardware&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Driver&amp;#45;&amp;gt;Ctrl --&gt;
&lt;g id=&quot;edge4&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Driver-&gt;Ctrl&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M89.82,-251.27C89.82,-243.68 89.82,-234.85 89.82,-226.46&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;93.32,-226.57 89.82,-216.57 86.32,-226.57 93.32,-226.57&quot;&gt;&lt;/polygon&gt;
&lt;/g&gt;
&lt;!-- Int --&gt;
&lt;g id=&quot;node6&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Int&lt;/title&gt;
&lt;polygon fill=&quot;salmon&quot; stroke=&quot;black&quot; points=&quot;153.6,-120.2 26.03,-120.2 26.03,-78.6 153.6,-78.6 153.6,-120.2&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;89.82&quot; y=&quot;-103.6&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;6. Interrupt Handler&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;89.82&quot; y=&quot;-86.8&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;process completion&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Ctrl&amp;#45;&amp;gt;Int --&gt;
&lt;g id=&quot;edge5&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Ctrl-&gt;Int&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; stroke-dasharray=&quot;5 2&quot; d=&quot;M89.82,-172.75C89.82,-160.76 89.82,-145.27 89.82,-131.7&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;93.32,-131.92 89.82,-121.92 86.32,-131.92 93.32,-131.92&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;113.92&quot; y=&quot;-142.4&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;interrupt&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Done --&gt;
&lt;g id=&quot;node7&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Done&lt;/title&gt;
&lt;polygon fill=&quot;lightyellow&quot; stroke=&quot;black&quot; points=&quot;161.2,-41.6 18.44,-41.6 18.44,0 161.2,0 161.2,-41.6&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;89.82&quot; y=&quot;-25&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;7. Back to Application&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;89.82&quot; y=&quot;-8.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;data available&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Int&amp;#45;&amp;gt;Done --&gt;
&lt;g id=&quot;edge6&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Int-&gt;Done&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; stroke-dasharray=&quot;5 2&quot; d=&quot;M89.82,-78.27C89.82,-70.68 89.82,-61.85 89.82,-53.46&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;93.32,-53.57 89.82,-43.57 86.32,-53.57 93.32,-53.57&quot;&gt;&lt;/polygon&gt;
&lt;/g&gt;
&lt;/g&gt;
&lt;/svg&gt;
&lt;/div&gt;
&lt;h2 id=&quot;key-properties&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Key Properties&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#key-properties&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;Each step adds appropriate abstraction or translation&lt;/li&gt;
&lt;li&gt;DMA can bypass CPU involvement in data transfer (steps 5-6)&lt;/li&gt;
&lt;li&gt;The process is asynchronous — application may block until interrupt arrives&lt;/li&gt;
&lt;li&gt;File system layer maps logical file operations to physical disk blocks&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;connections&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Connections&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#connections&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Built from:&lt;/strong&gt; &lt;a href=&quot;../../io-system&quot; class=&quot;internal alias&quot; data-slug=&quot;io-system&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;O System&lt;/a&gt;, &lt;a href=&quot;../../device-driver&quot; class=&quot;internal alias&quot; data-slug=&quot;device-driver&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Device Driver&lt;/a&gt;, &lt;a href=&quot;../../device-controller&quot; class=&quot;internal alias&quot; data-slug=&quot;device-controller&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Device Controller&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Builds into:&lt;/strong&gt; &lt;a href=&quot;../../dma&quot; class=&quot;internal alias&quot; data-slug=&quot;dma&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;DMA&lt;/a&gt;, &lt;a href=&quot;../../interrupt-handler&quot; class=&quot;internal alias&quot; data-slug=&quot;interrupt-handler&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Interrupt Handler&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../io-software-structure&quot; class=&quot;internal alias&quot; data-slug=&quot;io-software-structure&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;O Software Structure&lt;/a&gt;, &lt;a href=&quot;../../polling&quot; class=&quot;internal alias&quot; data-slug=&quot;polling&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Polling&lt;/a&gt;, &lt;a href=&quot;../../system-bus&quot; class=&quot;internal alias&quot; data-slug=&quot;system-bus&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;System Bus&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Contrasts with:&lt;/strong&gt; &lt;a href=&quot;../../user-level-io-software&quot; class=&quot;internal alias&quot; data-slug=&quot;user-level-io-software&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;O Software&lt;/a&gt; (only handles step 1)&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;edge-cases--gotchas&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Edge Cases &amp;#x26; Gotchas&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#edge-cases--gotchas&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;Page fault can occur during copy to user buffer, complicating the flow&lt;/li&gt;
&lt;li&gt;Disk may return errors (bad sector) that must be handled at each layer&lt;/li&gt;
&lt;li&gt;Concurrent I/O requests require proper queue management&lt;/li&gt;
&lt;li&gt;DMA setup failure falls back to programmed I/O (very slow)&lt;/li&gt;
&lt;/ul&gt;</content>
  </entry><entry>
    <title>io-software-structure</title>
    <link href="https://animishraa05.github.io/wiki/io/io-software-structure" />
    <link rel="alternate" type="text/markdown" href="https://animishraa05.github.io/wiki/io/io-software-structure.md" />
    <summary>The Problem I/O operations involve many concerns: buffering, error handling, device-specific commands, interrupt processing.</summary>
    <published>2026-04-30T00:00:00.000Z</published>
    <updated>2026-04-30T00:00:00.000Z</updated>
    <publishedTime>Apr 30, 2026</publishedTime>
    <updatedTime>Apr 30, 2026</updatedTime>
    <category term="systems" label="systems" />
<category term="io" label="io" />
    <author>
      <name>Animesh Mishra</name>
      <email>animesh.mishra818@gmail.com</email>
    </author>
    <content type="html">&lt;h2 id=&quot;the-problem&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;The Problem&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#the-problem&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;I/O operations involve many concerns: buffering, error handling, device-specific commands, interrupt processing. Putting all this in one place creates unmaintainable code and makes the OS dependent on hardware details.&lt;/p&gt;
&lt;h2 id=&quot;core-idea&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Core Idea&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#core-idea&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;I/O software is organized into four layers, each handling a specific abstraction level — from user-facing system calls down to hardware interrupt handling.&lt;/p&gt;
&lt;h2 id=&quot;how-it-works&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;How It Works&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#how-it-works&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;The four layers (top to bottom):&lt;/p&gt;
&lt;ol dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;User-Level I/O Software&lt;/strong&gt;: System calls (&lt;code class=&quot;notranslate&quot;&gt;read()&lt;/code&gt;, &lt;code class=&quot;notranslate&quot;&gt;write()&lt;/code&gt;, &lt;code class=&quot;notranslate&quot;&gt;fopen()&lt;/code&gt;), buffering in user space&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Device-Independent OS Software&lt;/strong&gt;: Naming, protection, buffering, caching, error reporting&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Device Drivers&lt;/strong&gt;: Translate generic requests to device-specific commands&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Interrupt Handlers&lt;/strong&gt;: Process device interrupts and signal completion&lt;/li&gt;
&lt;/ol&gt;
&lt;div class=&quot;graphviz-container&quot; style=&quot;display: flex; justify-content: center; margin: 1.5rem 0; overflow-x: auto;&quot; dir=&quot;auto&quot;&gt;&lt;!--?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?--&gt;

&lt;!-- Generated by graphviz version 15.1.0 (0)
 --&gt;
&lt;!-- Title: io_layers Pages: 1 --&gt;
&lt;svg width=&quot;332pt&quot; height=&quot;427pt&quot; viewBox=&quot;0.00 0.00 332.00 427.00&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; xmlns:xlink=&quot;http://www.w3.org/1999/xlink&quot;&gt;
&lt;g id=&quot;graph0&quot; class=&quot;graph&quot; transform=&quot;scale(1 1) rotate(0) translate(4 423.2)&quot;&gt;
&lt;title&gt;io_layers&lt;/title&gt;
&lt;polygon fill=&quot;white&quot; stroke=&quot;none&quot; points=&quot;-4,4 -4,-423.2 327.96,-423.2 327.96,4 -4,4&quot;&gt;&lt;/polygon&gt;
&lt;!-- User --&gt;
&lt;g id=&quot;node1&quot; class=&quot;node&quot;&gt;
&lt;title&gt;User&lt;/title&gt;
&lt;polygon fill=&quot;lightyellow&quot; stroke=&quot;black&quot; points=&quot;247.73,-419.2 89.81,-419.2 89.81,-377.6 247.73,-377.6 247.73,-419.2&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;168.77&quot; y=&quot;-402.6&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;User-Level I/O Software&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;168.77&quot; y=&quot;-385.8&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;system calls, fopen/printf&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Indep --&gt;
&lt;g id=&quot;node2&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Indep&lt;/title&gt;
&lt;polygon fill=&quot;lightblue&quot; stroke=&quot;black&quot; points=&quot;205.24,-324.8 0.31,-324.8 0.31,-283.2 205.24,-283.2 205.24,-324.8&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;102.77&quot; y=&quot;-308.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Device-Independent OS Software&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;102.77&quot; y=&quot;-291.4&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;buffering, naming, error handling&lt;/text&gt;
&lt;/g&gt;
&lt;!-- User&amp;#45;&amp;gt;Indep --&gt;
&lt;g id=&quot;edge1&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;User-&gt;Indep&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M154.45,-377.35C145.46,-364.76 133.7,-348.3 123.67,-334.26&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;126.6,-332.34 117.94,-326.24 120.91,-336.41 126.6,-332.34&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;172.98&quot; y=&quot;-347&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;system call&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Driver --&gt;
&lt;g id=&quot;node3&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Driver&lt;/title&gt;
&lt;polygon fill=&quot;lightgreen&quot; stroke=&quot;black&quot; points=&quot;197.54,-230.4 0,-230.4 0,-188.8 197.54,-188.8 197.54,-230.4&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;98.77&quot; y=&quot;-213.8&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Device Drivers&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;98.77&quot; y=&quot;-197&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;translate to hardware commands&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Indep&amp;#45;&amp;gt;Driver --&gt;
&lt;g id=&quot;edge2&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Indep-&gt;Driver&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M101.9,-282.95C101.38,-270.96 100.71,-255.47 100.13,-241.9&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;103.63,-241.96 99.7,-232.12 96.64,-242.26 103.63,-241.96&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;154.77&quot; y=&quot;-252.6&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;generic I/O request&lt;/text&gt;
&lt;/g&gt;
&lt;!-- HW --&gt;
&lt;g id=&quot;node5&quot; class=&quot;node&quot;&gt;
&lt;title&gt;HW&lt;/title&gt;
&lt;polygon fill=&quot;lightgray&quot; stroke=&quot;black&quot; points=&quot;173.84,-136 93.7,-136 93.7,-94.4 173.84,-94.4 173.84,-136&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;133.77&quot; y=&quot;-119.4&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Hardware&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;133.77&quot; y=&quot;-102.6&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;I/O devices&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Driver&amp;#45;&amp;gt;HW --&gt;
&lt;g id=&quot;edge3&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Driver-&gt;HW&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M97.77,-188.5C97.92,-177.89 99.19,-164.87 103.54,-154 104.67,-151.17 106.09,-148.39 107.69,-145.69&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;110.45,-147.85 113.24,-137.63 104.68,-143.88 110.45,-147.85&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;161.66&quot; y=&quot;-158.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;hardware commands&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Int --&gt;
&lt;g id=&quot;node4&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Int&lt;/title&gt;
&lt;polygon fill=&quot;orange&quot; stroke=&quot;black&quot; points=&quot;267.2,-41.6 100.34,-41.6 100.34,0 267.2,0 267.2,-41.6&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;183.77&quot; y=&quot;-25&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Interrupt Handlers&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;183.77&quot; y=&quot;-8.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;process completion signals&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Int&amp;#45;&amp;gt;User --&gt;
&lt;g id=&quot;edge5&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Int-&gt;User&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; stroke-dasharray=&quot;5 2&quot; d=&quot;M203.25,-41.92C207.8,-47.36 212.33,-53.45 215.77,-59.6 228.26,-81.89 233.77,-88.65 233.77,-114.2 233.77,-305 233.77,-305 233.77,-305 233.77,-329.95 217.73,-352.91 201.58,-369.71&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;199.47,-366.87 194.8,-376.38 204.38,-371.86 199.47,-366.87&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;278.87&quot; y=&quot;-205.4&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;data/completion&lt;/text&gt;
&lt;/g&gt;
&lt;!-- HW&amp;#45;&amp;gt;Int --&gt;
&lt;g id=&quot;edge4&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;HW-&gt;Int&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; stroke-dasharray=&quot;5 2&quot; d=&quot;M144.62,-94.15C151.3,-81.8 160,-65.73 167.5,-51.88&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;170.54,-53.6 172.22,-43.14 164.39,-50.27 170.54,-53.6&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;187.35&quot; y=&quot;-63.8&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;interrupt&lt;/text&gt;
&lt;/g&gt;
&lt;/g&gt;
&lt;/svg&gt;
&lt;/div&gt;
&lt;h2 id=&quot;key-properties&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Key Properties&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#key-properties&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;Each layer only communicates with adjacent layers&lt;/li&gt;
&lt;li&gt;Device-independent layer makes all devices look uniform to applications&lt;/li&gt;
&lt;li&gt;Drivers can be loaded/unloaded without changing the OS&lt;/li&gt;
&lt;li&gt;Modularity enables portability across hardware platforms&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;connections&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Connections&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#connections&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Built from:&lt;/strong&gt; &lt;a href=&quot;../../io-system&quot; class=&quot;internal alias&quot; data-slug=&quot;io-system&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;O System&lt;/a&gt;, &lt;a href=&quot;../../user-level-io-software&quot; class=&quot;internal alias&quot; data-slug=&quot;user-level-io-software&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;O Software&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Builds into:&lt;/strong&gt; &lt;a href=&quot;../../io-request-to-hardware&quot; class=&quot;internal alias&quot; data-slug=&quot;io-request-to-hardware&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;O Request to Hardware Operation&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../device-driver&quot; class=&quot;internal alias&quot; data-slug=&quot;device-driver&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Device Driver&lt;/a&gt;, &lt;a href=&quot;../../interrupt-handler&quot; class=&quot;internal alias&quot; data-slug=&quot;interrupt-handler&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Interrupt Handler&lt;/a&gt;, &lt;a href=&quot;../../device-independent-io-software&quot; class=&quot;internal alias&quot; data-slug=&quot;device-independent-io-software&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;O Software&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Contrasts with:&lt;/strong&gt; &lt;a href=&quot;../../device-controller&quot; class=&quot;internal alias&quot; data-slug=&quot;device-controller&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Device Controller&lt;/a&gt; (hardware, not software)&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;edge-cases--gotchas&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Edge Cases &amp;#x26; Gotchas&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#edge-cases--gotchas&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;Too many layers can impact performance due to context switches&lt;/li&gt;
&lt;li&gt;Device-independent layer must know enough about devices to do buffering correctly&lt;/li&gt;
&lt;li&gt;Error handling must propagate correctly up through all layers&lt;/li&gt;
&lt;li&gt;Some devices bypass layers (e.g., memory-mapped I/O)&lt;/li&gt;
&lt;/ul&gt;</content>
  </entry><entry>
    <title>io-system</title>
    <link href="https://animishraa05.github.io/wiki/io/io-system" />
    <link rel="alternate" type="text/markdown" href="https://animishraa05.github.io/wiki/io/io-system.md" />
    <summary>The Problem The CPU needs to communicate with external hardware devices (keyboards, disks, printers, network cards), but each device speaks a different “language” with different speeds, data formats, and control mechanisms.</summary>
    <published>2026-04-30T00:00:00.000Z</published>
    <updated>2026-04-30T00:00:00.000Z</updated>
    <publishedTime>Apr 30, 2026</publishedTime>
    <updatedTime>Apr 30, 2026</updatedTime>
    <category term="systems" label="systems" />
<category term="io" label="io" />
    <author>
      <name>Animesh Mishra</name>
      <email>animesh.mishra818@gmail.com</email>
    </author>
    <content type="html">&lt;h2 id=&quot;the-problem&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;The Problem&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#the-problem&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;The CPU needs to communicate with external hardware devices (keyboards, disks, printers, network cards), but each device speaks a different “language” with different speeds, data formats, and control mechanisms. Without a unified system, every program would need device-specific code.&lt;/p&gt;
&lt;h2 id=&quot;core-idea&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Core Idea&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#core-idea&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;The I/O System is the OS subsystem that manages communication between the CPU and external devices, providing abstraction layers so applications can perform I/O without knowing hardware details.&lt;/p&gt;
&lt;h2 id=&quot;how-it-works&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;How It Works&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#how-it-works&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ol dir=&quot;auto&quot;&gt;
&lt;li&gt;Applications make I/O requests via system calls (&lt;code class=&quot;notranslate&quot;&gt;read()&lt;/code&gt;, &lt;code class=&quot;notranslate&quot;&gt;write()&lt;/code&gt;, &lt;code class=&quot;notranslate&quot;&gt;open()&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;The request flows through layered I/O software (user-level → device-independent → device driver → interrupt handler)&lt;/li&gt;
&lt;li&gt;The device driver translates generic OS commands into device-specific instructions&lt;/li&gt;
&lt;li&gt;The device controller executes the operation on the physical hardware&lt;/li&gt;
&lt;li&gt;Completion is signaled via interrupt, and data is returned to the application&lt;/li&gt;
&lt;/ol&gt;
&lt;div class=&quot;graphviz-container&quot; style=&quot;display: flex; justify-content: center; margin: 1.5rem 0; overflow-x: auto;&quot; dir=&quot;auto&quot;&gt;&lt;!--?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?--&gt;

&lt;!-- Generated by graphviz version 15.1.0 (0)
 --&gt;
&lt;!-- Title: io_system Pages: 1 --&gt;
&lt;svg width=&quot;345pt&quot; height=&quot;522pt&quot; viewBox=&quot;0.00 0.00 345.00 522.00&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; xmlns:xlink=&quot;http://www.w3.org/1999/xlink&quot;&gt;
&lt;g id=&quot;graph0&quot; class=&quot;graph&quot; transform=&quot;scale(1 1) rotate(0) translate(4 517.6)&quot;&gt;
&lt;title&gt;io_system&lt;/title&gt;
&lt;polygon fill=&quot;white&quot; stroke=&quot;none&quot; points=&quot;-4,4 -4,-517.6 341.44,-517.6 341.44,4 -4,4&quot;&gt;&lt;/polygon&gt;
&lt;!-- App --&gt;
&lt;g id=&quot;node1&quot; class=&quot;node&quot;&gt;
&lt;title&gt;App&lt;/title&gt;
&lt;polygon fill=&quot;lightblue&quot; stroke=&quot;black&quot; points=&quot;265.8,-513.6 177.11,-513.6 177.11,-472 265.8,-472 265.8,-513.6&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;221.46&quot; y=&quot;-497&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Application&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;221.46&quot; y=&quot;-480.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;(User Space)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- UserIO --&gt;
&lt;g id=&quot;node2&quot; class=&quot;node&quot;&gt;
&lt;title&gt;UserIO&lt;/title&gt;
&lt;polygon fill=&quot;lightblue&quot; stroke=&quot;black&quot; points=&quot;220.02,-419.2 118.89,-419.2 118.89,-377.6 220.02,-377.6 220.02,-419.2&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;169.46&quot; y=&quot;-402.6&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;User-Level I/O&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;169.46&quot; y=&quot;-385.8&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;System Calls&lt;/text&gt;
&lt;/g&gt;
&lt;!-- App&amp;#45;&amp;gt;UserIO --&gt;
&lt;g id=&quot;edge1&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;App-&gt;UserIO&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M187.6,-471.87C181.64,-466.81 176.21,-460.83 172.61,-454 168.96,-447.08 167.34,-438.97 166.81,-431.14&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;170.31,-431.16 166.74,-421.18 163.31,-431.21 170.31,-431.16&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;216.53&quot; y=&quot;-441.4&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;read/write/open&lt;/text&gt;
&lt;/g&gt;
&lt;!-- DevIndep --&gt;
&lt;g id=&quot;node3&quot; class=&quot;node&quot;&gt;
&lt;title&gt;DevIndep&lt;/title&gt;
&lt;polygon fill=&quot;lightblue&quot; stroke=&quot;black&quot; points=&quot;226.2,-324.8 96.71,-324.8 96.71,-283.2 226.2,-283.2 226.2,-324.8&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;161.46&quot; y=&quot;-308.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Device-Independent&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;161.46&quot; y=&quot;-291.4&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;I/O Software&lt;/text&gt;
&lt;/g&gt;
&lt;!-- UserIO&amp;#45;&amp;gt;DevIndep --&gt;
&lt;g id=&quot;edge2&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;UserIO-&gt;DevIndep&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M167.72,-377.35C166.68,-365.36 165.34,-349.87 164.17,-336.3&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;167.67,-336.18 163.32,-326.52 160.69,-336.78 167.67,-336.18&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;208.73&quot; y=&quot;-347&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;generic request&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Driver --&gt;
&lt;g id=&quot;node4&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Driver&lt;/title&gt;
&lt;polygon fill=&quot;lightblue&quot; stroke=&quot;black&quot; points=&quot;196.3,-230.4 100.62,-230.4 100.62,-188.8 196.3,-188.8 196.3,-230.4&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;148.46&quot; y=&quot;-213.8&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Device Driver&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;148.46&quot; y=&quot;-197&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;(Per Device)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- DevIndep&amp;#45;&amp;gt;Driver --&gt;
&lt;g id=&quot;edge3&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;DevIndep-&gt;Driver&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M158.63,-282.95C156.95,-270.96 154.77,-255.47 152.86,-241.9&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;156.34,-241.52 151.48,-232.11 149.41,-242.5 156.34,-241.52&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;201.79&quot; y=&quot;-252.6&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;buffered request&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Controller --&gt;
&lt;g id=&quot;node6&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Controller&lt;/title&gt;
&lt;polygon fill=&quot;lightblue&quot; stroke=&quot;black&quot; points=&quot;169.23,-136 95.68,-136 95.68,-94.4 169.23,-94.4 169.23,-136&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;132.46&quot; y=&quot;-119.4&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Device&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;132.46&quot; y=&quot;-102.6&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Controller&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Driver&amp;#45;&amp;gt;Controller --&gt;
&lt;g id=&quot;edge4&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Driver-&gt;Controller&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M144.98,-188.55C142.91,-176.56 140.23,-161.07 137.88,-147.5&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;141.33,-146.96 136.18,-137.7 134.44,-148.15 141.33,-146.96&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;200&quot; y=&quot;-158.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;hardware commands&lt;/text&gt;
&lt;/g&gt;
&lt;!-- IntHandler --&gt;
&lt;g id=&quot;node5&quot; class=&quot;node&quot;&gt;
&lt;title&gt;IntHandler&lt;/title&gt;
&lt;polygon fill=&quot;lightblue&quot; stroke=&quot;black&quot; points=&quot;274.95,-41.6 209.97,-41.6 209.97,0 274.95,0 274.95,-41.6&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;242.46&quot; y=&quot;-25&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Interrupt&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;242.46&quot; y=&quot;-8.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Handler&lt;/text&gt;
&lt;/g&gt;
&lt;!-- IntHandler&amp;#45;&amp;gt;App --&gt;
&lt;g id=&quot;edge8&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;IntHandler-&gt;App&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; stroke-dasharray=&quot;5 2&quot; d=&quot;M253.83,-42.02C263.03,-60.29 274.46,-88.23 274.46,-114.2 274.46,-399.4 274.46,-399.4 274.46,-399.4 274.46,-424.45 273.03,-432.33 260.46,-454 258.61,-457.18 256.42,-460.27 254.04,-463.22&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;251.57,-460.73 247.46,-470.49 256.76,-465.42 251.57,-460.73&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;305.95&quot; y=&quot;-252.6&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;completion&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Controller&amp;#45;&amp;gt;IntHandler --&gt;
&lt;g id=&quot;edge7&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Controller-&gt;IntHandler&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; stroke-dasharray=&quot;5 2&quot; d=&quot;M157.96,-93.97C164.97,-88.33 172.54,-82.17 179.46,-76.4 189.85,-67.72 201.07,-58.09 211.11,-49.36&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;213.21,-52.18 218.45,-42.97 208.61,-46.9 213.21,-52.18&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;222.79&quot; y=&quot;-63.8&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;interrupt&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Device --&gt;
&lt;g id=&quot;node7&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Device&lt;/title&gt;
&lt;polygon fill=&quot;lightblue&quot; stroke=&quot;black&quot; points=&quot;133.71,-41.6 53.2,-41.6 53.2,0 133.71,0 133.71,-41.6&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;93.46&quot; y=&quot;-25&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;I/O Device&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;93.46&quot; y=&quot;-8.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;(Hardware)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Controller&amp;#45;&amp;gt;Device --&gt;
&lt;g id=&quot;edge5&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Controller-&gt;Device&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M95.19,-114.43C65.35,-112.38 25.17,-104.15 4.43,-76.4 -10.09,-56.98 14.86,-42.95 42.01,-33.97&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;42.85,-37.38 51.4,-31.11 40.81,-30.68 42.85,-37.38&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;55.94&quot; y=&quot;-63.8&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;physical operation&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Device&amp;#45;&amp;gt;Controller --&gt;
&lt;g id=&quot;edge6&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Device-&gt;Controller&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; stroke-dasharray=&quot;5 2&quot; d=&quot;M101.9,-41.81C107.06,-54.03 113.76,-69.9 119.57,-83.67&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;116.29,-84.9 123.4,-92.76 122.74,-82.18 116.29,-84.9&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;146&quot; y=&quot;-63.8&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;data/status&lt;/text&gt;
&lt;/g&gt;
&lt;/g&gt;
&lt;/svg&gt;
&lt;/div&gt;
&lt;h2 id=&quot;key-properties&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Key Properties&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#key-properties&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;Provides uniform interface to diverse hardware through abstraction layers&lt;/li&gt;
&lt;li&gt;Handles buffering, caching, and error reporting at device-independent layer&lt;/li&gt;
&lt;li&gt;Uses interrupts to avoid CPU busy-waiting&lt;/li&gt;
&lt;li&gt;Supports multiple I/O techniques: polling, interrupt-driven, DMA&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;connections&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Connections&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#connections&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Built from:&lt;/strong&gt; &lt;a href=&quot;../../system-bus&quot; class=&quot;internal alias&quot; data-slug=&quot;system-bus&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;System Bus&lt;/a&gt;, &lt;a href=&quot;../../device-driver&quot; class=&quot;internal alias&quot; data-slug=&quot;device-driver&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Device Driver&lt;/a&gt;, &lt;a href=&quot;../../interrupt-handler&quot; class=&quot;internal alias&quot; data-slug=&quot;interrupt-handler&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Interrupt Handler&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Builds into:&lt;/strong&gt; &lt;a href=&quot;../../io-request-to-hardware&quot; class=&quot;internal alias&quot; data-slug=&quot;io-request-to-hardware&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;O Request to Hardware Operation&lt;/a&gt;, &lt;a href=&quot;../../io-software-structure&quot; class=&quot;internal alias&quot; data-slug=&quot;io-software-structure&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;O Software Structure&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../device-controller&quot; class=&quot;internal alias&quot; data-slug=&quot;device-controller&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Device Controller&lt;/a&gt;, &lt;a href=&quot;../../dma&quot; class=&quot;internal alias&quot; data-slug=&quot;dma&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;DMA&lt;/a&gt;, &lt;a href=&quot;../../polling&quot; class=&quot;internal alias&quot; data-slug=&quot;polling&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Polling&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Contrasts with:&lt;/strong&gt; &lt;a href=&quot;../../user-level-io-software&quot; class=&quot;internal alias&quot; data-slug=&quot;user-level-io-software&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;O Software&lt;/a&gt; (one layer in the system)&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;edge-cases--gotchas&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Edge Cases &amp;#x26; Gotchas&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#edge-cases--gotchas&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;Device drivers run in kernel mode — a buggy driver can crash the entire OS&lt;/li&gt;
&lt;li&gt;Interrupt storms can overwhelm the CPU if devices generate too many interrupts&lt;/li&gt;
&lt;li&gt;Some devices don’t support interrupts and require polling&lt;/li&gt;
&lt;li&gt;DMA conflicts can occur if the DMA controller isn’t properly programmed&lt;/li&gt;
&lt;/ul&gt;</content>
  </entry><entry>
    <title>linear-probing</title>
    <link href="https://animishraa05.github.io/wiki/io/linear-probing" />
    <link rel="alternate" type="text/markdown" href="https://animishraa05.github.io/wiki/io/linear-probing.md" />
    <summary>The Problem In separate chaining, we need extra memory for linked lists.</summary>
    <published>2026-04-30T00:00:00.000Z</published>
    <updated>2026-04-30T00:00:00.000Z</updated>
    <publishedTime>Apr 30, 2026</publishedTime>
    <updatedTime>Apr 30, 2026</updatedTime>
    <category term="systems" label="systems" />
<category term="data-structures" label="data-structures" />
    <author>
      <name>Animesh Mishra</name>
      <email>animesh.mishra818@gmail.com</email>
    </author>
    <content type="html">&lt;h2 id=&quot;the-problem&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;The Problem&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#the-problem&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;In separate chaining, we need extra memory for linked lists. Can we store everything in the hash table array itself by finding the next empty slot?&lt;/p&gt;
&lt;h2 id=&quot;core-idea&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Core Idea&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#core-idea&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;On collision, linear probing checks the next slot (index+1, +2, …) until an empty slot is found, wrapping around to the beginning if needed.&lt;/p&gt;
&lt;h2 id=&quot;how-it-works&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;How It Works&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#how-it-works&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ol dir=&quot;auto&quot;&gt;
&lt;li&gt;Hash key to get initial index&lt;/li&gt;
&lt;li&gt;If slot is empty, insert there&lt;/li&gt;
&lt;li&gt;If occupied, check next slot (index+1)&lt;/li&gt;
&lt;li&gt;Continue until empty slot found (wrap around if needed)&lt;/li&gt;
&lt;li&gt;Search: check slots sequentially until key found or empty slot&lt;/li&gt;
&lt;/ol&gt;
&lt;div class=&quot;graphviz-container&quot; style=&quot;display: flex; justify-content: center; margin: 1.5rem 0; overflow-x: auto;&quot; dir=&quot;auto&quot;&gt;&lt;!--?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?--&gt;

&lt;!-- Generated by graphviz version 15.1.0 (0)
 --&gt;
&lt;!-- Title: linear_probe Pages: 1 --&gt;
&lt;svg width=&quot;729pt&quot; height=&quot;44pt&quot; viewBox=&quot;0.00 0.00 729.00 44.00&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; xmlns:xlink=&quot;http://www.w3.org/1999/xlink&quot;&gt;
&lt;g id=&quot;graph0&quot; class=&quot;graph&quot; transform=&quot;scale(1 1) rotate(0) translate(4 40)&quot;&gt;
&lt;title&gt;linear_probe&lt;/title&gt;
&lt;polygon fill=&quot;white&quot; stroke=&quot;none&quot; points=&quot;-4,4 -4,-40 725.29,-40 725.29,4 -4,4&quot;&gt;&lt;/polygon&gt;
&lt;!-- T --&gt;
&lt;g id=&quot;node1&quot; class=&quot;node&quot;&gt;
&lt;title&gt;T&lt;/title&gt;
&lt;polygon fill=&quot;lightgray&quot; stroke=&quot;black&quot; points=&quot;80.14,-36 0,-36 0,0 80.14,0 80.14,-36&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;40.07&quot; y=&quot;-13.8&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Hash Table&lt;/text&gt;
&lt;/g&gt;
&lt;!-- S0 --&gt;
&lt;g id=&quot;node2&quot; class=&quot;node&quot;&gt;
&lt;title&gt;S0&lt;/title&gt;
&lt;polygon fill=&quot;lightyellow&quot; stroke=&quot;black&quot; points=&quot;263.53,-36 202.82,-36 202.82,0 263.53,0 263.53,-36&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;233.17&quot; y=&quot;-13.8&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;3: Alice&lt;/text&gt;
&lt;/g&gt;
&lt;!-- T&amp;#45;&amp;gt;S0 --&gt;
&lt;g id=&quot;edge1&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;T-&gt;S0&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M80.2,-18C112.49,-18 158.17,-18 191.01,-18&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;190.96,-21.5 200.96,-18 190.96,-14.5 190.96,-21.5&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;141.48&quot; y=&quot;-22.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;probe sequence&lt;/text&gt;
&lt;/g&gt;
&lt;!-- S1 --&gt;
&lt;g id=&quot;node3&quot; class=&quot;node&quot;&gt;
&lt;title&gt;S1&lt;/title&gt;
&lt;polygon fill=&quot;lightgreen&quot; stroke=&quot;black&quot; points=&quot;523.9,-36 386.21,-36 386.21,0 523.9,0 523.9,-36&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;455.05&quot; y=&quot;-13.8&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;4: Bob ← probed here&lt;/text&gt;
&lt;/g&gt;
&lt;!-- S0&amp;#45;&amp;gt;S1 --&gt;
&lt;g id=&quot;edge2&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;S0-&gt;S1&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M263.83,-18C292.21,-18 336.28,-18 374.86,-18&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;374.59,-21.5 384.59,-18 374.59,-14.5 374.59,-21.5&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;324.87&quot; y=&quot;-22.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;probe sequence&lt;/text&gt;
&lt;/g&gt;
&lt;!-- S2 --&gt;
&lt;g id=&quot;node4&quot; class=&quot;node&quot;&gt;
&lt;title&gt;S2&lt;/title&gt;
&lt;polygon fill=&quot;white&quot; stroke=&quot;black&quot; points=&quot;721.29,-36 646.58,-36 646.58,0 721.29,0 721.29,-36&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;683.93&quot; y=&quot;-13.8&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;5: (empty)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- S1&amp;#45;&amp;gt;S2 --&gt;
&lt;g id=&quot;edge3&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;S1-&gt;S2&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M524.13,-18C559.81,-18 602.68,-18 634.87,-18&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;634.7,-21.5 644.7,-18 634.7,-14.5 634.7,-21.5&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;585.24&quot; y=&quot;-22.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;probe sequence&lt;/text&gt;
&lt;/g&gt;
&lt;/g&gt;
&lt;/svg&gt;
&lt;/div&gt;
&lt;h2 id=&quot;key-properties&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Key Properties&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#key-properties&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;No extra memory for linked lists (all in array)&lt;/li&gt;
&lt;li&gt;Causes primary clustering (consecutive occupied slots)&lt;/li&gt;
&lt;li&gt;Probe sequence is: h(k), h(k)+1, h(k)+2, …&lt;/li&gt;
&lt;li&gt;Deletion tricky: need tombstone markers&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;connections&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Connections&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#connections&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Built from:&lt;/strong&gt; &lt;a href=&quot;../../hashing&quot; class=&quot;internal alias&quot; data-slug=&quot;hashing&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Hashing&lt;/a&gt;, &lt;a href=&quot;../../collision-resolution&quot; class=&quot;internal alias&quot; data-slug=&quot;collision-resolution&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Collision Resolution&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Builds into:&lt;/strong&gt; &lt;a href=&quot;../../quadratic-probing&quot; class=&quot;internal alias&quot; data-slug=&quot;quadratic-probing&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Quadratic Probing&lt;/a&gt;, &lt;a href=&quot;../../double-hashing&quot; class=&quot;internal alias&quot; data-slug=&quot;double-hashing&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Double Hashing&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../load-factor&quot; class=&quot;internal alias&quot; data-slug=&quot;load-factor&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Load Factor&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Contrasts with:&lt;/strong&gt; &lt;a href=&quot;../../separate-chaining&quot; class=&quot;internal alias&quot; data-slug=&quot;separate-chaining&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Separate Chaining&lt;/a&gt; (in-table vs chains)&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;edge-cases--gotchas&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Edge Cases &amp;#x26; Gotchas&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#edge-cases--gotchas&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;Primary clustering: long runs of occupied slots form&lt;/li&gt;
&lt;li&gt;Performance drops sharply when load factor &gt; 0.7&lt;/li&gt;
&lt;li&gt;Deletion needs tombstones (can’t just clear slot)&lt;/li&gt;
&lt;li&gt;Table must be resized when getting full&lt;/li&gt;
&lt;/ul&gt;</content>
  </entry><entry>
    <title>load-factor</title>
    <link href="https://animishraa05.github.io/wiki/io/load-factor" />
    <link rel="alternate" type="text/markdown" href="https://animishraa05.github.io/wiki/io/load-factor.md" />
    <summary>The Problem How do we know when a hash table is “too full” and performance will degrade? We need a metric to decide when to resize.</summary>
    <published>2026-04-30T00:00:00.000Z</published>
    <updated>2026-04-30T00:00:00.000Z</updated>
    <publishedTime>Apr 30, 2026</publishedTime>
    <updatedTime>Apr 30, 2026</updatedTime>
    <category term="systems" label="systems" />
<category term="data-structures" label="data-structures" />
    <author>
      <name>Animesh Mishra</name>
      <email>animesh.mishra818@gmail.com</email>
    </author>
    <content type="html">&lt;h2 id=&quot;the-problem&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;The Problem&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#the-problem&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;How do we know when a hash table is “too full” and performance will degrade? We need a metric to decide when to resize.&lt;/p&gt;
&lt;h2 id=&quot;core-idea&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Core Idea&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#core-idea&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;Load factor (α) is the ratio of elements stored to the total table size: α = number_of_elements / table_size. It predicts hash table performance.&lt;/p&gt;
&lt;h2 id=&quot;how-it-works&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;How It Works&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#how-it-works&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ol dir=&quot;auto&quot;&gt;
&lt;li&gt;Calculate α = n / m (n = elements, m = table size)&lt;/li&gt;
&lt;li&gt;α ≤ 0.7: good performance, few collisions&lt;/li&gt;
&lt;li&gt;α &gt; 0.7: performance drops, consider resizing&lt;/li&gt;
&lt;li&gt;α close to 1.0: many collisions, O(n) worst case likely&lt;/li&gt;
&lt;/ol&gt;
&lt;div class=&quot;graphviz-container&quot; style=&quot;display: flex; justify-content: center; margin: 1.5rem 0; overflow-x: auto;&quot; dir=&quot;auto&quot;&gt;&lt;!--?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?--&gt;

&lt;!-- Generated by graphviz version 15.1.0 (0)
 --&gt;
&lt;!-- Title: load_factor Pages: 1 --&gt;
&lt;svg width=&quot;185pt&quot; height=&quot;272pt&quot; viewBox=&quot;0.00 0.00 185.00 272.00&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; xmlns:xlink=&quot;http://www.w3.org/1999/xlink&quot;&gt;
&lt;g id=&quot;graph0&quot; class=&quot;graph&quot; transform=&quot;scale(1 1) rotate(0) translate(4 268)&quot;&gt;
&lt;title&gt;load_factor&lt;/title&gt;
&lt;polygon fill=&quot;white&quot; stroke=&quot;none&quot; points=&quot;-4,4 -4,-268 181.3,-268 181.3,4 -4,4&quot;&gt;&lt;/polygon&gt;
&lt;!-- Good --&gt;
&lt;g id=&quot;node1&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Good&lt;/title&gt;
&lt;polygon fill=&quot;lightgreen&quot; stroke=&quot;black&quot; points=&quot;121.34,-264 0,-264 0,-205.6 121.34,-205.6 121.34,-264&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;60.67&quot; y=&quot;-247.4&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;α = 0.5&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;60.67&quot; y=&quot;-230.6&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Good performance&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;60.67&quot; y=&quot;-213.8&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;O(1) avg&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Okay --&gt;
&lt;g id=&quot;node2&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Okay&lt;/title&gt;
&lt;polygon fill=&quot;lightyellow&quot; stroke=&quot;black&quot; points=&quot;109.5,-152.8 11.84,-152.8 11.84,-111.2 109.5,-111.2 109.5,-152.8&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;60.67&quot; y=&quot;-136.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;α = 0.7&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;60.67&quot; y=&quot;-119.4&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Okay, monitor&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Good&amp;#45;&amp;gt;Okay --&gt;
&lt;g id=&quot;edge1&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Good-&gt;Okay&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M60.67,-205.18C60.67,-192.44 60.67,-177.39 60.67,-164.34&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;64.17,-164.56 60.67,-154.56 57.17,-164.56 64.17,-164.56&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;118.98&quot; y=&quot;-175&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;insert more elements&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Bad --&gt;
&lt;g id=&quot;node3&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Bad&lt;/title&gt;
&lt;polygon fill=&quot;salmon&quot; stroke=&quot;black&quot; points=&quot;102.1,-58.4 19.24,-58.4 19.24,0 102.1,0 102.1,-58.4&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;60.67&quot; y=&quot;-41.8&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;α = 0.9&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;60.67&quot; y=&quot;-25&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Bad, resize!&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;60.67&quot; y=&quot;-8.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;O(n) worst&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Okay&amp;#45;&amp;gt;Bad --&gt;
&lt;g id=&quot;edge2&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Okay-&gt;Bad&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M60.67,-111.09C60.67,-99.43 60.67,-84.29 60.67,-70.27&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;64.17,-70.37 60.67,-60.37 57.17,-70.37 64.17,-70.37&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;118.98&quot; y=&quot;-80.6&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;insert more elements&lt;/text&gt;
&lt;/g&gt;
&lt;/g&gt;
&lt;/svg&gt;
&lt;/div&gt;
&lt;h2 id=&quot;key-properties&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Key Properties&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#key-properties&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;α = 0.0: empty table (wasted space)&lt;/li&gt;
&lt;li&gt;α = 0.5-0.7: sweet spot for performance&lt;/li&gt;
&lt;li&gt;α &gt; 0.7: collisions increase sharply&lt;/li&gt;
&lt;li&gt;α = 1.0: table full, must resize&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;connections&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Connections&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#connections&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Built from:&lt;/strong&gt; &lt;a href=&quot;../../hashing&quot; class=&quot;internal alias&quot; data-slug=&quot;hashing&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Hashing&lt;/a&gt;, &lt;a href=&quot;../../hash-function&quot; class=&quot;internal alias&quot; data-slug=&quot;hash-function&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Hash Function&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Builds into:&lt;/strong&gt; &lt;a href=&quot;../../separate-chaining&quot; class=&quot;internal alias&quot; data-slug=&quot;separate-chaining&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Separate Chaining&lt;/a&gt;, &lt;a href=&quot;../../linear-probing&quot; class=&quot;internal alias&quot; data-slug=&quot;linear-probing&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Linear Probing&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../collision-resolution&quot; class=&quot;internal alias&quot; data-slug=&quot;collision-resolution&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Collision Resolution&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Contrasts with:&lt;/strong&gt; &lt;a href=&quot;../../big-o-notation&quot; class=&quot;internal alias&quot; data-slug=&quot;big-o-notation&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Big O Notation&lt;/a&gt; (load factor affects actual O(1) performance)&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;edge-cases--gotchas&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Edge Cases &amp;#x26; Gotchas&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#edge-cases--gotchas&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;Low load factor wastes memory (too many empty slots)&lt;/li&gt;
&lt;li&gt;High load factor causes performance collapse&lt;/li&gt;
&lt;li&gt;Resizing requires rehashing ALL elements (expensive)&lt;/li&gt;
&lt;li&gt;Chaining tolerates higher load factors than probing&lt;/li&gt;
&lt;/ul&gt;</content>
  </entry><entry>
    <title>look-scheduling</title>
    <link href="https://animishraa05.github.io/wiki/io/look-scheduling" />
    <link rel="alternate" type="text/markdown" href="https://animishraa05.github.io/wiki/io/look-scheduling.md" />
    <summary>The Problem SCAN goes all the way to the disk end even if there are no requests there, wasting time.</summary>
    <published>2026-04-30T00:00:00.000Z</published>
    <updated>2026-04-30T00:00:00.000Z</updated>
    <publishedTime>Apr 30, 2026</publishedTime>
    <updatedTime>Apr 30, 2026</updatedTime>
    <category term="systems" label="systems" />
<category term="storage" label="storage" />
    <author>
      <name>Animesh Mishra</name>
      <email>animesh.mishra818@gmail.com</email>
    </author>
    <content type="html">&lt;h2 id=&quot;the-problem&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;The Problem&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#the-problem&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;SCAN goes all the way to the disk end even if there are no requests there, wasting time. Can we optimize this?&lt;/p&gt;
&lt;h2 id=&quot;core-idea&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Core Idea&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#core-idea&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;LOOK is a variant of SCAN that only goes as far as the last request in each direction, then reverses — doesn’t go to disk end unnecessarily.&lt;/p&gt;
&lt;h2 id=&quot;how-it-works&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;How It Works&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#how-it-works&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ol dir=&quot;auto&quot;&gt;
&lt;li&gt;Move disk arm in current direction&lt;/li&gt;
&lt;li&gt;Service requests along the way&lt;/li&gt;
&lt;li&gt;When past the last request in that direction, reverse&lt;/li&gt;
&lt;li&gt;Don’t go to physical disk end (unlike SCAN)&lt;/li&gt;
&lt;/ol&gt;
&lt;div class=&quot;graphviz-container&quot; style=&quot;display: flex; justify-content: center; margin: 1.5rem 0; overflow-x: auto;&quot; dir=&quot;auto&quot;&gt;&lt;!--?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?--&gt;

&lt;!-- Generated by graphviz version 15.1.0 (0)
 --&gt;
&lt;!-- Title: look Pages: 1 --&gt;
&lt;svg width=&quot;284pt&quot; height=&quot;131pt&quot; viewBox=&quot;0.00 0.00 284.00 131.00&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; xmlns:xlink=&quot;http://www.w3.org/1999/xlink&quot;&gt;
&lt;g id=&quot;graph0&quot; class=&quot;graph&quot; transform=&quot;scale(1 1) rotate(0) translate(4 126.79)&quot;&gt;
&lt;title&gt;look&lt;/title&gt;
&lt;polygon fill=&quot;white&quot; stroke=&quot;none&quot; points=&quot;-4,4 -4,-126.79 280.17,-126.79 280.17,4 -4,4&quot;&gt;&lt;/polygon&gt;
&lt;!-- Req1 --&gt;
&lt;g id=&quot;node1&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Req1&lt;/title&gt;
&lt;polygon fill=&quot;lightgreen&quot; stroke=&quot;black&quot; points=&quot;70.8,-111.6 0,-111.6 0,-70 70.8,-70 70.8,-111.6&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;35.4&quot; y=&quot;-95&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Last Req&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;35.4&quot; y=&quot;-78.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;(track 80)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Req2 --&gt;
&lt;g id=&quot;node2&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Req2&lt;/title&gt;
&lt;polygon fill=&quot;lightblue&quot; stroke=&quot;black&quot; points=&quot;276.17,-81.6 199.14,-81.6 199.14,-40 276.17,-40 276.17,-81.6&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;237.66&quot; y=&quot;-65&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Requests&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;237.66&quot; y=&quot;-48.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;in between&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Req1&amp;#45;&amp;gt;Req2 --&gt;
&lt;g id=&quot;edge3&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Req1-&gt;Req2&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;red&quot; stroke-dasharray=&quot;5 2&quot; d=&quot;M71.23,-90.16C100.74,-89.09 144.06,-86.24 181.14,-78.8 183.3,-78.37 185.5,-77.88 187.7,-77.34&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;red&quot; stroke=&quot;red&quot; points=&quot;188.53,-80.74 197.28,-74.76 186.71,-73.99 188.53,-80.74&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;134.97&quot; y=&quot;-110.19&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;reverse here&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;134.97&quot; y=&quot;-93.39&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;(don&#039;t go to end)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Req2&amp;#45;&amp;gt;Req1 --&gt;
&lt;g id=&quot;edge2&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Req2-&gt;Req1&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M198.93,-56.08C168.65,-53.49 125.32,-52.47 88.8,-62 85.7,-62.81 82.57,-63.85 79.49,-65.04&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;78.3,-61.74 70.58,-69 81.14,-68.14 78.3,-61.74&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;134.97&quot; y=&quot;-66.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;service →&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Req3 --&gt;
&lt;g id=&quot;node3&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Req3&lt;/title&gt;
&lt;polygon fill=&quot;lightyellow&quot; stroke=&quot;black&quot; points=&quot;70.8,-41.6 0,-41.6 0,0 70.8,0 70.8,-41.6&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;35.4&quot; y=&quot;-25&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Start&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;35.4&quot; y=&quot;-8.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;(track 20)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Req3&amp;#45;&amp;gt;Req2 --&gt;
&lt;g id=&quot;edge1&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Req3-&gt;Req2&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M71.24,-20.51C100.96,-21.08 144.55,-23.86 181.14,-34 183.53,-34.66 185.94,-35.42 188.35,-36.26&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;186.83,-39.43 197.42,-39.8 189.38,-32.9 186.83,-39.43&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;134.97&quot; y=&quot;-38.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;service →&lt;/text&gt;
&lt;/g&gt;
&lt;/g&gt;
&lt;/svg&gt;
&lt;/div&gt;
&lt;h2 id=&quot;key-properties&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Key Properties&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#key-properties&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;More efficient than SCAN (no unnecessary travel to disk end)&lt;/li&gt;
&lt;li&gt;Still no starvation (like SCAN)&lt;/li&gt;
&lt;li&gt;Only goes as far as the furthest request&lt;/li&gt;
&lt;li&gt;C-LOOK is the C-SCAN version of LOOK&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;connections&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Connections&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#connections&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Built from:&lt;/strong&gt; &lt;a href=&quot;../../disk-scheduling&quot; class=&quot;internal alias&quot; data-slug=&quot;disk-scheduling&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Disk Scheduling&lt;/a&gt;, &lt;a href=&quot;../../scan-scheduling&quot; class=&quot;internal alias&quot; data-slug=&quot;scan-scheduling&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;SCAN&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Builds into:&lt;/strong&gt; &lt;a href=&quot;../../c-look&quot; class=&quot;internal alias&quot; data-slug=&quot;c-look&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;C-LOOK&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../c-scan&quot; class=&quot;internal alias&quot; data-slug=&quot;c-scan&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;C-SCAN&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Contrasts with:&lt;/strong&gt; &lt;a href=&quot;../../scan-scheduling&quot; class=&quot;internal alias&quot; data-slug=&quot;scan-scheduling&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;SCAN&lt;/a&gt; (stops at last request vs goes to end)&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;edge-cases--gotchas&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Edge Cases &amp;#x26; Gotchas&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#edge-cases--gotchas&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;Must track the furthest request in each direction&lt;/li&gt;
&lt;li&gt;Slightly more complex than SCAN&lt;/li&gt;
&lt;li&gt;Default in many modern OSs&lt;/li&gt;
&lt;/ul&gt;</content>
  </entry><entry>
    <title>network-driver</title>
    <link href="https://animishraa05.github.io/wiki/io/network-driver" />
    <link rel="alternate" type="text/markdown" href="https://animishraa05.github.io/wiki/io/network-driver.md" />
    <summary>The Problem Network devices transfer data in packets (variable-sized frames) and must handle addressing (MAC), protocol headers, and often checksum offloading.</summary>
    <published>2026-04-30T00:00:00.000Z</published>
    <updated>2026-04-30T00:00:00.000Z</updated>
    <publishedTime>Apr 30, 2026</publishedTime>
    <updatedTime>Apr 30, 2026</updatedTime>
    <category term="systems" label="systems" />
<category term="io" label="io" />
    <author>
      <name>Animesh Mishra</name>
      <email>animesh.mishra818@gmail.com</email>
    </author>
    <content type="html">&lt;h2 id=&quot;the-problem&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;The Problem&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#the-problem&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;Network devices transfer data in packets (variable-sized frames) and must handle addressing (MAC), protocol headers, and often checksum offloading. Standard block/character drivers don’t fit.&lt;/p&gt;
&lt;h2 id=&quot;core-idea&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Core Idea&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#core-idea&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;A network driver manages network interface cards (NICs), handling packet send/receive, DMA for packet buffers, and often hardware acceleration (checksum, TSO).&lt;/p&gt;
&lt;h2 id=&quot;how-it-works&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;How It Works&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#how-it-works&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ol dir=&quot;auto&quot;&gt;
&lt;li&gt;OS passes packet (with headers) to driver for transmission&lt;/li&gt;
&lt;li&gt;Driver sets up DMA descriptor for packet buffer&lt;/li&gt;
&lt;li&gt;NIC DMAs packet from memory, adds PHY header, transmits&lt;/li&gt;
&lt;li&gt;On receive, NIC DMAs packet to memory, raises interrupt&lt;/li&gt;
&lt;li&gt;Driver passes packet up to network stack&lt;/li&gt;
&lt;/ol&gt;
&lt;div class=&quot;graphviz-container&quot; style=&quot;display: flex; justify-content: center; margin: 1.5rem 0; overflow-x: auto;&quot; dir=&quot;auto&quot;&gt;&lt;!--?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?--&gt;

&lt;!-- Generated by graphviz version 15.1.0 (0)
 --&gt;
&lt;!-- Title: net_driver Pages: 1 --&gt;
&lt;svg width=&quot;185pt&quot; height=&quot;350pt&quot; viewBox=&quot;0.00 0.00 185.00 350.00&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; xmlns:xlink=&quot;http://www.w3.org/1999/xlink&quot;&gt;
&lt;g id=&quot;graph0&quot; class=&quot;graph&quot; transform=&quot;scale(1 1) rotate(0) translate(4 345.6)&quot;&gt;
&lt;title&gt;net_driver&lt;/title&gt;
&lt;polygon fill=&quot;white&quot; stroke=&quot;none&quot; points=&quot;-4,4 -4,-345.6 181.05,-345.6 181.05,4 -4,4&quot;&gt;&lt;/polygon&gt;
&lt;!-- Stack --&gt;
&lt;g id=&quot;node1&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Stack&lt;/title&gt;
&lt;polygon fill=&quot;lightyellow&quot; stroke=&quot;black&quot; points=&quot;107.75,-341.6 8.16,-341.6 8.16,-300 107.75,-300 107.75,-341.6&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;57.95&quot; y=&quot;-325&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Network Stack&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;57.95&quot; y=&quot;-308.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;(TCP/IP)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- NDriver --&gt;
&lt;g id=&quot;node2&quot; class=&quot;node&quot;&gt;
&lt;title&gt;NDriver&lt;/title&gt;
&lt;polygon fill=&quot;lightgreen&quot; stroke=&quot;black&quot; points=&quot;115.91,-247.2 0,-247.2 0,-188.8 115.91,-188.8 115.91,-247.2&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;57.95&quot; y=&quot;-230.6&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Network Driver&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;57.95&quot; y=&quot;-213.8&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;DMA descriptors&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;57.95&quot; y=&quot;-197&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;checksum offload&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Stack&amp;#45;&amp;gt;NDriver --&gt;
&lt;g id=&quot;edge1&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Stack-&gt;NDriver&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M22.44,-299.68C10.8,-290.28 2.14,-278.28 7.87,-265.2 9.18,-262.2 10.8,-259.31 12.63,-256.55&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;15.28,-258.84 18.67,-248.81 9.76,-254.54 15.28,-258.84&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;47.91&quot; y=&quot;-269.4&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;packet to send&lt;/text&gt;
&lt;/g&gt;
&lt;!-- NDriver&amp;#45;&amp;gt;Stack --&gt;
&lt;g id=&quot;edge6&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;NDriver-&gt;Stack&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; stroke-dasharray=&quot;5 2&quot; d=&quot;M82.06,-247.61C88.16,-258.2 91.98,-270.45 87.95,-282 86.95,-284.87 85.64,-287.68 84.11,-290.4&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;81.35,-288.22 78.71,-298.48 87.17,-292.11 81.35,-288.22&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;133.33&quot; y=&quot;-269.4&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;received packet&lt;/text&gt;
&lt;/g&gt;
&lt;!-- NIC --&gt;
&lt;g id=&quot;node3&quot; class=&quot;node&quot;&gt;
&lt;title&gt;NIC&lt;/title&gt;
&lt;polygon fill=&quot;orange&quot; stroke=&quot;black&quot; points=&quot;105.79,-136 10.11,-136 10.11,-94.4 105.79,-94.4 105.79,-136&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;57.95&quot; y=&quot;-119.4&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;NIC&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;57.95&quot; y=&quot;-102.6&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;packet buffers&lt;/text&gt;
&lt;/g&gt;
&lt;!-- NDriver&amp;#45;&amp;gt;NIC --&gt;
&lt;g id=&quot;edge2&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;NDriver-&gt;NIC&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M25.79,-188.48C21.48,-183.07 17.7,-177.11 15.23,-170.8 12.51,-163.85 12.17,-160.81 15.23,-154 16.74,-150.66 18.7,-147.49 20.96,-144.52&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;23.33,-147.11 27.43,-137.34 18.13,-142.43 23.33,-147.11&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;48.09&quot; y=&quot;-158.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;DMA setup&lt;/text&gt;
&lt;/g&gt;
&lt;!-- NIC&amp;#45;&amp;gt;NDriver --&gt;
&lt;g id=&quot;edge5&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;NIC-&gt;NDriver&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; stroke-dasharray=&quot;5 2&quot; d=&quot;M73.03,-136.44C76.28,-141.88 79.25,-147.93 80.95,-154 83.13,-161.77 82.44,-169.96 80.28,-177.76&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;77.04,-176.43 76.91,-187.03 83.62,-178.83 77.04,-176.43&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;106.39&quot; y=&quot;-158.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;interrupt&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Wire --&gt;
&lt;g id=&quot;node4&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Wire&lt;/title&gt;
&lt;polygon fill=&quot;lightgray&quot; stroke=&quot;black&quot; points=&quot;108.52,-41.6 7.38,-41.6 7.38,0 108.52,0 108.52,-41.6&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;57.95&quot; y=&quot;-25&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Network Cable&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;57.95&quot; y=&quot;-8.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;(Wire)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- NIC&amp;#45;&amp;gt;Wire --&gt;
&lt;g id=&quot;edge3&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;NIC-&gt;Wire&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M35.82,-94.01C31.43,-88.75 27.45,-82.75 25.07,-76.4 21.85,-67.78 24.19,-59 28.82,-51.07&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;31.54,-53.29 34.51,-43.12 25.84,-49.21 31.54,-53.29&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;48.01&quot; y=&quot;-63.8&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;transmit&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Wire&amp;#45;&amp;gt;NIC --&gt;
&lt;g id=&quot;edge4&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Wire-&gt;NIC&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; stroke-dasharray=&quot;5 2&quot; d=&quot;M66.69,-41.89C70.15,-52.15 72.88,-64.87 70.95,-76.4 70.58,-78.61 70.1,-80.86 69.54,-83.11&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;66.19,-82.09 66.67,-92.67 72.9,-84.1 66.19,-82.09&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;91.79&quot; y=&quot;-63.8&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;receive&lt;/text&gt;
&lt;/g&gt;
&lt;/g&gt;
&lt;/svg&gt;
&lt;/div&gt;
&lt;h2 id=&quot;key-properties&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Key Properties&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#key-properties&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;Packet-based (variable size, unlike fixed blocks)&lt;/li&gt;
&lt;li&gt;Often uses DMA rings (multiple packet buffers queued)&lt;/li&gt;
&lt;li&gt;Hardware acceleration: checksum offload, TSO, RSS&lt;/li&gt;
&lt;li&gt;Examples: Ethernet driver, Wi-Fi driver, InfiniBand driver&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;connections&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Connections&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#connections&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Built from:&lt;/strong&gt; &lt;a href=&quot;../../device-driver&quot; class=&quot;internal alias&quot; data-slug=&quot;device-driver&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Device Driver&lt;/a&gt;, &lt;a href=&quot;../../io-devices&quot; class=&quot;internal alias&quot; data-slug=&quot;io-devices&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;O Devices&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Builds into:&lt;/strong&gt; &lt;a href=&quot;../../system-bus&quot; class=&quot;internal alias&quot; data-slug=&quot;system-bus&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;System Bus&lt;/a&gt; (connects to network)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../dma&quot; class=&quot;internal alias&quot; data-slug=&quot;dma&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;DMA&lt;/a&gt;, &lt;a href=&quot;../../interrupt-handler&quot; class=&quot;internal alias&quot; data-slug=&quot;interrupt-handler&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Interrupt Handler&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Contrasts with:&lt;/strong&gt; &lt;a href=&quot;../../block-driver&quot; class=&quot;internal alias&quot; data-slug=&quot;block-driver&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Block Driver&lt;/a&gt; (packets vs blocks)&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;edge-cases--gotchas&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Edge Cases &amp;#x26; Gotchas&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#edge-cases--gotchas&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;Packet drop under high load (driver must handle ring exhaustion)&lt;/li&gt;
&lt;li&gt;DMA mapping must handle scattered packet buffers (SG DMA)&lt;/li&gt;
&lt;li&gt;Some NICs have buggy offload features — may need disabling&lt;/li&gt;
&lt;/ul&gt;</content>
  </entry><entry>
    <title>page-fault</title>
    <link href="https://animishraa05.github.io/wiki/io/page-fault" />
    <link rel="alternate" type="text/markdown" href="https://animishraa05.github.io/wiki/io/page-fault.md" />
    <summary>The Problem In paged virtual memory, a process may reference a page that isn’t currently in RAM.</summary>
    <published>2026-04-30T00:00:00.000Z</published>
    <updated>2026-04-30T00:00:00.000Z</updated>
    <publishedTime>Apr 30, 2026</publishedTime>
    <updatedTime>Apr 30, 2026</updatedTime>
    <category term="systems" label="systems" />
<category term="memory" label="memory" />
    <author>
      <name>Animesh Mishra</name>
      <email>animesh.mishra818@gmail.com</email>
    </author>
    <content type="html">&lt;h2 id=&quot;the-problem&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;The Problem&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#the-problem&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;In paged virtual memory, a process may reference a page that isn’t currently in RAM. The CPU needs to know this page isn’t present so the OS can fetch it from disk.&lt;/p&gt;
&lt;h2 id=&quot;core-idea&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Core Idea&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#core-idea&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;A page fault occurs when a program accesses a page not loaded in RAM, triggering the OS to fetch the page from disk (swap space) into a free frame.&lt;/p&gt;
&lt;h2 id=&quot;how-it-works&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;How It Works&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#how-it-works&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ol dir=&quot;auto&quot;&gt;
&lt;li&gt;CPU accesses a virtual address&lt;/li&gt;
&lt;li&gt;MMU looks up page table, finds page not present (valid bit = 0)&lt;/li&gt;
&lt;li&gt;CPU raises a page fault exception&lt;/li&gt;
&lt;li&gt;OS checks if access is legal, finds free frame&lt;/li&gt;
&lt;li&gt;OS schedules disk read to load page from swap&lt;/li&gt;
&lt;li&gt;Page loaded, update page table, restart instruction&lt;/li&gt;
&lt;/ol&gt;
&lt;div class=&quot;graphviz-container&quot; style=&quot;display: flex; justify-content: center; margin: 1.5rem 0; overflow-x: auto;&quot; dir=&quot;auto&quot;&gt;&lt;!--?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?--&gt;

&lt;!-- Generated by graphviz version 15.1.0 (0)
 --&gt;
&lt;!-- Title: pagefault Pages: 1 --&gt;
&lt;svg width=&quot;296pt&quot; height=&quot;411pt&quot; viewBox=&quot;0.00 0.00 296.00 411.00&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; xmlns:xlink=&quot;http://www.w3.org/1999/xlink&quot;&gt;
&lt;g id=&quot;graph0&quot; class=&quot;graph&quot; transform=&quot;scale(1 1) rotate(0) translate(4 407.4)&quot;&gt;
&lt;title&gt;pagefault&lt;/title&gt;
&lt;polygon fill=&quot;white&quot; stroke=&quot;none&quot; points=&quot;-4,4 -4,-407.4 292.49,-407.4 292.49,4 -4,4&quot;&gt;&lt;/polygon&gt;
&lt;!-- CPU --&gt;
&lt;g id=&quot;node1&quot; class=&quot;node&quot;&gt;
&lt;title&gt;CPU&lt;/title&gt;
&lt;polygon fill=&quot;lightyellow&quot; stroke=&quot;black&quot; points=&quot;158.22,-403.4 64.87,-403.4 64.87,-361.8 158.22,-361.8 158.22,-403.4&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;111.54&quot; y=&quot;-386.8&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;CPU&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;111.54&quot; y=&quot;-370&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;accesses page&lt;/text&gt;
&lt;/g&gt;
&lt;!-- MMU --&gt;
&lt;g id=&quot;node2&quot; class=&quot;node&quot;&gt;
&lt;title&gt;MMU&lt;/title&gt;
&lt;polygon fill=&quot;orange&quot; stroke=&quot;black&quot; points=&quot;165.42,-324.8 57.67,-324.8 57.67,-283.2 165.42,-283.2 165.42,-324.8&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;111.54&quot; y=&quot;-308.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;MMU&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;111.54&quot; y=&quot;-291.4&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;page not present&lt;/text&gt;
&lt;/g&gt;
&lt;!-- CPU&amp;#45;&amp;gt;MMU --&gt;
&lt;g id=&quot;edge1&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;CPU-&gt;MMU&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M111.54,-361.47C111.54,-353.88 111.54,-345.05 111.54,-336.66&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;115.05,-336.77 111.54,-326.77 108.05,-336.77 115.05,-336.77&quot;&gt;&lt;/polygon&gt;
&lt;/g&gt;
&lt;!-- OS --&gt;
&lt;g id=&quot;node3&quot; class=&quot;node&quot;&gt;
&lt;title&gt;OS&lt;/title&gt;
&lt;polygon fill=&quot;lightblue&quot; stroke=&quot;black&quot; points=&quot;103.09,-230.4 0,-230.4 0,-188.8 103.09,-188.8 103.09,-230.4&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;51.54&quot; y=&quot;-213.8&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;OS&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;51.54&quot; y=&quot;-197&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;load from swap&lt;/text&gt;
&lt;/g&gt;
&lt;!-- MMU&amp;#45;&amp;gt;OS --&gt;
&lt;g id=&quot;edge2&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;MMU-&gt;OS&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;red&quot; stroke-dasharray=&quot;5 2&quot; d=&quot;M65.23,-282.81C58.74,-277.98 52.97,-272.16 49.04,-265.2 45.13,-258.26 44.05,-249.99 44.37,-242.02&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;red&quot; stroke=&quot;red&quot; points=&quot;47.83,-242.58 45.5,-232.25 40.88,-241.78 47.83,-242.58&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;105.79&quot; y=&quot;-252.6&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;page fault exception&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Disk --&gt;
&lt;g id=&quot;node4&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Disk&lt;/title&gt;
&lt;polygon fill=&quot;lightgray&quot; stroke=&quot;black&quot; points=&quot;136.07,-136 19.02,-136 19.02,-94.4 136.07,-94.4 136.07,-136&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;77.54&quot; y=&quot;-119.4&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Swap Space&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;77.54&quot; y=&quot;-102.6&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;(page stored here)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- OS&amp;#45;&amp;gt;Disk --&gt;
&lt;g id=&quot;edge3&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;OS-&gt;Disk&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M57.19,-188.55C60.59,-176.44 65.01,-160.76 68.85,-147.09&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;72.16,-148.24 71.5,-137.67 65.43,-146.35 72.16,-148.24&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;93.88&quot; y=&quot;-158.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;read page&lt;/text&gt;
&lt;/g&gt;
&lt;!-- RAM --&gt;
&lt;g id=&quot;node5&quot; class=&quot;node&quot;&gt;
&lt;title&gt;RAM&lt;/title&gt;
&lt;polygon fill=&quot;lightgreen&quot; stroke=&quot;black&quot; points=&quot;164.49,-41.6 90.6,-41.6 90.6,0 164.49,0 164.49,-41.6&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;127.54&quot; y=&quot;-25&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;RAM&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;127.54&quot; y=&quot;-8.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;free frame&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Disk&amp;#45;&amp;gt;RAM --&gt;
&lt;g id=&quot;edge4&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Disk-&gt;RAM&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M76.32,-93.96C76.51,-83.2 78.1,-70.06 83.62,-59.6 85.36,-56.31 87.51,-53.18 89.92,-50.23&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;92.39,-52.72 96.74,-43.06 87.31,-47.9 92.39,-52.72&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;123.08&quot; y=&quot;-63.8&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;DMA transfer&lt;/text&gt;
&lt;/g&gt;
&lt;!-- RAM&amp;#45;&amp;gt;MMU --&gt;
&lt;g id=&quot;edge5&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;RAM-&gt;MMU&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; stroke-dasharray=&quot;5 2&quot; d=&quot;M151.09,-41.79C155.76,-47.06 160,-53.1 162.54,-59.6 195.88,-144.68 203.64,-183.59 162.54,-265.2 160.78,-268.7 158.52,-271.96 155.94,-274.98&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;153.71,-272.26 149.03,-281.77 158.62,-277.25 153.71,-272.26&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;239.51&quot; y=&quot;-158.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;update page table&lt;/text&gt;
&lt;/g&gt;
&lt;/g&gt;
&lt;/svg&gt;
&lt;/div&gt;
&lt;h2 id=&quot;key-properties&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Key Properties&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#key-properties&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;Minor page fault: page is in memory but not in process’s page table&lt;/li&gt;
&lt;li&gt;Major page fault: page must be loaded from disk (slow!)&lt;/li&gt;
&lt;li&gt;Too many page faults = thrashing (system slow)&lt;/li&gt;
&lt;li&gt;Handled by OS, transparent to process&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;connections&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Connections&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#connections&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Built from:&lt;/strong&gt; &lt;a href=&quot;../../wiki/io/paging&quot; class=&quot;internal alias&quot; data-slug=&quot;wiki/io/paging&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Paging&lt;/a&gt;, &lt;a href=&quot;../../page-table&quot; class=&quot;internal alias&quot; data-slug=&quot;page-table&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Page Table&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Builds into:&lt;/strong&gt; &lt;a href=&quot;../../demand-paging&quot; class=&quot;internal alias&quot; data-slug=&quot;demand-paging&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Demand Paging&lt;/a&gt;, &lt;a href=&quot;../../wiki/io/thrashing&quot; class=&quot;internal alias&quot; data-slug=&quot;wiki/io/thrashing&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Thrashing&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../swap-space&quot; class=&quot;internal alias&quot; data-slug=&quot;swap-space&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Swap Space&lt;/a&gt;, &lt;a href=&quot;../../virtual-memory&quot; class=&quot;internal alias&quot; data-slug=&quot;virtual-memory&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Virtual Memory&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Contrasts with:&lt;/strong&gt; &lt;a href=&quot;../../segmentation&quot; class=&quot;internal alias&quot; data-slug=&quot;segmentation&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Segmentation&lt;/a&gt; (different memory model)&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;edge-cases--gotchas&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Edge Cases &amp;#x26; Gotchas&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#edge-cases--gotchas&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;Invalid access (segfault) raises SIGSEGV, not page fault&lt;/li&gt;
&lt;li&gt;Copy-on-write: page fault used to duplicate pages&lt;/li&gt;
&lt;li&gt;Page fault handling is expensive (disk I/O)&lt;/li&gt;
&lt;/ul&gt;</content>
  </entry><entry>
    <title>page-table</title>
    <link href="https://animishraa05.github.io/wiki/io/page-table" />
    <link rel="alternate" type="text/markdown" href="https://animishraa05.github.io/wiki/io/page-table.md" />
    <summary>The Problem In paging, processes use virtual (logical) addresses, but RAM uses physical addresses.</summary>
    <published>2026-04-30T00:00:00.000Z</published>
    <updated>2026-04-30T00:00:00.000Z</updated>
    <publishedTime>Apr 30, 2026</publishedTime>
    <updatedTime>Apr 30, 2026</updatedTime>
    <category term="systems" label="systems" />
<category term="memory" label="memory" />
    <author>
      <name>Animesh Mishra</name>
      <email>animesh.mishra818@gmail.com</email>
    </author>
    <content type="html">&lt;h2 id=&quot;the-problem&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;The Problem&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#the-problem&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;In paging, processes use virtual (logical) addresses, but RAM uses physical addresses. The CPU needs to know which physical frame corresponds to each virtual page.&lt;/p&gt;
&lt;h2 id=&quot;core-idea&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Core Idea&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#core-idea&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;A page table is a data structure maintained by the OS that maps each virtual page of a process to its physical frame in RAM.&lt;/p&gt;
&lt;h2 id=&quot;how-it-works&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;How It Works&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#how-it-works&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ol dir=&quot;auto&quot;&gt;
&lt;li&gt;CPU generates logical address: page number + page offset&lt;/li&gt;
&lt;li&gt;Page number is used as index into page table&lt;/li&gt;
&lt;li&gt;Page table entry gives frame number&lt;/li&gt;
&lt;li&gt;Physical address = frame number × page size + offset&lt;/li&gt;
&lt;/ol&gt;
&lt;div class=&quot;graphviz-container&quot; style=&quot;display: flex; justify-content: center; margin: 1.5rem 0; overflow-x: auto;&quot; dir=&quot;auto&quot;&gt;&lt;!--?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?--&gt;

&lt;!-- Generated by graphviz version 15.1.0 (0)
 --&gt;
&lt;!-- Title: page_table Pages: 1 --&gt;
&lt;svg width=&quot;574pt&quot; height=&quot;83pt&quot; viewBox=&quot;0.00 0.00 574.00 83.00&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; xmlns:xlink=&quot;http://www.w3.org/1999/xlink&quot;&gt;
&lt;g id=&quot;graph0&quot; class=&quot;graph&quot; transform=&quot;scale(1 1) rotate(0) translate(4 79.2)&quot;&gt;
&lt;title&gt;page_table&lt;/title&gt;
&lt;polygon fill=&quot;white&quot; stroke=&quot;none&quot; points=&quot;-4,4 -4,-79.2 569.8,-79.2 569.8,4 -4,4&quot;&gt;&lt;/polygon&gt;
&lt;!-- CPU --&gt;
&lt;g id=&quot;node1&quot; class=&quot;node&quot;&gt;
&lt;title&gt;CPU&lt;/title&gt;
&lt;polygon fill=&quot;lightyellow&quot; stroke=&quot;black&quot; points=&quot;125.09,-66.8 0,-66.8 0,-8.4 125.09,-8.4 125.09,-66.8&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;62.55&quot; y=&quot;-50.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;CPU&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;62.55&quot; y=&quot;-33.4&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;logical addr:&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;62.55&quot; y=&quot;-16.6&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;page=2, offset=150&lt;/text&gt;
&lt;/g&gt;
&lt;!-- PT --&gt;
&lt;g id=&quot;node2&quot; class=&quot;node&quot;&gt;
&lt;title&gt;PT&lt;/title&gt;
&lt;polygon fill=&quot;orange&quot; stroke=&quot;black&quot; points=&quot;357.89,-75.2 240.41,-75.2 240.41,0 357.89,0 357.89,-75.2&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;299.15&quot; y=&quot;-58.6&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Page Table&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;299.15&quot; y=&quot;-41.8&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Page 0 → Frame 5&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;299.15&quot; y=&quot;-25&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Page 1 → Frame 2&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;299.15&quot; y=&quot;-8.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Page 2 → Frame 7&lt;/text&gt;
&lt;/g&gt;
&lt;!-- CPU&amp;#45;&amp;gt;PT --&gt;
&lt;g id=&quot;edge1&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;CPU-&gt;PT&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M125.49,-37.6C157.31,-37.6 196.18,-37.6 228.97,-37.6&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;228.78,-41.1 238.78,-37.6 228.78,-34.1 228.78,-41.1&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;182.75&quot; y=&quot;-41.8&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;lookup page 2&lt;/text&gt;
&lt;/g&gt;
&lt;!-- RAM --&gt;
&lt;g id=&quot;node3&quot; class=&quot;node&quot;&gt;
&lt;title&gt;RAM&lt;/title&gt;
&lt;polygon fill=&quot;lightblue&quot; stroke=&quot;black&quot; points=&quot;565.8,-66.8 440.16,-66.8 440.16,-8.4 565.8,-8.4 565.8,-66.8&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;502.98&quot; y=&quot;-50.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;RAM&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;502.98&quot; y=&quot;-33.4&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Frame 7, offset 150&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;502.98&quot; y=&quot;-16.6&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Physical addr&lt;/text&gt;
&lt;/g&gt;
&lt;!-- PT&amp;#45;&amp;gt;RAM --&gt;
&lt;g id=&quot;edge2&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;PT-&gt;RAM&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M358.26,-37.6C380.07,-37.6 405.17,-37.6 428.22,-37.6&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;428.19,-41.1 438.19,-37.6 428.19,-34.1 428.19,-41.1&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;399.02&quot; y=&quot;-41.8&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Frame 7&lt;/text&gt;
&lt;/g&gt;
&lt;/g&gt;
&lt;/svg&gt;
&lt;/div&gt;
&lt;h2 id=&quot;key-properties&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Key Properties&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#key-properties&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;One page table per process&lt;/li&gt;
&lt;li&gt;Stored in RAM (not in CPU registers — too large)&lt;/li&gt;
&lt;li&gt;Accessed on every memory reference (needs caching → TLB)&lt;/li&gt;
&lt;li&gt;Can be single-level, multi-level, or inverted&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;connections&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Connections&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#connections&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Built from:&lt;/strong&gt; &lt;a href=&quot;../../wiki/io/paging&quot; class=&quot;internal alias&quot; data-slug=&quot;wiki/io/paging&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Paging&lt;/a&gt;, &lt;a href=&quot;../../virtual-memory&quot; class=&quot;internal alias&quot; data-slug=&quot;virtual-memory&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Virtual Memory&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Builds into:&lt;/strong&gt; &lt;a href=&quot;../../tlb&quot; class=&quot;internal alias&quot; data-slug=&quot;tlb&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;TLB&lt;/a&gt;, &lt;a href=&quot;../../demand-paging&quot; class=&quot;internal alias&quot; data-slug=&quot;demand-paging&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Demand Paging&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../multi-level-page-table&quot; class=&quot;internal alias&quot; data-slug=&quot;multi-level-page-table&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Multi-Level Page Table&lt;/a&gt;, &lt;a href=&quot;../../inverted-page-table&quot; class=&quot;internal alias&quot; data-slug=&quot;inverted-page-table&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Inverted Page Table&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Contrasts with:&lt;/strong&gt; &lt;a href=&quot;../../segment-table&quot; class=&quot;internal alias&quot; data-slug=&quot;segment-table&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Segment Table&lt;/a&gt; (variable sizes vs fixed pages)&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;edge-cases--gotchas&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Edge Cases &amp;#x26; Gotchas&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#edge-cases--gotchas&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;Single-level page table can be huge (1M entries for 4GB process with 4KB pages)&lt;/li&gt;
&lt;li&gt;Multi-level page tables add levels of indirection&lt;/li&gt;
&lt;li&gt;Page table walks are slow (4 memory accesses for 4-level paging)&lt;/li&gt;
&lt;/ul&gt;</content>
  </entry><entry>
    <title>Paging vs Segmentation — Memory Management Compared</title>
    <link href="https://animishraa05.github.io/wiki/io/paging-vs-segmentation" />
    <link rel="alternate" type="text/markdown" href="https://animishraa05.github.io/wiki/io/paging-vs-segmentation.md" />
    <summary>Framing Compare two memory management schemes: paging (fixed-size chunks) vs segmentation (variable-size logical units).</summary>
    <published>2026-04-30T00:00:00.000Z</published>
    <updated>2026-04-30T00:00:00.000Z</updated>
    <publishedTime>Apr 30, 2026</publishedTime>
    <updatedTime>Apr 30, 2026</updatedTime>
    <category term="systems" label="systems" />
<category term="memory" label="memory" />
    <author>
      <name>Animesh Mishra</name>
      <email>animesh.mishra818@gmail.com</email>
    </author>
    <content type="html">&lt;h2 id=&quot;framing&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Framing&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#framing&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;Compare two memory management schemes: &lt;strong&gt;paging&lt;/strong&gt; (fixed-size chunks) vs &lt;strong&gt;segmentation&lt;/strong&gt; (variable-size logical units). Both enable virtual memory but with different trade-offs.&lt;/p&gt;
&lt;h2 id=&quot;comparison&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Comparison&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#comparison&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Feature&lt;/th&gt;
&lt;th&gt;Paging&lt;/th&gt;
&lt;th&gt;Segmentation&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Size&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Fixed (e.g., 4KB pages)&lt;/td&gt;
&lt;td&gt;Variable (code, data, stack)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Fragmentation&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Internal (last page wasted)&lt;/td&gt;
&lt;td&gt;External (gaps between segments)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Addressing&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Page number + offset&lt;/td&gt;
&lt;td&gt;Segment number + offset&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Table&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Page table (one per process)&lt;/td&gt;
&lt;td&gt;Segment table (base + limit)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Sharing&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Harder (page-granularity)&lt;/td&gt;
&lt;td&gt;Easier (share entire segment)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Protection&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Per-page bits&lt;/td&gt;
&lt;td&gt;Per-segment (code=read/exec, data=rw)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Growth&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Automatic (new pages)&lt;/td&gt;
&lt;td&gt;Explicit (segment grow/shrink)&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;h2 id=&quot;key-insights&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Key Insights&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#key-insights&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ol dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Paging eliminates external fragmentation&lt;/strong&gt; but wastes space inside pages (internal fragmentation)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Segmentation matches program structure&lt;/strong&gt; (code, data, stack are natural segments) but causes external fragmentation&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Paging is transparent&lt;/strong&gt; to the programmer; segmentation is visible (segment registers)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Modern OSs combine both&lt;/strong&gt;: outer segmentation (for protection) with inner paging (for no external fragmentation) — this is called &lt;strong&gt;paged segmentation&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;x86 architecture&lt;/strong&gt; uses paged segmentation: segment selector → linear address → page table → physical&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&quot;synthesis&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Synthesis&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#synthesis&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;No single scheme wins — paging solves fragmentation but loses program semantics; segmentation preserves semantics but fragments memory. The best systems (like modern x86) use &lt;strong&gt;both&lt;/strong&gt;: segmentation for protection and logical structure, paging for efficient physical memory use.&lt;/p&gt;
&lt;h2 id=&quot;connections&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Connections&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#connections&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;a href=&quot;../../wiki/io/paging&quot; class=&quot;internal alias&quot; data-slug=&quot;wiki/io/paging&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Paging&lt;/a&gt; — fixed-size memory management&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;../../segmentation&quot; class=&quot;internal alias&quot; data-slug=&quot;segmentation&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Segmentation&lt;/a&gt; — variable-size logical units&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;../../page-table&quot; class=&quot;internal alias&quot; data-slug=&quot;page-table&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Page Table&lt;/a&gt; — used in paging&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;../../segment-table&quot; class=&quot;internal alias&quot; data-slug=&quot;segment-table&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Segment Table&lt;/a&gt; — used in segmentation&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;../../virtual-memory&quot; class=&quot;internal alias&quot; data-slug=&quot;virtual-memory&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Virtual Memory&lt;/a&gt; — both enable virtual memory&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;../../internal-fragmentation&quot; class=&quot;internal alias&quot; data-slug=&quot;internal-fragmentation&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Internal Fragmentation&lt;/a&gt; — paging’s weakness&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;../../external-fragmentation&quot; class=&quot;internal alias&quot; data-slug=&quot;external-fragmentation&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;External Fragmentation&lt;/a&gt; — segmentation’s weakness&lt;/li&gt;
&lt;/ul&gt;</content>
  </entry><entry>
    <title>paging</title>
    <link href="https://animishraa05.github.io/wiki/io/paging" />
    <link rel="alternate" type="text/markdown" href="https://animishraa05.github.io/wiki/io/paging.md" />
    <summary>The Problem Contiguous memory allocation requires a process to be loaded in one continuous block of RAM, causing external fragmentation (wasted gaps between processes).</summary>
    <published>2026-04-30T00:00:00.000Z</published>
    <updated>2026-04-30T00:00:00.000Z</updated>
    <publishedTime>Apr 30, 2026</publishedTime>
    <updatedTime>Apr 30, 2026</updatedTime>
    <category term="systems" label="systems" />
<category term="memory" label="memory" />
    <author>
      <name>Animesh Mishra</name>
      <email>animesh.mishra818@gmail.com</email>
    </author>
    <content type="html">&lt;h2 id=&quot;the-problem&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;The Problem&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#the-problem&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;Contiguous memory allocation requires a process to be loaded in one continuous block of RAM, causing external fragmentation (wasted gaps between processes). We need non-contiguous allocation.&lt;/p&gt;
&lt;h2 id=&quot;core-idea&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Core Idea&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#core-idea&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;Paging divides processes into fixed-size pages and RAM into page frames, allowing non-contiguous allocation and eliminating external fragmentation.&lt;/p&gt;
&lt;h2 id=&quot;how-it-works&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;How It Works&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#how-it-works&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ol dir=&quot;auto&quot;&gt;
&lt;li&gt;Process is divided into &lt;strong&gt;pages&lt;/strong&gt; (e.g., 4KB each)&lt;/li&gt;
&lt;li&gt;RAM is divided into &lt;strong&gt;page frames&lt;/strong&gt; of same size&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Page table&lt;/strong&gt; maps each page to a frame in RAM&lt;/li&gt;
&lt;li&gt;CPU generates logical address = page number + offset&lt;/li&gt;
&lt;li&gt;MMU uses page table to translate to physical address = frame number + offset&lt;/li&gt;
&lt;/ol&gt;
&lt;div class=&quot;graphviz-container&quot; style=&quot;display: flex; justify-content: center; margin: 1.5rem 0; overflow-x: auto;&quot; dir=&quot;auto&quot;&gt;&lt;!--?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?--&gt;

&lt;!-- Generated by graphviz version 15.1.0 (0)
 --&gt;
&lt;!-- Title: paging Pages: 1 --&gt;
&lt;svg width=&quot;262pt&quot; height=&quot;291pt&quot; viewBox=&quot;0.00 0.00 262.00 291.00&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; xmlns:xlink=&quot;http://www.w3.org/1999/xlink&quot;&gt;
&lt;g id=&quot;graph0&quot; class=&quot;graph&quot; transform=&quot;scale(1 1) rotate(0) translate(4 287)&quot;&gt;
&lt;title&gt;paging&lt;/title&gt;
&lt;polygon fill=&quot;white&quot; stroke=&quot;none&quot; points=&quot;-4,4 -4,-287 258,-287 258,4 -4,4&quot;&gt;&lt;/polygon&gt;
&lt;g id=&quot;clust1&quot; class=&quot;cluster&quot;&gt;
&lt;title&gt;cluster_proc&lt;/title&gt;
&lt;polygon fill=&quot;none&quot; stroke=&quot;black&quot; points=&quot;20,-198.2 20,-275 234,-275 234,-198.2 20,-198.2&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;127&quot; y=&quot;-258.4&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Process (Virtual Memory)&lt;/text&gt;
&lt;/g&gt;
&lt;g id=&quot;clust2&quot; class=&quot;cluster&quot;&gt;
&lt;title&gt;cluster_ram&lt;/title&gt;
&lt;polygon fill=&quot;none&quot; stroke=&quot;black&quot; points=&quot;8,-8 8,-84.8 246,-84.8 246,-8 8,-8&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;127&quot; y=&quot;-68.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;RAM (Physical Memory)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- P0 --&gt;
&lt;g id=&quot;node1&quot; class=&quot;node&quot;&gt;
&lt;title&gt;P0&lt;/title&gt;
&lt;polygon fill=&quot;lightgreen&quot; stroke=&quot;black&quot; points=&quot;82,-242.2 28,-242.2 28,-206.2 82,-206.2 82,-242.2&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;55&quot; y=&quot;-220&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Page 0&lt;/text&gt;
&lt;/g&gt;
&lt;!-- PT --&gt;
&lt;g id=&quot;node4&quot; class=&quot;node&quot;&gt;
&lt;title&gt;PT&lt;/title&gt;
&lt;polygon fill=&quot;orange&quot; stroke=&quot;black&quot; points=&quot;195.45,-153.4 58.55,-153.4 58.55,-111.8 195.45,-111.8 195.45,-153.4&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;127&quot; y=&quot;-136.8&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Page Table&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;127&quot; y=&quot;-120&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;maps pages to frames&lt;/text&gt;
&lt;/g&gt;
&lt;!-- P0&amp;#45;&amp;gt;PT --&gt;
&lt;g id=&quot;edge1&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;P0-&gt;PT&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M57.43,-206.03C59.64,-195.25 63.75,-181.53 71.29,-171.4 74.07,-167.65 77.35,-164.16 80.89,-160.92&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;82.83,-163.86 88.35,-154.82 78.4,-158.44 82.83,-163.86&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;97.14&quot; y=&quot;-175.6&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Page 0 →&lt;/text&gt;
&lt;/g&gt;
&lt;!-- P1 --&gt;
&lt;g id=&quot;node2&quot; class=&quot;node&quot;&gt;
&lt;title&gt;P1&lt;/title&gt;
&lt;polygon fill=&quot;lightgreen&quot; stroke=&quot;black&quot; points=&quot;154,-242.2 100,-242.2 100,-206.2 154,-206.2 154,-242.2&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;127&quot; y=&quot;-220&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Page 1&lt;/text&gt;
&lt;/g&gt;
&lt;!-- P1&amp;#45;&amp;gt;PT --&gt;
&lt;g id=&quot;edge2&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;P1-&gt;PT&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M127,-205.92C127,-194.36 127,-178.8 127,-165.08&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;130.5,-165.15 127,-155.15 123.5,-165.15 130.5,-165.15&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;152.86&quot; y=&quot;-175.6&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Page 1 →&lt;/text&gt;
&lt;/g&gt;
&lt;!-- P2 --&gt;
&lt;g id=&quot;node3&quot; class=&quot;node&quot;&gt;
&lt;title&gt;P2&lt;/title&gt;
&lt;polygon fill=&quot;lightgreen&quot; stroke=&quot;black&quot; points=&quot;226,-242.2 172,-242.2 172,-206.2 226,-206.2 226,-242.2&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;199&quot; y=&quot;-220&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Page 2&lt;/text&gt;
&lt;/g&gt;
&lt;!-- P2&amp;#45;&amp;gt;PT --&gt;
&lt;g id=&quot;edge3&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;P2-&gt;PT&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M195.47,-206.07C192.62,-195.32 187.78,-181.61 180,-171.4 177.26,-167.81 174.09,-164.42 170.69,-161.26&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;172.94,-158.58 163.02,-154.85 168.44,-163.95 172.94,-158.58&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;214.8&quot; y=&quot;-175.6&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Page 2 →&lt;/text&gt;
&lt;/g&gt;
&lt;!-- F5 --&gt;
&lt;g id=&quot;node5&quot; class=&quot;node&quot;&gt;
&lt;title&gt;F5&lt;/title&gt;
&lt;polygon fill=&quot;lightblue&quot; stroke=&quot;black&quot; points=&quot;78.13,-52 15.87,-52 15.87,-16 78.13,-16 78.13,-52&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;47&quot; y=&quot;-29.8&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Frame 5&lt;/text&gt;
&lt;/g&gt;
&lt;!-- PT&amp;#45;&amp;gt;F5 --&gt;
&lt;g id=&quot;edge4&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;PT-&gt;F5&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M109.74,-111.67C102.64,-103.41 94.37,-93.69 87,-84.8 80.66,-77.15 73.86,-68.76 67.7,-61.08&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;70.49,-58.97 61.52,-53.34 65.03,-63.34 70.49,-58.97&quot;&gt;&lt;/polygon&gt;
&lt;/g&gt;
&lt;!-- F2 --&gt;
&lt;g id=&quot;node6&quot; class=&quot;node&quot;&gt;
&lt;title&gt;F2&lt;/title&gt;
&lt;polygon fill=&quot;lightblue&quot; stroke=&quot;black&quot; points=&quot;158.13,-52 95.87,-52 95.87,-16 158.13,-16 158.13,-52&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;127&quot; y=&quot;-29.8&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Frame 2&lt;/text&gt;
&lt;/g&gt;
&lt;!-- PT&amp;#45;&amp;gt;F2 --&gt;
&lt;g id=&quot;edge5&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;PT-&gt;F2&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M127,-111.58C127,-97.8 127,-79.28 127,-63.91&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;130.5,-63.91 127,-53.91 123.5,-63.91 130.5,-63.91&quot;&gt;&lt;/polygon&gt;
&lt;/g&gt;
&lt;!-- F7 --&gt;
&lt;g id=&quot;node7&quot; class=&quot;node&quot;&gt;
&lt;title&gt;F7&lt;/title&gt;
&lt;polygon fill=&quot;lightblue&quot; stroke=&quot;black&quot; points=&quot;238.13,-52 175.87,-52 175.87,-16 238.13,-16 238.13,-52&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;207&quot; y=&quot;-29.8&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Frame 7&lt;/text&gt;
&lt;/g&gt;
&lt;!-- PT&amp;#45;&amp;gt;F7 --&gt;
&lt;g id=&quot;edge6&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;PT-&gt;F7&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M144.26,-111.67C151.36,-103.41 159.63,-93.69 167,-84.8 173.34,-77.15 180.14,-68.76 186.3,-61.08&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;188.97,-63.34 192.48,-53.34 183.51,-58.97 188.97,-63.34&quot;&gt;&lt;/polygon&gt;
&lt;/g&gt;
&lt;/g&gt;
&lt;/svg&gt;
&lt;/div&gt;
&lt;h2 id=&quot;key-properties&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Key Properties&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#key-properties&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;Eliminates external fragmentation (pages can be anywhere)&lt;/li&gt;
&lt;li&gt;Fixed-size pages simplify allocation&lt;/li&gt;
&lt;li&gt;Page table overhead per process&lt;/li&gt;
&lt;li&gt;Internal fragmentation within pages (last page may not be full)&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;connections&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Connections&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#connections&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Built from:&lt;/strong&gt; &lt;a href=&quot;../../virtual-memory&quot; class=&quot;internal alias&quot; data-slug=&quot;virtual-memory&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Virtual Memory&lt;/a&gt;, &lt;a href=&quot;../../page-table&quot; class=&quot;internal alias&quot; data-slug=&quot;page-table&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Page Table&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Builds into:&lt;/strong&gt; &lt;a href=&quot;../../page-fault&quot; class=&quot;internal alias&quot; data-slug=&quot;page-fault&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Page Fault&lt;/a&gt;, &lt;a href=&quot;../../demand-paging&quot; class=&quot;internal alias&quot; data-slug=&quot;demand-paging&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Demand Paging&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../segmentation&quot; class=&quot;internal alias&quot; data-slug=&quot;segmentation&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Segmentation&lt;/a&gt;, &lt;a href=&quot;../../tlb&quot; class=&quot;internal alias&quot; data-slug=&quot;tlb&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;TLB&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Contrasts with:&lt;/strong&gt; &lt;a href=&quot;../../segmentation&quot; class=&quot;internal alias&quot; data-slug=&quot;segmentation&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Segmentation&lt;/a&gt; (fixed vs variable size)&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;edge-cases--gotchas&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Edge Cases &amp;#x26; Gotchas&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#edge-cases--gotchas&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;Internal fragmentation: last page partially filled wastes space&lt;/li&gt;
&lt;li&gt;Page table size grows with process size (use multi-level page tables)&lt;/li&gt;
&lt;li&gt;Every memory access needs page table lookup (slow → use TLB)&lt;/li&gt;
&lt;/ul&gt;</content>
  </entry><entry>
    <title>polling</title>
    <link href="https://animishraa05.github.io/wiki/io/polling" />
    <link rel="alternate" type="text/markdown" href="https://animishraa05.github.io/wiki/io/polling.md" />
    <summary>The Problem Interrupts require hardware support and can be complex to handle.</summary>
    <published>2026-04-30T00:00:00.000Z</published>
    <updated>2026-04-30T00:00:00.000Z</updated>
    <publishedTime>Apr 30, 2026</publishedTime>
    <updatedTime>Apr 30, 2026</updatedTime>
    <category term="systems" label="systems" />
<category term="io" label="io" />
    <author>
      <name>Animesh Mishra</name>
      <email>animesh.mishra818@gmail.com</email>
    </author>
    <content type="html">&lt;h2 id=&quot;the-problem&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;The Problem&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#the-problem&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;Interrupts require hardware support and can be complex to handle. For simple systems or when a quick response is needed, there must be a simpler way for the CPU to check if a device is ready.&lt;/p&gt;
&lt;h2 id=&quot;core-idea&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Core Idea&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#core-idea&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;A technique where the CPU repeatedly checks (polls) a device’s status register in a loop until the device is ready or operation completes, instead of using interrupts.&lt;/p&gt;
&lt;h2 id=&quot;how-it-works&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;How It Works&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#how-it-works&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ol dir=&quot;auto&quot;&gt;
&lt;li&gt;CPU writes command to device controller registers&lt;/li&gt;
&lt;li&gt;CPU enters a loop: read status register repeatedly&lt;/li&gt;
&lt;li&gt;If status indicates “busy” or “not ready”, keep looping&lt;/li&gt;
&lt;li&gt;When status changes to “ready” or “complete”, proceed&lt;/li&gt;
&lt;li&gt;Read/write data as needed&lt;/li&gt;
&lt;/ol&gt;
&lt;div class=&quot;graphviz-container&quot; style=&quot;display: flex; justify-content: center; margin: 1.5rem 0; overflow-x: auto;&quot; dir=&quot;auto&quot;&gt;&lt;!--?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?--&gt;

&lt;!-- Generated by graphviz version 15.1.0 (0)
 --&gt;
&lt;!-- Title: polling Pages: 1 --&gt;
&lt;svg width=&quot;298pt&quot; height=&quot;115pt&quot; viewBox=&quot;0.00 0.00 298.00 115.00&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; xmlns:xlink=&quot;http://www.w3.org/1999/xlink&quot;&gt;
&lt;g id=&quot;graph0&quot; class=&quot;graph&quot; transform=&quot;scale(1 1) rotate(0) translate(4 110.8)&quot;&gt;
&lt;title&gt;polling&lt;/title&gt;
&lt;polygon fill=&quot;white&quot; stroke=&quot;none&quot; points=&quot;-4,4 -4,-110.8 294.01,-110.8 294.01,4 -4,4&quot;&gt;&lt;/polygon&gt;
&lt;!-- CPU --&gt;
&lt;g id=&quot;node1&quot; class=&quot;node&quot;&gt;
&lt;title&gt;CPU&lt;/title&gt;
&lt;polygon fill=&quot;lightyellow&quot; stroke=&quot;black&quot; points=&quot;84.06,-78.8 0,-78.8 0,-37.2 84.06,-37.2 84.06,-78.8&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;42.03&quot; y=&quot;-62.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;CPU&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;42.03&quot; y=&quot;-45.4&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;polling loop&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Status --&gt;
&lt;g id=&quot;node2&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Status&lt;/title&gt;
&lt;polygon fill=&quot;orange&quot; stroke=&quot;black&quot; points=&quot;290.01,-106.8 189.63,-106.8 189.63,-65.2 290.01,-65.2 290.01,-106.8&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;239.82&quot; y=&quot;-90.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Status Register&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;239.82&quot; y=&quot;-73.4&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;(busy/ready)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- CPU&amp;#45;&amp;gt;Status --&gt;
&lt;g id=&quot;edge1&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;CPU-&gt;Status&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M84.34,-71.87C90.24,-73.47 96.27,-74.92 102.06,-76 126.7,-80.6 154.2,-83.1 178.04,-84.46&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;177.75,-87.95 187.91,-84.97 178.1,-80.96 177.75,-87.95&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;136.84&quot; y=&quot;-88.1&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;read status&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Device --&gt;
&lt;g id=&quot;node3&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Device&lt;/title&gt;
&lt;polygon fill=&quot;lightgray&quot; stroke=&quot;black&quot; points=&quot;267.64,-36 212,-36 212,0 267.64,0 267.64,-36&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;239.82&quot; y=&quot;-13.8&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Device&lt;/text&gt;
&lt;/g&gt;
&lt;!-- CPU&amp;#45;&amp;gt;Device --&gt;
&lt;g id=&quot;edge3&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;CPU-&gt;Device&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;green&quot; stroke-dasharray=&quot;5 2&quot; d=&quot;M81.28,-36.82C88.04,-33.81 95.13,-31.1 102.06,-29.2 134.42,-20.32 172.58,-17.82 200.36,-17.37&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;green&quot; stroke=&quot;green&quot; points=&quot;200.09,-20.87 210.06,-17.3 200.04,-13.87 200.09,-20.87&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;136.84&quot; y=&quot;-33.4&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;transfer data&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Status&amp;#45;&amp;gt;CPU --&gt;
&lt;g id=&quot;edge2&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Status-&gt;CPU&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; stroke-dasharray=&quot;5 2&quot; d=&quot;M200.01,-64.82C190.95,-60.84 181.16,-57.28 171.63,-55.2 146.97,-49.82 119.02,-49.73 95.5,-51.32&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;95.53,-47.8 85.84,-52.09 96.09,-54.78 95.53,-47.8&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;136.84&quot; y=&quot;-59.4&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;still busy?&lt;/text&gt;
&lt;/g&gt;
&lt;/g&gt;
&lt;/svg&gt;
&lt;/div&gt;
&lt;h2 id=&quot;key-properties&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Key Properties&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#key-properties&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;Simple to implement, no interrupt hardware needed&lt;/li&gt;
&lt;li&gt;CPU is fully occupied during polling (can’t do other work)&lt;/li&gt;
&lt;li&gt;Gives predictable timing for real-time systems&lt;/li&gt;
&lt;li&gt;Wasteful for slow devices (CPU spins doing nothing)&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;connections&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Connections&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#connections&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Built from:&lt;/strong&gt; &lt;a href=&quot;../../io-system&quot; class=&quot;internal alias&quot; data-slug=&quot;io-system&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;O System&lt;/a&gt;, &lt;a href=&quot;../../device-controller&quot; class=&quot;internal alias&quot; data-slug=&quot;device-controller&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Device Controller&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Builds into:&lt;/strong&gt; &lt;a href=&quot;../../interrupt-handler&quot; class=&quot;internal alias&quot; data-slug=&quot;interrupt-handler&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Interrupt Handler&lt;/a&gt; (alternative to polling)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../dma&quot; class=&quot;internal alias&quot; data-slug=&quot;dma&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;DMA&lt;/a&gt;, &lt;a href=&quot;../../io-request-to-hardware&quot; class=&quot;internal alias&quot; data-slug=&quot;io-request-to-hardware&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;O Request to Hardware Operation&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Contrasts with:&lt;/strong&gt; &lt;a href=&quot;../../interrupt-handler&quot; class=&quot;internal alias&quot; data-slug=&quot;interrupt-handler&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Interrupt Handler&lt;/a&gt; (event-driven vs poll-driven)&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;edge-cases--gotchas&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Edge Cases &amp;#x26; Gotchas&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#edge-cases--gotchas&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;Can waste enormous CPU cycles for slow devices&lt;/li&gt;
&lt;li&gt;May miss events if polling interval is too long&lt;/li&gt;
&lt;li&gt;Useful for small embedded systems without interrupt controllers&lt;/li&gt;
&lt;li&gt;High throughput for bulk transfers (once polled, transfer quickly)&lt;/li&gt;
&lt;/ul&gt;</content>
  </entry><entry>
    <title>producer-consumer</title>
    <link href="https://animishraa05.github.io/wiki/io/producer-consumer" />
    <link rel="alternate" type="text/markdown" href="https://animishraa05.github.io/wiki/io/producer-consumer.md" />
    <summary>The Problem A producer generates data and puts it into a buffer, while a consumer takes data from the buffer.</summary>
    <published>2026-04-30T00:00:00.000Z</published>
    <updated>2026-04-30T00:00:00.000Z</updated>
    <publishedTime>Apr 30, 2026</publishedTime>
    <updatedTime>Apr 30, 2026</updatedTime>
    <category term="systems" label="systems" />
<category term="concurrency" label="concurrency" />
    <author>
      <name>Animesh Mishra</name>
      <email>animesh.mishra818@gmail.com</email>
    </author>
    <content type="html">&lt;h2 id=&quot;the-problem&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;The Problem&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#the-problem&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;A producer generates data and puts it into a buffer, while a consumer takes data from the buffer. The buffer has limited size — producer must wait if full, consumer must wait if empty.&lt;/p&gt;
&lt;h2 id=&quot;core-idea&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Core Idea&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#core-idea&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;A classic synchronization problem solved using three semaphores: empty (counts free slots), full (counts filled slots), and mutex (protects buffer access).&lt;/p&gt;
&lt;h2 id=&quot;how-it-works&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;How It Works&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#how-it-works&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ol dir=&quot;auto&quot;&gt;
&lt;li&gt;Producer waits on &lt;code class=&quot;notranslate&quot;&gt;empty&lt;/code&gt; semaphore (decrements)&lt;/li&gt;
&lt;li&gt;Producer waits on &lt;code class=&quot;notranslate&quot;&gt;mutex&lt;/code&gt; (enters critical section)&lt;/li&gt;
&lt;li&gt;Producer adds item to buffer&lt;/li&gt;
&lt;li&gt;Producer signals &lt;code class=&quot;notranslate&quot;&gt;mutex&lt;/code&gt; (exits critical section)&lt;/li&gt;
&lt;li&gt;Producer signals &lt;code class=&quot;notranslate&quot;&gt;full&lt;/code&gt; (increments)&lt;/li&gt;
&lt;li&gt;Consumer does the reverse&lt;/li&gt;
&lt;/ol&gt;
&lt;div class=&quot;graphviz-container&quot; style=&quot;display: flex; justify-content: center; margin: 1.5rem 0; overflow-x: auto;&quot; dir=&quot;auto&quot;&gt;&lt;!--?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?--&gt;

&lt;!-- Generated by graphviz version 15.1.0 (0)
 --&gt;
&lt;!-- Title: prod_cons Pages: 1 --&gt;
&lt;svg width=&quot;432pt&quot; height=&quot;66pt&quot; viewBox=&quot;0.00 0.00 432.00 66.00&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; xmlns:xlink=&quot;http://www.w3.org/1999/xlink&quot;&gt;
&lt;g id=&quot;graph0&quot; class=&quot;graph&quot; transform=&quot;scale(1 1) rotate(0) translate(4 62.4)&quot;&gt;
&lt;title&gt;prod_cons&lt;/title&gt;
&lt;polygon fill=&quot;white&quot; stroke=&quot;none&quot; points=&quot;-4,4 -4,-62.4 428.41,-62.4 428.41,4 -4,4&quot;&gt;&lt;/polygon&gt;
&lt;!-- Prod --&gt;
&lt;g id=&quot;node1&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Prod&lt;/title&gt;
&lt;polygon fill=&quot;lightgreen&quot; stroke=&quot;black&quot; points=&quot;84.42,-58.4 0,-58.4 0,0 84.42,0 84.42,-58.4&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;42.21&quot; y=&quot;-41.8&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Producer&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;42.21&quot; y=&quot;-25&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;wait(empty)&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;42.21&quot; y=&quot;-8.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;wait(mutex)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Buf --&gt;
&lt;g id=&quot;node2&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Buf&lt;/title&gt;
&lt;polygon fill=&quot;lightyellow&quot; stroke=&quot;black&quot; points=&quot;233.63,-50 169.02,-50 169.02,-8.4 233.63,-8.4 233.63,-50&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;201.32&quot; y=&quot;-33.4&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Buffer&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;201.32&quot; y=&quot;-16.6&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;[N slots]&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Prod&amp;#45;&amp;gt;Buf --&gt;
&lt;g id=&quot;edge1&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Prod-&gt;Buf&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M84.9,-29.2C107.35,-29.2 135,-29.2 157.6,-29.2&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;157.4,-32.7 167.4,-29.2 157.4,-25.7 157.4,-32.7&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;126.72&quot; y=&quot;-33.4&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;add item&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Cons --&gt;
&lt;g id=&quot;node3&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Cons&lt;/title&gt;
&lt;polygon fill=&quot;lightblue&quot; stroke=&quot;black&quot; points=&quot;424.41,-58.4 339.99,-58.4 339.99,0 424.41,0 424.41,-58.4&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;382.2&quot; y=&quot;-41.8&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Consumer&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;382.2&quot; y=&quot;-25&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;wait(full)&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;382.2&quot; y=&quot;-8.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;wait(mutex)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Buf&amp;#45;&amp;gt;Cons --&gt;
&lt;g id=&quot;edge2&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Buf-&gt;Cons&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M233.89,-29.2C259.95,-29.2 297.49,-29.2 328.16,-29.2&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;328.02,-32.7 338.02,-29.2 328.02,-25.7 328.02,-32.7&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;286.81&quot; y=&quot;-33.4&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;remove item&lt;/text&gt;
&lt;/g&gt;
&lt;/g&gt;
&lt;/svg&gt;
&lt;/div&gt;
&lt;h2 id=&quot;key-properties&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Key Properties&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#key-properties&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;Uses 3 semaphores: empty (N), full (0), mutex (1)&lt;/li&gt;
&lt;li&gt;Producer waits on empty, signals full&lt;/li&gt;
&lt;li&gt;Consumer waits on full, signals empty&lt;/li&gt;
&lt;li&gt;Mutex protects buffer data structure&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;connections&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Connections&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#connections&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Built from:&lt;/strong&gt; &lt;a href=&quot;../../semaphore&quot; class=&quot;internal alias&quot; data-slug=&quot;semaphore&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Semaphore&lt;/a&gt;, &lt;a href=&quot;../../counting-semaphore&quot; class=&quot;internal alias&quot; data-slug=&quot;counting-semaphore&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Counting Semaphore&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Builds into:&lt;/strong&gt; &lt;a href=&quot;../../reader-writer&quot; class=&quot;internal alias&quot; data-slug=&quot;reader-writer&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Reader-Writer Problem&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../wait-operation&quot; class=&quot;internal alias&quot; data-slug=&quot;wait-operation&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Wait Operation&lt;/a&gt;, &lt;a href=&quot;../../signal-operation&quot; class=&quot;internal alias&quot; data-slug=&quot;signal-operation&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Signal Operation&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Contrasts with:&lt;/strong&gt; &lt;a href=&quot;../../reader-writer&quot; class=&quot;internal alias&quot; data-slug=&quot;reader-writer&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Reader-Writer&lt;/a&gt; (producer-consumer vs readers-writers)&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;edge-cases--gotchas&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Edge Cases &amp;#x26; Gotchas&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#edge-cases--gotchas&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;Wrong semaphore order can cause deadlock (always mutex last in, first out)&lt;/li&gt;
&lt;li&gt;Buffer must be protected by mutex during access&lt;/li&gt;
&lt;li&gt;Can be extended to multiple producers/consumers&lt;/li&gt;
&lt;/ul&gt;</content>
  </entry><entry>
    <title>quadratic-probing</title>
    <link href="https://animishraa05.github.io/wiki/io/quadratic-probing" />
    <link rel="alternate" type="text/markdown" href="https://animishraa05.github.io/wiki/io/quadratic-probing.md" />
    <summary>The Problem Linear probing causes primary clustering (long runs of occupied slots).</summary>
    <published>2026-04-30T00:00:00.000Z</published>
    <updated>2026-04-30T00:00:00.000Z</updated>
    <publishedTime>Apr 30, 2026</publishedTime>
    <updatedTime>Apr 30, 2026</updatedTime>
    <category term="systems" label="systems" />
<category term="data-structures" label="data-structures" />
    <author>
      <name>Animesh Mishra</name>
      <email>animesh.mishra818@gmail.com</email>
    </author>
    <content type="html">&lt;h2 id=&quot;the-problem&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;The Problem&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#the-problem&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;Linear probing causes primary clustering (long runs of occupied slots). We need a probing sequence that skips more slots each time to reduce clustering.&lt;/p&gt;
&lt;h2 id=&quot;core-idea&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Core Idea&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#core-idea&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;Quadratic probing uses a quadratic function (i²) to determine probe sequence: h(k), h(k)+1², h(k)+2², h(k)+3², …&lt;/p&gt;
&lt;h2 id=&quot;how-it-works&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;How It Works&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#how-it-works&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ol dir=&quot;auto&quot;&gt;
&lt;li&gt;Hash key to get initial index&lt;/li&gt;
&lt;li&gt;If collision, check index + 1²&lt;/li&gt;
&lt;li&gt;If still occupied, check index + 2²&lt;/li&gt;
&lt;li&gt;Continue: index + 3², index + 4², …&lt;/li&gt;
&lt;li&gt;Wrap around table as needed&lt;/li&gt;
&lt;/ol&gt;
&lt;div class=&quot;graphviz-container&quot; style=&quot;display: flex; justify-content: center; margin: 1.5rem 0; overflow-x: auto;&quot; dir=&quot;auto&quot;&gt;&lt;!--?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?--&gt;

&lt;!-- Generated by graphviz version 15.1.0 (0)
 --&gt;
&lt;!-- Title: quad Pages: 1 --&gt;
&lt;svg width=&quot;676pt&quot; height=&quot;50pt&quot; viewBox=&quot;0.00 0.00 676.00 50.00&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; xmlns:xlink=&quot;http://www.w3.org/1999/xlink&quot;&gt;
&lt;g id=&quot;graph0&quot; class=&quot;graph&quot; transform=&quot;scale(1 1) rotate(0) translate(4 45.6)&quot;&gt;
&lt;title&gt;quad&lt;/title&gt;
&lt;polygon fill=&quot;white&quot; stroke=&quot;none&quot; points=&quot;-4,4 -4,-45.6 672.15,-45.6 672.15,4 -4,4&quot;&gt;&lt;/polygon&gt;
&lt;!-- Hash --&gt;
&lt;g id=&quot;node1&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Hash&lt;/title&gt;
&lt;polygon fill=&quot;lightyellow&quot; stroke=&quot;black&quot; points=&quot;61.22,-38.8 0,-38.8 0,-2.8 61.22,-2.8 61.22,-38.8&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;30.61&quot; y=&quot;-16.6&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;h(k) = 5&lt;/text&gt;
&lt;/g&gt;
&lt;!-- P1 --&gt;
&lt;g id=&quot;node2&quot; class=&quot;node&quot;&gt;
&lt;title&gt;P1&lt;/title&gt;
&lt;polygon fill=&quot;salmon&quot; stroke=&quot;black&quot; points=&quot;264.82,-41.6 183.9,-41.6 183.9,0 264.82,0 264.82,-41.6&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;224.36&quot; y=&quot;-25&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;5: occupied&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;224.36&quot; y=&quot;-8.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;+1² = +1&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Hash&amp;#45;&amp;gt;P1 --&gt;
&lt;g id=&quot;edge1&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Hash-&gt;P1&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M61.57,-20.8C91.22,-20.8 137.18,-20.8 172.55,-20.8&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;172.12,-24.3 182.12,-20.8 172.12,-17.3 172.12,-24.3&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;122.56&quot; y=&quot;-25&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;probe sequence&lt;/text&gt;
&lt;/g&gt;
&lt;!-- P2 --&gt;
&lt;g id=&quot;node3&quot; class=&quot;node&quot;&gt;
&lt;title&gt;P2&lt;/title&gt;
&lt;polygon fill=&quot;salmon&quot; stroke=&quot;black&quot; points=&quot;468.42,-41.6 387.5,-41.6 387.5,0 468.42,0 468.42,-41.6&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;427.96&quot; y=&quot;-25&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;6: occupied&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;427.96&quot; y=&quot;-8.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;+2² = +4&lt;/text&gt;
&lt;/g&gt;
&lt;!-- P1&amp;#45;&amp;gt;P2 --&gt;
&lt;g id=&quot;edge2&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;P1-&gt;P2&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M265.19,-20.8C296.94,-20.8 341.63,-20.8 375.99,-20.8&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;375.7,-24.3 385.7,-20.8 375.7,-17.3 375.7,-24.3&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;326.16&quot; y=&quot;-25&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;probe sequence&lt;/text&gt;
&lt;/g&gt;
&lt;!-- P3 --&gt;
&lt;g id=&quot;node4&quot; class=&quot;node&quot;&gt;
&lt;title&gt;P3&lt;/title&gt;
&lt;polygon fill=&quot;lightgreen&quot; stroke=&quot;black&quot; points=&quot;668.15,-41.6 591.1,-41.6 591.1,0 668.15,0 668.15,-41.6&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;629.62&quot; y=&quot;-25&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;10: empty!&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;629.62&quot; y=&quot;-8.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;insert here&lt;/text&gt;
&lt;/g&gt;
&lt;!-- P2&amp;#45;&amp;gt;P3 --&gt;
&lt;g id=&quot;edge3&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;P2-&gt;P3&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M468.89,-20.8C500.79,-20.8 545.64,-20.8 579.69,-20.8&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;579.28,-24.3 589.28,-20.8 579.28,-17.3 579.28,-24.3&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;529.76&quot; y=&quot;-25&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;probe sequence&lt;/text&gt;
&lt;/g&gt;
&lt;/g&gt;
&lt;/svg&gt;
&lt;/div&gt;
&lt;h2 id=&quot;key-properties&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Key Properties&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#key-properties&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;Reduces primary clustering compared to linear probing&lt;/li&gt;
&lt;li&gt;May not probe all slots (depends on table size)&lt;/li&gt;
&lt;li&gt;Works best when table size is prime number&lt;/li&gt;
&lt;li&gt;Load factor should be &amp;#x3C; 0.7 for good performance&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;connections&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Connections&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#connections&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Built from:&lt;/strong&gt; &lt;a href=&quot;../../hashing&quot; class=&quot;internal alias&quot; data-slug=&quot;hashing&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Hashing&lt;/a&gt;, &lt;a href=&quot;../../collision-resolution&quot; class=&quot;internal alias&quot; data-slug=&quot;collision-resolution&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Collision Resolution&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Builds into:&lt;/strong&gt; &lt;a href=&quot;../../double-hashing&quot; class=&quot;internal alias&quot; data-slug=&quot;double-hashing&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Double Hashing&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../linear-probing&quot; class=&quot;internal alias&quot; data-slug=&quot;linear-probing&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Linear Probing&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Contrasts with:&lt;/strong&gt; &lt;a href=&quot;../../linear-probing&quot; class=&quot;internal alias&quot; data-slug=&quot;linear-probing&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Linear Probing&lt;/a&gt; (quadratic vs linear skip)&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;edge-cases--gotchas&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Edge Cases &amp;#x26; Gotchas&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#edge-cases--gotchas&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;May not probe all table slots (unlike linear probing)&lt;/li&gt;
&lt;li&gt;Table size should be prime for best coverage&lt;/li&gt;
&lt;li&gt;Secondary clustering: same initial hash = same probe sequence&lt;/li&gt;
&lt;/ul&gt;</content>
  </entry><entry>
    <title>raid</title>
    <link href="https://animishraa05.github.io/wiki/io/raid" />
    <link rel="alternate" type="text/markdown" href="https://animishraa05.github.io/wiki/io/raid.md" />
    <summary>The Problem Disks fail — and when they do, data is lost. Single disks also have performance limits.</summary>
    <published>2026-04-30T00:00:00.000Z</published>
    <updated>2026-04-30T00:00:00.000Z</updated>
    <publishedTime>Apr 30, 2026</publishedTime>
    <updatedTime>Apr 30, 2026</updatedTime>
    <category term="systems" label="systems" />
<category term="storage" label="storage" />
    <author>
      <name>Animesh Mishra</name>
      <email>animesh.mishra818@gmail.com</email>
    </author>
    <content type="html">&lt;h2 id=&quot;the-problem&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;The Problem&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#the-problem&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;Disks fail — and when they do, data is lost. Single disks also have performance limits. We need techniques to combine multiple disks for reliability and/or speed.&lt;/p&gt;
&lt;h2 id=&quot;core-idea&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Core Idea&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#core-idea&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;RAID combines multiple physical disks into a logical unit to provide redundancy (data safety) and/or improved performance.&lt;/p&gt;
&lt;h2 id=&quot;how-it-works&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;How It Works&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#how-it-works&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;RAID levels:&lt;/p&gt;
&lt;ol dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;RAID 0 (Striping)&lt;/strong&gt;: Data split across disks, no redundancy, fast but risky&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;RAID 1 (Mirroring)&lt;/strong&gt;: Data duplicated to 2+ disks, full redundancy&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;RAID 5 (Striping + Parity)&lt;/strong&gt;: Data + parity distributed, 1 disk failure tolerance&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;RAID 6 (Striping + Double Parity)&lt;/strong&gt;: Tolerates 2 disk failures&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;RAID 10 (1+0)&lt;/strong&gt;: Mirror pairs striped, best of both worlds&lt;/li&gt;
&lt;/ol&gt;
&lt;div class=&quot;graphviz-container&quot; style=&quot;display: flex; justify-content: center; margin: 1.5rem 0; overflow-x: auto;&quot; dir=&quot;auto&quot;&gt;&lt;!--?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?--&gt;

&lt;!-- Generated by graphviz version 15.1.0 (0)
 --&gt;
&lt;!-- Title: raid Pages: 1 --&gt;
&lt;svg width=&quot;323pt&quot; height=&quot;106pt&quot; viewBox=&quot;0.00 0.00 323.00 106.00&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; xmlns:xlink=&quot;http://www.w3.org/1999/xlink&quot;&gt;
&lt;g id=&quot;graph0&quot; class=&quot;graph&quot; transform=&quot;scale(1 1) rotate(0) translate(4 102.4)&quot;&gt;
&lt;title&gt;raid&lt;/title&gt;
&lt;polygon fill=&quot;white&quot; stroke=&quot;none&quot; points=&quot;-4,4 -4,-102.4 319,-102.4 319,4 -4,4&quot;&gt;&lt;/polygon&gt;
&lt;g id=&quot;clust1&quot; class=&quot;cluster&quot;&gt;
&lt;title&gt;cluster_raid0&lt;/title&gt;
&lt;polygon fill=&quot;none&quot; stroke=&quot;black&quot; points=&quot;8,-8 8,-90.4 154,-90.4 154,-8 8,-8&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;81&quot; y=&quot;-73.8&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;RAID 0 (Stripe)&lt;/text&gt;
&lt;/g&gt;
&lt;g id=&quot;clust2&quot; class=&quot;cluster&quot;&gt;
&lt;title&gt;cluster_raid1&lt;/title&gt;
&lt;polygon fill=&quot;none&quot; stroke=&quot;black&quot; points=&quot;162,-8 162,-90.4 307,-90.4 307,-8 162,-8&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;234.5&quot; y=&quot;-73.8&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;RAID 1 (Mirror)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- D1 --&gt;
&lt;g id=&quot;node1&quot; class=&quot;node&quot;&gt;
&lt;title&gt;D1&lt;/title&gt;
&lt;polygon fill=&quot;lightblue&quot; stroke=&quot;black&quot; points=&quot;72.02,-57.6 15.98,-57.6 15.98,-16 72.02,-16 72.02,-57.6&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;44&quot; y=&quot;-41&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Disk 1&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;44&quot; y=&quot;-24.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Data A&lt;/text&gt;
&lt;/g&gt;
&lt;!-- D2 --&gt;
&lt;g id=&quot;node2&quot; class=&quot;node&quot;&gt;
&lt;title&gt;D2&lt;/title&gt;
&lt;polygon fill=&quot;lightblue&quot; stroke=&quot;black&quot; points=&quot;145.63,-57.6 90.37,-57.6 90.37,-16 145.63,-16 145.63,-57.6&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;118&quot; y=&quot;-41&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Disk 2&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;118&quot; y=&quot;-24.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Data B&lt;/text&gt;
&lt;/g&gt;
&lt;!-- D3 --&gt;
&lt;g id=&quot;node3&quot; class=&quot;node&quot;&gt;
&lt;title&gt;D3&lt;/title&gt;
&lt;polygon fill=&quot;lightgreen&quot; stroke=&quot;black&quot; points=&quot;225.63,-57.6 170.37,-57.6 170.37,-16 225.63,-16 225.63,-57.6&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;198&quot; y=&quot;-41&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Disk 3&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;198&quot; y=&quot;-24.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Data C&lt;/text&gt;
&lt;/g&gt;
&lt;!-- D4 --&gt;
&lt;g id=&quot;node4&quot; class=&quot;node&quot;&gt;
&lt;title&gt;D4&lt;/title&gt;
&lt;polygon fill=&quot;lightgreen&quot; stroke=&quot;black&quot; points=&quot;298.63,-57.6 243.37,-57.6 243.37,-16 298.63,-16 298.63,-57.6&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;271&quot; y=&quot;-41&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Disk 4&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;271&quot; y=&quot;-24.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Data C&lt;/text&gt;
&lt;/g&gt;
&lt;/g&gt;
&lt;/svg&gt;
&lt;/div&gt;
&lt;h2 id=&quot;key-properties&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Key Properties&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#key-properties&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;RAID 0: Performance ↑, Reliability ↓ (no redundancy)&lt;/li&gt;
&lt;li&gt;RAID 1: Reliability ↑, Cost ↑ (100% overhead)&lt;/li&gt;
&lt;li&gt;RAID 5: Balanced (1 disk overhead for parity)&lt;/li&gt;
&lt;li&gt;RAID 6: More reliable than 5 (2 disk failures)&lt;/li&gt;
&lt;li&gt;RAID 10: Best performance + reliability, but expensive&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;connections&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Connections&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#connections&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Built from:&lt;/strong&gt; &lt;a href=&quot;../../disk-management&quot; class=&quot;internal alias&quot; data-slug=&quot;disk-management&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Disk Management&lt;/a&gt;, &lt;a href=&quot;../../disk-structure&quot; class=&quot;internal alias&quot; data-slug=&quot;disk-structure&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Disk Structure&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Builds into:&lt;/strong&gt; &lt;a href=&quot;../../disk-reliability&quot; class=&quot;internal alias&quot; data-slug=&quot;disk-reliability&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Disk Reliability&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../parity&quot; class=&quot;internal alias&quot; data-slug=&quot;parity&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Parity&lt;/a&gt;, &lt;a href=&quot;../../striping&quot; class=&quot;internal alias&quot; data-slug=&quot;striping&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Striping&lt;/a&gt;, &lt;a href=&quot;../../mirroring&quot; class=&quot;internal alias&quot; data-slug=&quot;mirroring&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Mirroring&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Contrasts with:&lt;/strong&gt; &lt;a href=&quot;../../swap-space&quot; class=&quot;internal alias&quot; data-slug=&quot;swap-space&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Swap Space&lt;/a&gt; (different purpose — performance vs capacity extension)&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;edge-cases--gotchas&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Edge Cases &amp;#x26; Gotchas&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#edge-cases--gotchas&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;RAID is not backup — accidental deletion still propagates&lt;/li&gt;
&lt;li&gt;RAID rebuild after failure is I/O intensive (risky if another disk fails)&lt;/li&gt;
&lt;li&gt;Software RAID vs Hardware RAID (hardware has battery-backed cache)&lt;/li&gt;
&lt;/ul&gt;</content>
  </entry><entry>
    <title>reader-writer</title>
    <link href="https://animishraa05.github.io/wiki/io/reader-writer" />
    <link rel="alternate" type="text/markdown" href="https://animishraa05.github.io/wiki/io/reader-writer.md" />
    <summary>The Problem Multiple processes want to read or write a shared resource. Readers can access concurrently, but writers need exclusive access.</summary>
    <published>2026-04-30T00:00:00.000Z</published>
    <updated>2026-04-30T00:00:00.000Z</updated>
    <publishedTime>Apr 30, 2026</publishedTime>
    <updatedTime>Apr 30, 2026</updatedTime>
    <category term="systems" label="systems" />
<category term="concurrency" label="concurrency" />
    <author>
      <name>Animesh Mishra</name>
      <email>animesh.mishra818@gmail.com</email>
    </author>
    <content type="html">&lt;h2 id=&quot;the-problem&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;The Problem&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#the-problem&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;Multiple processes want to read or write a shared resource. Readers can access concurrently, but writers need exclusive access. We need to coordinate them.&lt;/p&gt;
&lt;h2 id=&quot;core-idea&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Core Idea&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#core-idea&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;A synchronization problem where multiple readers can read simultaneously, but a writer requires exclusive access (no readers or other writers).&lt;/p&gt;
&lt;h2 id=&quot;how-it-works&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;How It Works&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#how-it-works&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ol dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Readers&lt;/strong&gt;: increment readCount (atomically), if first reader, wait on writeLock&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Readers&lt;/strong&gt;: read data, decrement readCount, if last reader, signal writeLock&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Writers&lt;/strong&gt;: wait on writeLock (exclusive access), write, signal writeLock&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Mutex&lt;/strong&gt;: protects readCount variable&lt;/li&gt;
&lt;/ol&gt;
&lt;div class=&quot;graphviz-container&quot; style=&quot;display: flex; justify-content: center; margin: 1.5rem 0; overflow-x: auto;&quot; dir=&quot;auto&quot;&gt;&lt;!--?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?--&gt;

&lt;!-- Generated by graphviz version 15.1.0 (0)
 --&gt;
&lt;!-- Title: rw Pages: 1 --&gt;
&lt;svg width=&quot;306pt&quot; height=&quot;178pt&quot; viewBox=&quot;0.00 0.00 306.00 178.00&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; xmlns:xlink=&quot;http://www.w3.org/1999/xlink&quot;&gt;
&lt;g id=&quot;graph0&quot; class=&quot;graph&quot; transform=&quot;scale(1 1) rotate(0) translate(4 173.6)&quot;&gt;
&lt;title&gt;rw&lt;/title&gt;
&lt;polygon fill=&quot;white&quot; stroke=&quot;none&quot; points=&quot;-4,4 -4,-173.6 301.59,-173.6 301.59,4 -4,4&quot;&gt;&lt;/polygon&gt;
&lt;!-- Readers --&gt;
&lt;g id=&quot;node1&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Readers&lt;/title&gt;
&lt;polygon fill=&quot;lightgreen&quot; stroke=&quot;black&quot; points=&quot;148.95,-161.2 0,-161.2 0,-102.8 148.95,-102.8 148.95,-161.2&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;74.48&quot; y=&quot;-144.6&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Readers&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;74.48&quot; y=&quot;-127.8&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;readCount++&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;74.48&quot; y=&quot;-111&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;if first: wait(writeLock)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Resource --&gt;
&lt;g id=&quot;node2&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Resource&lt;/title&gt;
&lt;polygon fill=&quot;lightyellow&quot; stroke=&quot;black&quot; points=&quot;204.71,-41.6 94.24,-41.6 94.24,0 204.71,0 204.71,-41.6&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;149.48&quot; y=&quot;-25&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Shared Resource&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;149.48&quot; y=&quot;-8.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;(data)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Readers&amp;#45;&amp;gt;Resource --&gt;
&lt;g id=&quot;edge1&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Readers-&gt;Resource&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M89.42,-102.39C96.84,-89.01 106.29,-73.09 116.03,-59.6 118.19,-56.62 120.53,-53.6 122.95,-50.63&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;125.52,-53.02 129.33,-43.13 120.18,-48.48 125.52,-53.02&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;159.75&quot; y=&quot;-63.8&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;concurrent read&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Writers --&gt;
&lt;g id=&quot;node3&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Writers&lt;/title&gt;
&lt;polygon fill=&quot;salmon&quot; stroke=&quot;black&quot; points=&quot;283.62,-169.6 167.33,-169.6 167.33,-94.4 283.62,-94.4 283.62,-169.6&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;225.48&quot; y=&quot;-153&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Writers&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;225.48&quot; y=&quot;-136.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;wait(writeLock)&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;225.48&quot; y=&quot;-119.4&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;write&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;225.48&quot; y=&quot;-102.6&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;signal(writeLock)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Writers&amp;#45;&amp;gt;Resource --&gt;
&lt;g id=&quot;edge2&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Writers-&gt;Resource&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M219.03,-93.99C215.73,-82.22 210.81,-69.67 203.48,-59.6 200.82,-55.96 197.71,-52.54 194.34,-49.37&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;196.62,-46.71 186.71,-42.96 192.12,-52.07 196.62,-46.71&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;255.02&quot; y=&quot;-63.8&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;exclusive write&lt;/text&gt;
&lt;/g&gt;
&lt;/g&gt;
&lt;/svg&gt;
&lt;/div&gt;
&lt;h2 id=&quot;key-properties&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Key Properties&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#key-properties&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;Readers can proceed concurrently&lt;/li&gt;
&lt;li&gt;Writers need exclusive access&lt;/li&gt;
&lt;li&gt;Starvation possible: writers may starve if readers keep coming&lt;/li&gt;
&lt;li&gt;Uses readCount, mutex, writeLock semaphores&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;connections&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Connections&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#connections&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Built from:&lt;/strong&gt; &lt;a href=&quot;../../semaphore&quot; class=&quot;internal alias&quot; data-slug=&quot;semaphore&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Semaphore&lt;/a&gt;, &lt;a href=&quot;../../producer-consumer&quot; class=&quot;internal alias&quot; data-slug=&quot;producer-consumer&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Producer-Consumer Problem&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Builds into:&lt;/strong&gt; &lt;a href=&quot;../../race-condition&quot; class=&quot;internal alias&quot; data-slug=&quot;race-condition&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Race Condition&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../mutex&quot; class=&quot;internal alias&quot; data-slug=&quot;mutex&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Mutex&lt;/a&gt;, &lt;a href=&quot;../../wait-operation&quot; class=&quot;internal alias&quot; data-slug=&quot;wait-operation&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Wait Operation&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Contrasts with:&lt;/strong&gt; &lt;a href=&quot;../../producer-consumer&quot; class=&quot;internal alias&quot; data-slug=&quot;producer-consumer&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Producer-Consumer&lt;/a&gt; (readers concurrent vs producer-consumer serialized)&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;edge-cases--gotchas&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Edge Cases &amp;#x26; Gotchas&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#edge-cases--gotchas&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;Writer starvation: readers keep arriving, writer never gets access&lt;/li&gt;
&lt;li&gt;Reader starvation: writer locks resource, new readers blocked&lt;/li&gt;
&lt;li&gt;readCount must be protected by mutex (it’s a shared variable)&lt;/li&gt;
&lt;/ul&gt;</content>
  </entry><entry>
    <title>scan-scheduling</title>
    <link href="https://animishraa05.github.io/wiki/io/scan-scheduling" />
    <link rel="alternate" type="text/markdown" href="https://animishraa05.github.io/wiki/io/scan-scheduling.md" />
    <summary>The Problem SSTF can starve requests at the edges of the disk. We need a fair algorithm that still performs well.</summary>
    <published>2026-04-30T00:00:00.000Z</published>
    <updated>2026-04-30T00:00:00.000Z</updated>
    <publishedTime>Apr 30, 2026</publishedTime>
    <updatedTime>Apr 30, 2026</updatedTime>
    <category term="systems" label="systems" />
<category term="storage" label="storage" />
    <author>
      <name>Animesh Mishra</name>
      <email>animesh.mishra818@gmail.com</email>
    </author>
    <content type="html">&lt;h2 id=&quot;the-problem&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;The Problem&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#the-problem&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;SSTF can starve requests at the edges of the disk. We need a fair algorithm that still performs well.&lt;/p&gt;
&lt;h2 id=&quot;core-idea&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Core Idea&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#core-idea&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;SCAN (Elevator Algorithm) moves the disk arm in one direction, servicing requests along the way, then reverses direction at the end and repeats.&lt;/p&gt;
&lt;h2 id=&quot;how-it-works&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;How It Works&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#how-it-works&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ol dir=&quot;auto&quot;&gt;
&lt;li&gt;Disk arm starts moving in one direction (e.g., outward)&lt;/li&gt;
&lt;li&gt;Service all requests in the current direction&lt;/li&gt;
&lt;li&gt;When reaching the end, reverse direction&lt;/li&gt;
&lt;li&gt;Service requests in the new direction&lt;/li&gt;
&lt;li&gt;Continue like an elevator&lt;/li&gt;
&lt;/ol&gt;
&lt;div class=&quot;graphviz-container&quot; style=&quot;display: flex; justify-content: center; margin: 1.5rem 0; overflow-x: auto;&quot; dir=&quot;auto&quot;&gt;&lt;!--?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?--&gt;

&lt;!-- Generated by graphviz version 15.1.0 (0)
 --&gt;
&lt;!-- Title: scan Pages: 1 --&gt;
&lt;svg width=&quot;171pt&quot; height=&quot;238pt&quot; viewBox=&quot;0.00 0.00 171.00 238.00&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; xmlns:xlink=&quot;http://www.w3.org/1999/xlink&quot;&gt;
&lt;g id=&quot;graph0&quot; class=&quot;graph&quot; transform=&quot;scale(1 1) rotate(0) translate(4 234.4)&quot;&gt;
&lt;title&gt;scan&lt;/title&gt;
&lt;polygon fill=&quot;white&quot; stroke=&quot;none&quot; points=&quot;-4,4 -4,-234.4 167.33,-234.4 167.33,4 -4,4&quot;&gt;&lt;/polygon&gt;
&lt;!-- Left --&gt;
&lt;g id=&quot;node1&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Left&lt;/title&gt;
&lt;polygon fill=&quot;lightgray&quot; stroke=&quot;black&quot; points=&quot;101.54,-230.4 29.15,-230.4 29.15,-188.8 101.54,-188.8 101.54,-230.4&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;65.35&quot; y=&quot;-213.8&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Disk Start&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;65.35&quot; y=&quot;-197&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;(track 0)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Mid --&gt;
&lt;g id=&quot;node2&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Mid&lt;/title&gt;
&lt;polygon fill=&quot;lightgreen&quot; stroke=&quot;black&quot; points=&quot;130.69,-136 0,-136 0,-94.4 130.69,-94.4 130.69,-136&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;65.35&quot; y=&quot;-119.4&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;→ Requests serviced&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;65.35&quot; y=&quot;-102.6&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;as arm moves right&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Left&amp;#45;&amp;gt;Mid --&gt;
&lt;g id=&quot;edge1&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Left-&gt;Mid&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M65.35,-188.55C65.35,-176.56 65.35,-161.07 65.35,-147.5&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;68.85,-147.72 65.35,-137.72 61.85,-147.72 68.85,-147.72&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;99.17&quot; y=&quot;-158.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;direction: →&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Right --&gt;
&lt;g id=&quot;node3&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Right&lt;/title&gt;
&lt;polygon fill=&quot;lightgray&quot; stroke=&quot;black&quot; points=&quot;99.6,-41.6 31.1,-41.6 31.1,0 99.6,0 99.6,-41.6&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;65.35&quot; y=&quot;-25&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Disk End&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;65.35&quot; y=&quot;-8.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;(track N)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Mid&amp;#45;&amp;gt;Right --&gt;
&lt;g id=&quot;edge2&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Mid-&gt;Right&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M30.78,-93.99C25.05,-89.01 19.91,-83.13 16.62,-76.4 11.93,-66.83 15.54,-57.67 22.52,-49.68&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;24.87,-52.28 29.71,-42.85 20.05,-47.2 24.87,-52.28&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;55.48&quot; y=&quot;-63.8&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;reverse at end&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Right&amp;#45;&amp;gt;Mid --&gt;
&lt;g id=&quot;edge3&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Right-&gt;Mid&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M84.6,-41.95C88.59,-47.29 92.22,-53.33 94.35,-59.6 97.15,-67.87 95.25,-76.4 91.34,-84.18&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;88.4,-82.28 86.08,-92.62 94.34,-85.99 88.4,-82.28&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;129.5&quot; y=&quot;-63.8&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;direction: ←&lt;/text&gt;
&lt;/g&gt;
&lt;/g&gt;
&lt;/svg&gt;
&lt;/div&gt;
&lt;h2 id=&quot;key-properties&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Key Properties&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#key-properties&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;No starvation (all requests eventually serviced)&lt;/li&gt;
&lt;li&gt;More uniform wait times than SSTF&lt;/li&gt;
&lt;li&gt;Can waste time going to disk end (even if no requests there)&lt;/li&gt;
&lt;li&gt;Like an elevator serving floors&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;connections&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Connections&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#connections&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Built from:&lt;/strong&gt; &lt;a href=&quot;../../disk-scheduling&quot; class=&quot;internal alias&quot; data-slug=&quot;disk-scheduling&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Disk Scheduling&lt;/a&gt;, &lt;a href=&quot;../../sstf&quot; class=&quot;internal alias&quot; data-slug=&quot;sstf&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;SSTF&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Builds into:&lt;/strong&gt; &lt;a href=&quot;../../c-scan&quot; class=&quot;internal alias&quot; data-slug=&quot;c-scan&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;C-SCAN&lt;/a&gt;, &lt;a href=&quot;../../look-scheduling&quot; class=&quot;internal alias&quot; data-slug=&quot;look-scheduling&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;LOOK&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../disk-structure&quot; class=&quot;internal alias&quot; data-slug=&quot;disk-structure&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Disk Structure&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Contrasts with:&lt;/strong&gt; &lt;a href=&quot;../../sstf&quot; class=&quot;internal alias&quot; data-slug=&quot;sstf&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;SSTF&lt;/a&gt; (no starvation vs possible starvation)&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;edge-cases--gotchas&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Edge Cases &amp;#x26; Gotchas&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#edge-cases--gotchas&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;High response time for requests at the edges (must wait for full sweep)&lt;/li&gt;
&lt;li&gt;May go to disk end unnecessarily (solved by LOOK)&lt;/li&gt;
&lt;li&gt;Better for heavy load than SSTF&lt;/li&gt;
&lt;/ul&gt;</content>
  </entry><entry>
    <title>segmentation</title>
    <link href="https://animishraa05.github.io/wiki/io/segmentation" />
    <link rel="alternate" type="text/markdown" href="https://animishraa05.github.io/wiki/io/segmentation.md" />
    <summary>The Problem Paging uses fixed-size pages, which don’t match program structure (code, data, stack are different logical units).</summary>
    <published>2026-04-30T00:00:00.000Z</published>
    <updated>2026-04-30T00:00:00.000Z</updated>
    <publishedTime>Apr 30, 2026</publishedTime>
    <updatedTime>Apr 30, 2026</updatedTime>
    <category term="systems" label="systems" />
<category term="memory" label="memory" />
    <author>
      <name>Animesh Mishra</name>
      <email>animesh.mishra818@gmail.com</email>
    </author>
    <content type="html">&lt;h2 id=&quot;the-problem&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;The Problem&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#the-problem&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;Paging uses fixed-size pages, which don’t match program structure (code, data, stack are different logical units). We need variable-size chunks that match program semantics.&lt;/p&gt;
&lt;h2 id=&quot;core-idea&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Core Idea&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#core-idea&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;Segmentation divides memory into variable-size logical units (segments) like code, data, stack, each with a segment table mapping to physical memory.&lt;/p&gt;
&lt;h2 id=&quot;how-it-works&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;How It Works&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#how-it-works&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ol dir=&quot;auto&quot;&gt;
&lt;li&gt;Program divided into segments (code, data, stack, heap)&lt;/li&gt;
&lt;li&gt;Each segment has: base address, limit (size)&lt;/li&gt;
&lt;li&gt;Segment table maps segment number → (base, limit)&lt;/li&gt;
&lt;li&gt;Address = segment number + offset within segment&lt;/li&gt;
&lt;li&gt;Hardware checks offset &amp;#x3C; limit (protection)&lt;/li&gt;
&lt;/ol&gt;
&lt;div class=&quot;graphviz-container&quot; style=&quot;display: flex; justify-content: center; margin: 1.5rem 0; overflow-x: auto;&quot; dir=&quot;auto&quot;&gt;&lt;!--?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?--&gt;

&lt;!-- Generated by graphviz version 15.1.0 (0)
 --&gt;
&lt;!-- Title: seg Pages: 1 --&gt;
&lt;svg width=&quot;346pt&quot; height=&quot;66pt&quot; viewBox=&quot;0.00 0.00 346.00 66.00&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; xmlns:xlink=&quot;http://www.w3.org/1999/xlink&quot;&gt;
&lt;g id=&quot;graph0&quot; class=&quot;graph&quot; transform=&quot;scale(1 1) rotate(0) translate(4 62.4)&quot;&gt;
&lt;title&gt;seg&lt;/title&gt;
&lt;polygon fill=&quot;white&quot; stroke=&quot;none&quot; points=&quot;-4,4 -4,-62.4 342.09,-62.4 342.09,4 -4,4&quot;&gt;&lt;/polygon&gt;
&lt;!-- SegTable --&gt;
&lt;g id=&quot;node1&quot; class=&quot;node&quot;&gt;
&lt;title&gt;SegTable&lt;/title&gt;
&lt;polygon fill=&quot;orange&quot; stroke=&quot;black&quot; points=&quot;174.5,-58.4 0,-58.4 0,0 174.5,0 174.5,-58.4&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;87.25&quot; y=&quot;-41.8&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Segment Table&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;87.25&quot; y=&quot;-25&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Seg0: base=1000, limit=500&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;87.25&quot; y=&quot;-8.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Seg1: base=1500, limit=300&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Segs --&gt;
&lt;g id=&quot;node2&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Segs&lt;/title&gt;
&lt;polygon fill=&quot;lightblue&quot; stroke=&quot;black&quot; points=&quot;338.09,-58.4 254.45,-58.4 254.45,0 338.09,0 338.09,-58.4&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;296.27&quot; y=&quot;-41.8&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Segments&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;296.27&quot; y=&quot;-25&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Code, Data,&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;296.27&quot; y=&quot;-8.2&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Stack, Heap&lt;/text&gt;
&lt;/g&gt;
&lt;!-- SegTable&amp;#45;&amp;gt;Segs --&gt;
&lt;g id=&quot;edge1&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;SegTable-&gt;Segs&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M174.85,-29.2C197.92,-29.2 222.15,-29.2 242.78,-29.2&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;242.64,-32.7 252.64,-29.2 242.64,-25.7 242.64,-32.7&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;214.48&quot; y=&quot;-33.4&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;maps to&lt;/text&gt;
&lt;/g&gt;
&lt;/g&gt;
&lt;/svg&gt;
&lt;/div&gt;
&lt;h2 id=&quot;key-properties&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Key Properties&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#key-properties&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;Variable-size segments (no internal fragmentation)&lt;/li&gt;
&lt;li&gt;Matches program structure (logical units)&lt;/li&gt;
&lt;li&gt;External fragmentation (gaps between segments)&lt;/li&gt;
&lt;li&gt;Easier sharing (share entire segment)&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;connections&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Connections&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#connections&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Built from:&lt;/strong&gt; &lt;a href=&quot;../../virtual-memory&quot; class=&quot;internal alias&quot; data-slug=&quot;virtual-memory&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Virtual Memory&lt;/a&gt;, &lt;a href=&quot;../../wiki/io/paging&quot; class=&quot;internal alias&quot; data-slug=&quot;wiki/io/paging&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Paging&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Builds into:&lt;/strong&gt; &lt;a href=&quot;../../paging-vs-segmentation&quot; class=&quot;internal alias&quot; data-slug=&quot;paging-vs-segmentation&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Paging vs Segmentation&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../segment-table&quot; class=&quot;internal alias&quot; data-slug=&quot;segment-table&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Segment Table&lt;/a&gt;, &lt;a href=&quot;../../external-fragmentation&quot; class=&quot;internal alias&quot; data-slug=&quot;external-fragmentation&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;External Fragmentation&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Contrasts with:&lt;/strong&gt; &lt;a href=&quot;../../wiki/io/paging&quot; class=&quot;internal alias&quot; data-slug=&quot;wiki/io/paging&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Paging&lt;/a&gt; (variable vs fixed size)&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;edge-cases--gotchas&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Edge Cases &amp;#x26; Gotchas&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#edge-cases--gotchas&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;External fragmentation: gaps between segments&lt;/li&gt;
&lt;li&gt;Segment table overhead per process&lt;/li&gt;
&lt;li&gt;Segment bounds checking required (hardware)&lt;/li&gt;
&lt;/ul&gt;</content>
  </entry><entry>
    <title>Semaphore Types — Binary vs Counting Semaphores Compared</title>
    <link href="https://animishraa05.github.io/wiki/io/semaphore-types" />
    <link rel="alternate" type="text/markdown" href="https://animishraa05.github.io/wiki/io/semaphore-types.md" />
    <summary>Framing Compare binary semaphores (mutex) versus counting semaphores (resource pools) — their use cases, behavior, and when to use each.</summary>
    <published>2026-04-30T00:00:00.000Z</published>
    <updated>2026-04-30T00:00:00.000Z</updated>
    <publishedTime>Apr 30, 2026</publishedTime>
    <updatedTime>Apr 30, 2026</updatedTime>
    <category term="systems" label="systems" />
<category term="concurrency" label="concurrency" />
    <author>
      <name>Animesh Mishra</name>
      <email>animesh.mishra818@gmail.com</email>
    </author>
    <content type="html">&lt;h2 id=&quot;framing&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Framing&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#framing&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;Compare &lt;strong&gt;binary semaphores&lt;/strong&gt; (mutex) versus &lt;strong&gt;counting semaphores&lt;/strong&gt; (resource pools) — their use cases, behavior, and when to use each.&lt;/p&gt;
&lt;h2 id=&quot;comparison&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Comparison&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#comparison&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Feature&lt;/th&gt;
&lt;th&gt;Binary Semaphore&lt;/th&gt;
&lt;th&gt;Counting Semaphore&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Values&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;0 or 1 only&lt;/td&gt;
&lt;td&gt;0 to N (N = resource count)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Use Case&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Mutual exclusion (critical section)&lt;/td&gt;
&lt;td&gt;Resource pool management&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Initial Value&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;1 (unlocked)&lt;/td&gt;
&lt;td&gt;N (available resources)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Negative Value&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Never negative&lt;/td&gt;
&lt;td&gt;Negative = number of waiters&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Example&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;File lock, mutex&lt;/td&gt;
&lt;td&gt;Buffer slots, printer pool&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;h2 id=&quot;key-insights&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Key Insights&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#key-insights&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ol dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Binary semaphore = mutex&lt;/strong&gt; — ensures only one process enters critical section&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Counting semaphore = resource counter&lt;/strong&gt; — tracks pool of identical resources&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Both use same wait()/signal() operations&lt;/strong&gt; — the difference is initialization and interpretation&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Binary semaphores can be implemented with counting&lt;/strong&gt; (just set N=1), but not vice versa&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Classic use: producer-consumer&lt;/strong&gt; — uses counting (empty, full) + binary (mutex)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Priority inversion&lt;/strong&gt; affects both types — high-priority process blocked by lower-priority holder&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&quot;synthesis&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Synthesis&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#synthesis&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;Binary semaphores are a special case of counting semaphores (N=1). Use &lt;strong&gt;binary for mutual exclusion&lt;/strong&gt;, &lt;strong&gt;counting for resource pools&lt;/strong&gt;. The producer-consumer problem elegantly combines both: counting semaphores (empty, full) manage buffer slots, while a binary semaphore (mutex) protects the buffer data structure.&lt;/p&gt;
&lt;h2 id=&quot;connections&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Connections&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#connections&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;a href=&quot;../../semaphore&quot; class=&quot;internal alias&quot; data-slug=&quot;semaphore&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Semaphore&lt;/a&gt; — the general concept&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;../../binary-semaphore&quot; class=&quot;internal alias&quot; data-slug=&quot;binary-semaphore&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Binary Semaphore&lt;/a&gt; — mutex use case&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;../../counting-semaphore&quot; class=&quot;internal alias&quot; data-slug=&quot;counting-semaphore&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Counting Semaphore&lt;/a&gt; — resource pool use case&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;../../producer-consumer&quot; class=&quot;internal alias&quot; data-slug=&quot;producer-consumer&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Producer-Consumer Problem&lt;/a&gt; — uses both types&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;../../mutex&quot; class=&quot;internal alias&quot; data-slug=&quot;mutex&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Mutex&lt;/a&gt; — binary semaphore synonym&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;../../wait-operation&quot; class=&quot;internal alias&quot; data-slug=&quot;wait-operation&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;wait() Operation&lt;/a&gt; — used by both&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;../../signal-operation&quot; class=&quot;internal alias&quot; data-slug=&quot;signal-operation&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;signal() Operation&lt;/a&gt; — used by both&lt;/li&gt;
&lt;/ul&gt;</content>
  </entry>
</feed>