I have created a simple program in java:
我在java中创建了一个简单的程序:
public static void main(String[] args) throws InterruptedException {
while (true)
;
}
If I run this on a Linux machine, it shows 100% CPU usage, but doesn't cause the OS to appear slow. However, if I run the exact same code on Windows, it only shows about 20% CPU usage.
如果我在Linux机器上运行这个程序,它会显示100%的CPU使用率,但是不会导致操作系统出现缓慢。但是,如果我在Windows上运行相同的代码,它只显示大约20%的CPU使用率。
I am using Oracle JRE on Windows and OpenJDK 6 on Linux.
我在Windows上使用Oracle JRE,在Linux上使用OpenJDK 6。
I'm wondering if Windows' scheduler preempt threads randomly and Linux's doesn't?
我想知道Windows的调度器是否会随机抢占线程,而Linux不是?
1 个解决方案
#1
384
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:
默认情况下,Linux上的top运行在所谓的IRIX模式下,而Windows任务管理器没有。假设你有4个核:
-
With IRIX mode on, 1 fully utilized core is 100% and 4 cores are 400%.
在IRIX模式下,1个充分利用的核心是100%,4个核心是400%。
-
With IRIX mode off, 1 fully utilized core is 25% and 4 cores are 100%.
在IRIX模式关闭后,1个完全利用的核心是25%,4个核心是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.
这意味着默认情况下,Linux上的top将显示一个无限循环~100%,Windows将显示为~25%,这是完全相同的意思。
You can toggle IRIX mode while top
is running with Shift+i. This will make the numbers match up.
当top运行Shift+i时,你可以切换IRIX模式。这将使数字匹配。
#1
384
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:
默认情况下,Linux上的top运行在所谓的IRIX模式下,而Windows任务管理器没有。假设你有4个核:
-
With IRIX mode on, 1 fully utilized core is 100% and 4 cores are 400%.
在IRIX模式下,1个充分利用的核心是100%,4个核心是400%。
-
With IRIX mode off, 1 fully utilized core is 25% and 4 cores are 100%.
在IRIX模式关闭后,1个完全利用的核心是25%,4个核心是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.
这意味着默认情况下,Linux上的top将显示一个无限循环~100%,Windows将显示为~25%,这是完全相同的意思。
You can toggle IRIX mode while top
is running with Shift+i. This will make the numbers match up.
当top运行Shift+i时,你可以切换IRIX模式。这将使数字匹配。