热门问题
时间线
聊天
视角
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