Linux内核中的Microsecond Sleep

时间:2015-08-28 05:59:29

标签: linux-kernel delay sleep

udelay()mdelay()usleep_range()都会给出运行时错误:

symbol lookup error: undefined symbol: __const_udelay

我尝试使用ns3-DCE-linux,因此我能够看到错误,但在Linux内核中,我得到内核恐慌。

here udelay()定义为宏。

#define udelay(n)                                                \
 ({                                                              \
         if (__builtin_constant_p(n)) {                          \
                 if ((n) / 20000 >= 1)                           \
                          __bad_udelay();                        \
                 else                                            \
                         __const_udelay((n) * 0x10c7ul);         \
         } else {                                                \
                 __udelay(n);                                    \
         }                                                       \
 })

来自here mdelay()被定义为使用udelay()的宏。

#ifndef mdelay
#define mdelay(n) (\
        (__builtin_constant_p(n) && (n)<=MAX_UDELAY_MS) ? udelay((n)*1000) : \
        ({unsigned long __ms=(n); while (__ms--) udelay(1000);}))
#endif
经过长时间跟踪后,

usleep_range()也会使用udelay()

我可以清楚地看到__const_udelay() here的定义。

inline void __const_udelay(unsigned long xloops)
 {
         int d0;

         xloops *= 4;
         asm("mull %%edx"
                 :"=d" (xloops), "=&a" (d0)
                 :"1" (xloops), ""
                 (this_cpu_read(cpu_info.loops_per_jiffy) * (HZ/4)));

         __delay(++xloops);
 }
 EXPORT_SYMBOL(__const_udelay);

并包含在extern here

extern void __const_udelay(unsigned long xloops);

唯一有效的是msleep()

无论如何,我可以在内核中进行几微秒的睡眠吗? (延迟或睡觉。但最好是睡觉。)

上述错误的原因是什么?这个硬件依赖吗?如何解决错误?

0 个答案:

没有答案