delay.c

来自「xen虚拟机源代码安装包」· C语言 代码 · 共 31 行

C
31
字号
/* * Precise Delay Loops for i386 * * Copyright (C) 1993 Linus Torvalds * Copyright (C) 1997 Martin Mares <mj@atrey.karlin.mff.cuni.cz> * * The __delay function must _NOT_ be inlined as its execution time * depends wildly on alignment on many x86 processors. The additional * jump magic is needed to get the timing stable on all the CPU's * we have to worry about. */#include <xen/config.h>#include <xen/delay.h>#include <xen/time.h>#include <asm/msr.h>#include <asm/processor.h>void __udelay(unsigned long usecs){    unsigned long ticks = usecs * (cpu_khz / 1000);    unsigned long s, e;    rdtscl(s);    do    {        rep_nop();        rdtscl(e);    } while ((e-s) < ticks);}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?