热门问题
时间线
聊天
视角
BogoMips
来自维基百科,自由的百科全书
Remove ads
BogoMips ("bogus"与MIPS,伪MIPS) 是一种衡量CPU速度的不科学方法。当计算机内核启动时,将执行一个计数循环。
此条目翻译质量不佳。 (2023年6月28日) |
![]() | 此条目可参照英语维基百科相应条目来扩充。 (2023年6月28日) |
对于特定的CPU,BogoMips可用来查看它是否个合适的值。它的时钟频率和它潜在的CPU缓存。但是它不可在不同的CPU间进行比较演示。[1]
合适的BogoMips比率
作为一个参考向导,BogoMips可以用下列的表格进行预计算。给出的比率是以应用到LINUX版本的CPU作为例子。指数是指其它CPU同Intel 386DX CPU的BogoMips/clock speed比率.
Remove ads
BogoMIPS 怎么计算的?
在当前内核(2.6.x),BogoMIPS实现在内核源文件/usr/src/linux/init/calibrate.c
。它计算了Linux内核定时参数loops_per_jiffy
(see Jiffy ) 值。源码解释如下:
/* * A simple loop like * while ( jiffies < start_jiffies+1) * start = read_current_timer(); * will not do. As we don't really know whether jiffy switch * happened first or timer_value was read first. And some asynchronous * event can happen between these two events introducing errors in lpj. * * So, we do * 1. pre_start <- When we are sure that jiffy switch hasn't happened * 2. check jiffy switch * 3. start <- timer value before or after jiffy switch * 4. post_start <- When we are sure that jiffy switch has happened * * Note, we don't know anything about order of 2 and 3. * Now, by looking at post_start and pre_start difference, we can * check whether any asynchronous event happened or not */
loops_per_jiffy
is used to implement udelay
(delay in microseconds) and ndelay
(delay in nanoseconds) functions. These functions are needed by some drivers to wait for hardware. Note that a busy waiting technique is used, so the kernel is effectively blocked when executing ndelay/udelay
functions. For i386 architecture delay_loop
is implemented in /usr/src/linux/arch/i386/lib/delay.c
as:
/* simple loop based delay: */
static void delay_loop(unsigned long loops)
{
int d0;
__asm__ __volatile__(
"\tjmp 1f\n"
".align 16\n"
"1:\tjmp 2f\n"
".align 16\n"
"2:\tdecl %0\n\tjns 2b"
:"=&a" (d0)
:"0" (loops));
}
用C语言重写的代码如下:
static void delay_loop(long loops)
{
long d0 = loops;
do {
--d0;
} while (d0 >= 0);
}
关于BogoMips更丰富更全的信息和数百篇相关文章可参见 BogoMips mini-Howto.[1]
Remove ads
参考
外部链接
Wikiwand - on
Seamless Wikipedia browsing. On steroids.
Remove ads