<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>Fifo on Rafiul Alam</title>
    <link>https://alamrafiul.com/tags/fifo/</link>
    <description>Recent content in Fifo on Rafiul Alam</description>
    <image>
      <title>Rafiul Alam</title>
      <url>https://alamrafiul.com/papermod-cover.png</url>
      <link>https://alamrafiul.com/papermod-cover.png</link>
    </image>
    <generator>Hugo -- gohugo.io</generator>
    <language>en</language>
    <lastBuildDate>Sat, 16 Aug 2025 00:00:00 +0000</lastBuildDate><atom:link href="https://alamrafiul.com/tags/fifo/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Readers-Writers: Fair Solution</title>
      <link>https://alamrafiul.com/blogs/readers-writers-fair/</link>
      <pubDate>Sat, 16 Aug 2025 00:00:00 +0000</pubDate>
      
      <guid>https://alamrafiul.com/blogs/readers-writers-fair/</guid>
      <description>&lt;h2 id=&#34;the-fairness-problem&#34;&gt;The Fairness Problem&lt;/h2&gt;
&lt;p&gt;We&amp;rsquo;ve seen two extremes:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://alamrafiul.com/blogs/readers-writers-readers-preference/&#34;&gt;Readers preference&lt;/a&gt;: Writers can starve&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://alamrafiul.com/blogs/readers-writers-writers-preference/&#34;&gt;Writers preference&lt;/a&gt;: Readers can starve&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The &lt;strong&gt;fair solution&lt;/strong&gt; ensures &lt;strong&gt;no starvation&lt;/strong&gt; - everyone gets served in the order they arrive.&lt;/p&gt;
&lt;h2 id=&#34;the-solution-fifo-ordering&#34;&gt;The Solution: FIFO Ordering&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;Key idea&lt;/strong&gt;: Use a queue to serve requests in arrival order. This prevents both reader and writer starvation.&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-fallback&#34; data-lang=&#34;fallback&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;Arrival Order: R1, R2, W1, R3, R4, W2
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;Execution:     R1+R2 → W1 → R3+R4 → W2
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;               (batch)  (excl) (batch)  (excl)
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Consecutive readers can still batch together, but writers don&amp;rsquo;t get skipped!&lt;/p&gt;</description>
    </item>
    
  </channel>
</rss>
