<?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" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Raj.Harini on Medium]]></title>
        <description><![CDATA[Stories by Raj.Harini on Medium]]></description>
        <link>https://medium.com/@raj.harini2006?source=rss-cf6fc2fe838c------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*4_baQ25BeKMiREPH</url>
            <title>Stories by Raj.Harini on Medium</title>
            <link>https://medium.com/@raj.harini2006?source=rss-cf6fc2fe838c------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 15:40:37 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@raj.harini2006/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Why Operating Systems Hate Infinite Loops]]></title>
            <link>https://medium.com/@raj.harini2006/why-operating-systems-hate-infinite-loops-1f1af37fb8e4?source=rss-cf6fc2fe838c------2</link>
            <guid isPermaLink="false">https://medium.com/p/1f1af37fb8e4</guid>
            <dc:creator><![CDATA[Raj.Harini]]></dc:creator>
            <pubDate>Wed, 04 Feb 2026 13:59:54 GMT</pubDate>
            <atom:updated>2026-02-04T13:59:54.889Z</atom:updated>
            <content:encoded><![CDATA[<p>If you’ve ever written code like this:</p><pre>while(1) {<br>    // do nothing<br>}</pre><p>…and watched your computer slow down, heat up, or freeze, congratulations you’ve just discovered one of an operating system’s biggest enemies.</p><p><strong>Infinite loops.</strong></p><p>Operating systems don’t hate them because they’re poorly written.<br> They hate them because infinite loops break the rules that operating<strong> </strong>systems live by.</p><p>Let’s unpack why.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*uXwGnvT75XpmbQGW" /></figure><h3>What an Infinite Loop Really Means to an OS</h3><p>To a programmer, an infinite loop is just:</p><blockquote><em>“A loop that never ends.”</em></blockquote><p>To an operating system, an infinite loop means:</p><ul><li>A process that never voluntarily stops</li><li>A program that may never release the CPU</li><li>A task that refuses to cooperate</li></ul><p>And modern operating systems are built on one critical assumption:</p><blockquote>Every process will eventually give someone else a turn.</blockquote><p>An infinite loop says: “No.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/272/0*TTfoUVboz8n0dLC1" /></figure><h3>The CPU Is a Shared Resource (Not Yours Alone)</h3><p>Your CPU is not dedicated to one program.</p><p>At any moment, it’s shared between:</p><ul><li>Your browser</li><li>Music player</li><li>System services</li><li>Background tasks</li><li>The OS itself</li></ul><p>Operating systems like Linux and Windows rely on time-sharing.</p><p>Each process gets:</p><ul><li>A small slice of CPU time</li><li>Then it must step aside</li></ul><p>An infinite loop tries to consume every slice it gets — forever.</p><h3>Why Infinite Loops Are Dangerous (OS View)</h3><h3>1. CPU Starvation</h3><p>If a loop:</p><ul><li>Does heavy computation</li><li>Never blocks</li><li>Never sleeps</li></ul><p>Then other processes:</p><ul><li>Get delayed</li><li>Become sluggish</li><li>May stop responding</li></ul><p>This is called CPU starvation.</p><p>The OS scheduler is forced to fight the loop just to keep the system alive.</p><h3>2. They Break the Illusion of Multitasking</h3><p>Your OS creates an illusion that everything runs at once.</p><p>It does this using:</p><ul><li>Time slicing</li><li>Context switching</li></ul><p>But infinite loops:</p><ul><li>Increase context switches</li><li>Reduce responsiveness</li><li>Expose scheduling limits</li></ul><p>That’s when you feel:</p><blockquote><em>“My system is lagging.”</em></blockquote><p>The illusion collapses.</p><h3>3. They Trigger Thermal and Power Issues</h3><p>Infinite loops:</p><ul><li>Keep CPU cores active</li><li>Prevent low-power states</li><li>Increase heat generation</li></ul><p>On laptops, this means:</p><ul><li>Loud fans</li><li>Battery drain</li><li>Thermal throttling</li></ul><p>The OS tries to save power — the infinite loop refuses.</p><h3>Why the OS Can’t “Just Stop” the Loop</h3><p>You might wonder:</p><blockquote><em>“Why doesn’t the OS simply kill the loop?”</em></blockquote><p>Because:</p><ul><li>The OS doesn’t know your intent</li><li>Some infinite loops are legitimate</li></ul><p>Examples:</p><ul><li>Event loops (GUI apps)</li><li>Web servers</li><li>Daemons</li></ul><p>The OS must assume:</p><blockquote>An infinite loop might be doing something important.</blockquote><p>So instead of killing it, the OS:</p><ul><li>Limits its CPU time</li><li>Adjusts priority</li><li>Monitors its behavior</li></ul><h3>Preemption: The OS’s Defense Mechanism</h3><p>Modern OSs use preemptive multitasking.</p><p>That means:</p><ul><li>A timer interrupt fires</li><li>The OS forcibly takes back the CPU</li><li>Another process gets scheduled</li></ul><p>Without preemption:</p><ul><li>One infinite loop could freeze the entire system</li></ul><p>Early systems actually suffered from this</p><h3>When Infinite Loops Become Truly Dangerous</h3><p>Infinite loops become critical when they:</p><h3>Run in Kernel Mode</h3><ul><li>Device drivers</li><li>Kernel modules</li><li>OS core services</li></ul><p>Here, the OS cannot preempt safely.</p><p>Result:</p><ul><li>System hang</li><li>Kernel panic</li><li>Blue screen</li></ul><p>This is why kernel code is written with extreme caution.</p><h3>Why OS Textbooks Warn You About This</h3><p>Infinite loops are used in OS courses to teach:</p><ul><li>Scheduling</li><li>Starvation</li><li>Deadlocks</li><li>Resource fairness</li></ul><p>They expose why the OS exists in the first place:</p><blockquote><em>To stop one program from ruining everything else.</em></blockquote><h3>Final Thought</h3><p>Infinite loops aren’t evil.<br> But they demand discipline.</p><p>From an OS perspective, infinite loops:</p><ul><li>Challenge fairness</li><li>Stress schedulers</li><li>Reveal system limits</li></ul><p>Every time your computer slows down because of one program, remember:</p><blockquote><em>The operating system is working overtime to protect you — from a loop that refuses to stop.</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*zT3S4K7vWFk8Kgnn" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1f1af37fb8e4" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>