linux驱动开发------ 时间

 
#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

此后看中文版了 ,英文的太慢了。。。。。。。

 

 

posted @   杨大茄子  阅读(148)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· winform 绘制太阳,地球,月球 运作规律
· AI与.NET技术实操系列(五):向量存储与相似性搜索在 .NET 中的实现
· 超详细:普通电脑也行Windows部署deepseek R1训练数据并当服务器共享给他人
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 上周热点回顾(3.3-3.9)
点击右上角即可分享
微信分享提示