<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[The Retros Way]]></title><description><![CDATA[The Retros Way]]></description><link>https://theretrosway.hashnode.dev</link><generator>RSS for Node</generator><lastBuildDate>Wed, 17 Jun 2026 21:40:11 GMT</lastBuildDate><atom:link href="https://theretrosway.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[5 Unexpected Truths About CPU Scheduling: How Your Computer Manages Tasks]]></title><description><![CDATA[Truths About CPU Scheduling
In the few milliseconds it takes you to scroll down this page, your computer has made hundreds of executive decisions. To the user, a modern operating system feels like a seamless, multitasking powerhouse—a digital ocean o...]]></description><link>https://theretrosway.hashnode.dev/5-unexpected-truths-about-cpu-scheduling-how-your-computer-manages-tasks</link><guid isPermaLink="true">https://theretrosway.hashnode.dev/5-unexpected-truths-about-cpu-scheduling-how-your-computer-manages-tasks</guid><category><![CDATA[cpu]]></category><category><![CDATA[CPU Scheduling]]></category><category><![CDATA[fcfs]]></category><category><![CDATA[sjf]]></category><dc:creator><![CDATA[ASN]]></dc:creator><pubDate>Wed, 11 Feb 2026 12:40:27 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1770813497456/69a438b8-a698-4569-81a9-5028d3a36509.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h1 id="heading-truths-about-cpu-scheduling">Truths About CPU Scheduling</h1>
<p>In the few milliseconds it takes you to scroll down this page, your computer has made hundreds of executive decisions. To the user, a modern operating system feels like a seamless, multitasking powerhouse—a digital ocean of fluid motion. But behind the interface sits an invisible conductor managing a chaotic orchestra: the CPU scheduler.</p>
<p>Like a high-speed traffic controller managing a thousand converging lanes, the scheduler must decide which process gets to use the processor and for how long. When your computer feels lightning-fast, the conductor is in perfect rhythm. When it lags, you are witnessing the breakdown of a complex mathematical balancing act. These five truths reveal the hidden logic, and the inevitable trade-offs, that govern how your computer "thinks."</p>
<p>--------------------------------------------------------------------------------</p>
<h2 id="heading-1-the-perfection-paradox-why-the-best-algorithm-is-mathematically-impossible">1. The Perfection Paradox: Why the "Best" Algorithm is Mathematically Impossible</h2>
<p>In the world of kernel engineering, there is a "gold standard" known as Shortest Job First (SJF). The logic is elegant: by prioritizing the quickest tasks, you clear the queue faster and minimize the average time a process spends waiting.</p>
<p>However, SJF presents a fundamental irony. For the <strong>short-term CPU scheduler</strong>—the one responsible for millisecond-to-millisecond decisions—SJF is practically impossible to implement. To work, the scheduler would need to know the future, specifically the exact length of a process’s next "CPU burst." Since interactive tasks are non-deterministic and driven by user input, we can never truly know their requirements in advance.</p>
<p>"The SJF scheduling algorithm is provably optimal; it gives the minimum average waiting time for a given set of processes... [but] it cannot be implemented at the level of short-term CPU scheduling. There is no way to know the length of the next CPU burst."</p>
<p>Architects attempt to bypass this by using <strong>alpha weighting</strong> and <strong>exponential averages</strong>—mathematical tricks that use a job’s recent history to guess its future. We don't solve the paradox; we merely build sophisticated models to hide our ignorance.</p>
<p>--------------------------------------------------------------------------------</p>
<h2 id="heading-2-the-grocery-store-nightmare-understanding-the-convoy-effect">2. The Grocery Store Nightmare: Understanding the Convoy Effect</h2>
<p>The simplest way to schedule tasks is "First-Come, First-Served" (FCFS). While this is inherently "fair" in the same way a grocery store line is fair, it leads to a performance disaster known as the <strong>Convoy Effect</strong>.</p>
<p>If a single, resource-heavy process (a "CPU-bound hog") reaches the head of the line, every other task must wait. In a multiprogramming system where users expect instant feedback, this turns a high-performance machine into a backlog.</p>
<p><strong>The Impact of the Convoy Effect:</strong></p>
<ul>
<li><p><strong>Increased Average Wait Times:</strong> Short, interactive tasks suffer massive, unnecessary delays behind a singular heavy process.</p>
</li>
<li><p><strong>Lower CPU Utilization:</strong> The processor may cycle through short tasks quickly and then sit under-taxed while waiting for the "convoy" to reach a breaking point.</p>
</li>
<li><p><strong>Lower Device Utilization:</strong> This is the hidden cost; I/O devices (like your NVMe drive or network card) sit idle because the processes that need them are trapped in the CPU queue, unable to even ask for data.</p>
</li>
</ul>
<p>--------------------------------------------------------------------------------</p>
<h2 id="heading-3-the-starvation-crisis-when-low-priority-means-forever">3. The "Starvation" Crisis: When Low Priority Means Forever</h2>
<p>Priority-based scheduling allows an OS to rank tasks by importance. System-critical tasks get the CPU first, while background updates wait. This sounds logical, but it creates the risk of <strong>starvation:</strong> a scenario where a low-priority process waits for the CPU and never receives it because a steady stream of higher-priority tasks keeps cutting in line.</p>
<p>"If high-priority processes use up a lot of CPU time, lower-priority processes may starve and be postponed indefinitely. The situation where a process never gets scheduled to run is called starvation."</p>
<p>The architectural solution is <strong>aging.</strong> By gradually increasing the priority of a process the longer it waits, we transform a <strong>static</strong> priority system into a <strong>dynamic</strong> one. It is a human-like logic: even the most insignificant background task eventually becomes "old" enough that its needs become urgent, forcing the scheduler to listen.</p>
<p>--------------------------------------------------------------------------------</p>
<h2 id="heading-4-the-algorithm-that-watches-you-the-genius-of-mlfq">4. The Algorithm That Watches You: The Genius of MLFQ</h2>
<p>The Multi-Level Feedback Queue (MLFQ) is perhaps the most sophisticated approach to scheduling because it "learns" from history. It doesn't need to see the future; it simply watches how processes behave. MLFQ uses multiple queues with varying priorities and follows a strict set of rules to categorize jobs:</p>
<ul>
<li><p><strong>Rule 3:</strong> All new jobs enter at the highest priority queue.</p>
</li>
<li><p><strong>Rule 4:</strong> Once a job uses up its time allotment at a given level (even across multiple bursts), its priority is reduced. It is demoted to a lower queue.</p>
</li>
<li><p><strong>Rule 5 (The Priority Boost):</strong> To prevent starvation and accommodate jobs that change from CPU-bound to interactive, all jobs are periodically moved back to the topmost queue after a specific time period (S).</p>
</li>
</ul>
<p>MLFQ approximates the elusive Shortest Job First ideal by identifying and rewarding interactive tasks that give up the CPU quickly. However, it is notoriously difficult to tune. Engineers must decide on <strong>"Voodoo Constants"</strong>—arbitrary values for time slices and boost intervals—to prevent "gaming" the system, where a clever program might relinquish the CPU at 99% of its allotment just to stay in a high-priority queue.</p>
<p>--------------------------------------------------------------------------------</p>
<h2 id="heading-5-the-hidden-war-windows-vs-linux-philosophy">5. The Hidden War: Windows vs. Linux Philosophy</h2>
<p>The performance divide between Windows and Linux, particularly on modern multi-core Ryzen hardware, stems from a fundamental disagreement on how to handle thread migration across <strong>CCX (Core Complex) boundaries</strong>.</p>
<div class="hn-table">
<table>
<thead>
<tr>
<td>Feature</td><td>Windows Scheduler</td><td>Linux CFS (Completely Fair Scheduler)</td></tr>
</thead>
<tbody>
<tr>
<td><strong>Primary Philosophy</strong></td><td><strong>Load Balancing:</strong> Aggressively moving threads to spread heat and load evenly.</td><td><strong>Core Affinity:</strong> Keeping threads on the same core to maintain "cache warmth."</td></tr>
<tr>
<td><strong>Data Integrity</strong></td><td>High-frequency migration moves threads "willy-nilly" across logical cores.</td><td>Low-frequency migration uses <strong>red-black trees</strong> to track <strong>vruntime</strong>.</td></tr>
<tr>
<td><strong>Hardware Awareness</strong></td><td>Not SMT-aware (though core-parking is); often blind to CCX cache boundaries.</td><td>Fully SMT/SMP aware; prioritizes keeping data local to the core.</td></tr>
<tr>
<td><strong>Trade-off</strong></td><td><strong>Cache Thrashing:</strong> Data is dragged across the die, increasing latency.</td><td><strong>Efficiency:</strong> Reduces context-switch overhead by keeping data resident.</td></tr>
</tbody>
</table>
</div><p>Windows often prioritizes thermal management, but this results in "cache thrashing." On a Ryzen chip, if Windows moves a thread from one CCX to another, that thread must laboriously pull its data from the cache of the previous complex. Linux's CFS instead uses a red-black tree to track a variable called <code>vruntime</code> (virtual runtime)” aiming for a system where every process gets a "fair" share of the CPU while staying on the same core long enough to keep its cache hot and efficient.</p>
<p>--------------------------------------------------------------------------------</p>
<h2 id="heading-conclusion-the-future-of-fairness">Conclusion: The Future of Fairness</h2>
<p>CPU scheduling is a relentless balancing act between raw efficiency, maximum throughput, and the "perceived" responsiveness that makes a computer feel alive. We have seen that a "perfect" algorithm is a mathematical impossibility; there are only trade-offs and clever deceptions.</p>
<p>Every time you use your computer, you are benefiting from a system that is essentially "gaming" its own rules—demoting background tasks and protecting interactive ones—to make your experience feel fluid. It raises a final, philosophical question for the next generation of architects: Is a truly "fair" system even desirable, or do we prefer a master of deception that knows exactly which rules to break to keep us productive?</p>
]]></content:encoded></item><item><title><![CDATA[What I Feel]]></title><description><![CDATA[When My Mind Was Quiet
Picture this: a quiet evening a few years ago.
I’m sitting in my favorite corner of the room. No phone in my hand. No screen glowing in my face. Just silence—and my thoughts. My mind feels calm, like still water. I know what I ...]]></description><link>https://theretrosway.hashnode.dev/what-i-feel</link><guid isPermaLink="true">https://theretrosway.hashnode.dev/what-i-feel</guid><category><![CDATA[technology]]></category><category><![CDATA[#mood]]></category><category><![CDATA[Feelings]]></category><category><![CDATA[mobile]]></category><category><![CDATA[student]]></category><dc:creator><![CDATA[ASN]]></dc:creator><pubDate>Sun, 25 Jan 2026 06:03:00 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/stock/unsplash/jLwVAUtLOAQ/upload/e7aa801b86518e7c1b3536d5023c6f41.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h3 id="heading-when-my-mind-was-quiet">When My Mind Was Quiet</h3>
<p>Picture this: a quiet evening a few years ago.</p>
<p>I’m sitting in my favorite corner of the room. No phone in my hand. No screen glowing in my face. Just silence—and my thoughts. My mind feels calm, like still water. I know what I want from life. My ambitions are clear. My goals feel real.</p>
<p>“I’ll build that app.”<br />“I’ll learn that skill.”<br />“I’ll get that job.”</p>
<p>Everything feels possible. The future feels open. Time feels like it’s on my side.</p>
<p>Back then, I didn’t feel lost. I didn’t feel rushed. Even when I did nothing, my mind felt relaxed.</p>
<h3 id="heading-fast-forward-to-now">Fast Forward to Now</h3>
<p>Now things feel different.</p>
<p>Sometimes I just lie there, staring at the ceiling, thinking:<br /><em>What am I even doing?</em><br /><em>Where did I end up?</em><br /><em>What happened to the person I wanted to become?</em></p>
<p>The fire I once had feels weak. My days pass in pieces—starting things, stopping halfway, forgetting what I planned to do. I still know what I <em>should</em> do. That clarity hasn’t disappeared completely. But my mind feels crowded. Too many thoughts. Too many voices.</p>
<p>Emails. Notifications. Messages.<br />One thing after another.</p>
<p>Before I realize it, the day is gone.</p>
<h3 id="heading-the-phone-in-my-hand">The Phone in My Hand</h3>
<p>And honestly, most of it comes down to one thing—my phone.</p>
<p>I love technology. I always have. I love gadgets, new features, clean design. As a tech person, that excitement is natural for me.</p>
<p>But there’s a difference between <em>loving technology</em> and <em>letting it control your time</em>.</p>
<p>My phone is always there. In my pocket. On my bed. On the table. I pick it up for “just a minute”… and suddenly hours are gone.</p>
<p>Scrolling.<br />Watching random videos.<br />Reading things that don’t matter.</p>
<p>Lying on the couch, swiping endlessly. Memes that aren’t funny. Videos that don’t teach anything. Content that feels good for five seconds and empty right after.</p>
<p>It’s so easy. Too easy.</p>
<p>And that’s the problem.</p>
<h3 id="heading-autopilot-mode">Autopilot Mode</h3>
<p>I remember one moment clearly.</p>
<p>I was supposed to work on a project—something connected to my old goals. Instead, I was deep into what I call “shitty things.” Pointless content. Useless arguments. Stuff that adds nothing to my life.</p>
<p>My brain just shut off.</p>
<p>No thinking. No awareness. Just autopilot.</p>
<p>When the phone is in my hand, time flies. It’s automatic. Effortless. And because it’s effortless, it’s dangerous.</p>
<p>No setup. No sitting properly. No intention.<br />Just unlock → scroll → waste time.</p>
<h3 id="heading-why-the-laptop-feels-different">Why the Laptop Feels Different</h3>
<p>That’s when I realized something important.</p>
<p>When I use my laptop, things change.</p>
<p>I have to sit properly.<br />I have to open it.<br />I have to type.</p>
<p>There’s effort involved.</p>
<p>And that small effort creates focus.</p>
<p>On a laptop, my mind keeps asking me:<br /><em>What are you here to do?</em></p>
<p>When I try to open something useless, I feel it. My mind reminds me:<br />“If you’re spending time, why not use it to improve yourself?”</p>
<p>That reminder never comes on my phone.<br />But on my laptop, it’s always there.</p>
<h3 id="heading-choosing-better-not-perfect">Choosing Better, Not Perfect</h3>
<p>I’m not quitting technology. I still love it. I still get excited about new ideas, tools, and innovations.</p>
<p>But now I understand the difference.</p>
<p>Loving tech means using it as a <strong>tool</strong>, not a <strong>trap</strong>.</p>
<p>So I’ve decided to reduce my phone use. Calls. Important messages. That’s it. For real work, learning, and building—I choose my laptop.</p>
<p>Because focus needs space.<br />And clarity needs effort.</p>
<h3 id="heading-finding-my-way-back">Finding My Way Back</h3>
<p>If you’re reading this and feeling the same way, you’re not broken. You’re not lazy. You’re just living in a world designed to distract you.</p>
<p>Try this: put the phone away. Sit down. Open your laptop. Sit quietly for a moment.</p>
<p>You might feel uncomfortable at first. That’s okay.</p>
<p>That quiet mind you once had?<br />It’s still there.</p>
<p>And maybe, slowly, your old ambitions will come back—not all at once, but one focused moment at a time.</p>
<p>Because the best stories aren’t about getting lost.</p>
<p>They’re about finding your way back.</p>
]]></content:encoded></item></channel></rss>