Why does “while(true)” without “Thread.sleep” cause 100% CPU usage on Linux but not on Windows? Why does “while(true)” without “Thread.sleep” cause 100% CPU usage on Linux but not on Windows? linux linux

Why does “while(true)” without “Thread.sleep” cause 100% CPU usage on Linux but not on Windows?


By default, top on Linux runs in so-called IRIX mode, while the Windows Task Manager does not. Let's say you have 4 cores:

  • With IRIX mode on, 1 fully utilized core is 100% and 4 cores are 400%.

  • With IRIX mode off, 1 fully utilized core is 25% and 4 cores are 100%.

This means that by default, top on Linux will show an infinite loop as ~100% and Windows will show it as ~25%, and it means exactly the same thing.

You can toggle IRIX mode while top is running with Shift+i. This will make the numbers match up.