Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Special pages
Niidae Wiki
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
BogoMips
(section)
Page
Discussion
English
Read
Edit
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== Computation of BogoMips == With kernel 2.6.x, BogoMips are implemented in the <code>/usr/src/linux/init/calibrate.c</code> kernel source file. It computes the Linux kernel timing parameter <code>loops_per_jiffy</code> (see [[jiffy (time)|jiffy]]) value. The explanation from source code: <pre><nowiki> /* * 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 */ </nowiki></pre> <code>loops_per_jiffy</code> is used to implement <code>udelay</code> (delay in microseconds) and <code>ndelay</code> (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 <code>ndelay</code>/<code>udelay</code> functions. For i386 architecture <code>delay_loop</code> is implemented in <code>/usr/src/linux/arch/i386/lib/delay.c</code> as: <syntaxhighlight lang="c"> /* 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)); } </syntaxhighlight> equivalent to the following assembler code <syntaxhighlight lang="asm"> ; input: eax = d0 ; output: eax = 0 jmp start .align 16 start: jmp body .align 16 body: decl eax jns body </syntaxhighlight> which can be rewritten to C-pseudocode <syntaxhighlight lang="c"> static void delay_loop(long loops) { long d0 = loops; do { --d0; } while (d0 >= 0); } </syntaxhighlight> Full and complete information and details about BogoMips, and hundreds of reference entries can be found in the (outdated) BogoMips mini-Howto.<ref name=howto/>
Summary:
Please note that all contributions to Niidae Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Encyclopedia:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Search
Search
Editing
BogoMips
(section)
Add topic