#include <linux/delay.h>
Simple sleeping in the kernel
简单睡眠函数。passive delay ,睡眠时让出CPU资源,非原子操作中用;
usleep_range(unsigned long min, unsigned long max) #微秒,下面三个单位是毫秒ms,10微秒到20毫秒间的短暂睡眠用,10毫秒以上用msleep;
msleep(unsigned long msecs)
msleep(unsigned long msecs)
msleep_interruptible(unsigned long msecs)
Kernel delay or busy waiting
buzy waiting中犹如while(1)空转等待,消耗CPU,因此优点是原子操作或非原子都可以使用
ndelay(unsigned long nsecs) #低频率的嵌入式系统可能不精确。。。
udelay(unsigned long usecs) #建议10毫秒以下延迟使用
mdelay(unsigned long msecs)
Understanding Linux kernel time management
CONFIG_HIGH_RES_TIMERS 高分辨率计时器
list clock source devices:
dmesg | grep clocksource
cat /sys/devices/system/clocksource/clocksource0/available_clocksource


The clockevent framework and clock event devices
list the available clock event devices : ls /sys/devices/system/clockevents/ #每个CPU核心有一个clockevent


CONFIG_HIGH_RES_TIMERS allows the use of hrtimer APIs
CONFIG_NO_HZ enabling dynamic tick support
Broadcast tick device This always-on timer is called a broadcast clock device #其他tickdevice可能因为电源管理设置而关闭省电,这个一直开着,用来叫醒idle cpu,wake_up_nohz_cpu()
cat /sys/devices/system/clockevents/broadcast/current_device

kernel/time/tick-broadcast.c
Understanding the sched_clock function; unsigned long long __weak sched_clock(void) returns the number of nanoseconds since the system started; kernel/sched/clock.c
此后看中文版了 ,英文的太慢了。。。。。。。