Why udelay and ndelay is not accurate in linux kernel?

前端 未结 3 1243
萌比男神i
萌比男神i 2021-01-15 05:57

I make a function like this

trace_printk(\"111111\");
udelay(4000);
trace_printk(\"222222\");

and the log shows it\'s 4.01 ms , it\'OK

3条回答
  •  清酒与你
    2021-01-15 06:20

    Every time you call it, a rounding error is added. Note the comment 2**32 / 1000000000. That value is really ~4.29, but it was rounded up to 5. That's a pretty hefty error.

    By contrast the udelay error is small: (~4294.97 versus 4295 [0x10c7]).

提交回复
热议问题