当前位置: 首页 > news >正文

个人全屏网站模板网站电子地图怎么做

个人全屏网站模板,网站电子地图怎么做,深圳网站设计公司排名前十,关键词优化排名软件哪家好目录#xff08;一#xff09;内核定时器介绍#xff08;二#xff09;内核定时器相关接口#xff08;三#xff09;使用步骤#xff08;四#xff09;实例代码#xff08;一#xff09;内核定时器介绍 内核定时器并不是用来简单的定时操作#xff0c;而是在定时时… 目录一内核定时器介绍二内核定时器相关接口三使用步骤四实例代码一内核定时器介绍 内核定时器并不是用来简单的定时操作而是在定时时间后触发事件的操作类似定时器中断是内核用来控制在未来某个时间点基于jiffies调度执行某个函数的一种机制内核中采用的定时器以jiffies为单位。 单位秒jiffies/HZ 几个重要跟时间有关的名词或变数 HZLinux核心每隔固定周期会发出timer interrupt (IRQ 0)HZ是用来定义每一秒有几次timer interrupts。举例来说HZ为1000代表每秒有1000次timer interrupts。 TickTick是HZ的倒数意即timer interrupt每发生一次中断的时间。如HZ为250时tick为4毫秒(millisecond)。 JiffiesJiffies为Linux核心变数(unsigned long)它被用来记录系统自开机以来已经过了多少tick。每发生一次timer interruptJiffies变数会被加一。值得注意的是Jiffies于系统开机时并非初始化成零而是被设为-300*HZ 类似Linux系统中time日历时间二内核定时器相关接口 和定时器先关的数据结构 struct timer_list {unsigned long expires; //未来时间点即超时时间void (*function)(unsigned long);//超时回调函数unsigned long data; //传递给回调函数的数据也就是定时器数据 };初始化定时器相关的数据结构 1. 静态定以定时器数据结构 #define DEFINE_TIMER(_name, _function, _expires, _data) \struct timer_list _name \TIMER_INITIALIZER(_function, _expires, _data)2. 动态初始化-----手动对变量进行初始化 #define init_timer(timer) \do { \static struct lock_class_key __key; \init_timer_key((timer), #timer, __key); \} while (0)可延时定时 #define init_timer_deferrable(timer) \do { \static struct lock_class_key __key; \init_timer_deferrable_key((timer), #timer, __key); \} while (0)设置定时时间 #define setup_timer(timer, fn, data) \ do { \static struct lock_class_key __key; \setup_timer_key((timer), #timer, __key, (fn), (data));\ } while (0)向内核添加定时器: /*** add_timer - start a timer* timer: the timer to be added** The kernel will do a -function(-data) callback from the* timer interrupt at the -expires point in the future. The* current time is jiffies.** The timers -expires, -function (and if the handler uses it, -data)* fields must be set prior calling this function.** Timers with an -expires field in the past will be executed in the next* timer tick.*/ void add_timer(struct timer_list *timer) {BUG_ON(timer_pending(timer));mod_timer(timer, timer-expires); }从内核删除定时器 /*** del_timer - deactive a timer.* timer: the timer to be deactivated** del_timer() deactivates a timer - this works on both active and inactive* timers.** The function returns whether it has deactivated a pending timer or not.* (ie. del_timer() of an inactive timer returns 0, del_timer() of an* active timer returns 1.)*/ int del_timer(struct timer_list *timer)修改定时时间 /*** mod_timer - modify a timers timeout* timer: the timer to be modified* expires: new timeout in jiffies** mod_timer() is a more efficient way to update the expire field of an* active timer (if the timer is inactive it will be activated)** mod_timer(timer, expires) is equivalent to:** del_timer(timer); timer-expires expires; add_timer(timer);** Note that if there are multiple unserialized concurrent users of the* same timer, then mod_timer() is the only safe way to modify the timeout,* since add_timer() cannot modify an already running timer.** The function returns whether it has modified a pending timer or not.* (ie. mod_timer() of an inactive timer returns 0, mod_timer() of an* active timer returns 1.)*/ int mod_timer(struct timer_list *timer, unsigned long expires)jiffies和时间的转换 extern unsigned int jiffies_to_msecs(const unsigned long j); extern unsigned int jiffies_to_usecs(const unsigned long j); extern unsigned long msecs_to_jiffies(const unsigned int m); extern unsigned long usecs_to_jiffies(const unsigned int u);三使用步骤 1、向内核添加定时器 setup_timer();设置定时器add_timer();.2、解绑定时器 int del_timer(struct timer_list *timer)四实例代码 #include linux/timer.h #include linux/kernel.h #include linux/module.hstruct timer_list timer; void function(unsigned long data) {static int count0;printk(this is timer test:%d\n,count);mod_timer(timer,jiffies1*HZ); } static int __init timer_module_init(void) {timer.expires jiffies5*HZ;setup_timer(timer,function,0);add_timer(timer);return 0; } static void __exit timer_module_cleanup(void) {del_timer(timer); }module_init(timer_module_init); module_exit(timer_module_cleanup); MODULE_LICENSE(GPL);本文章仅供学习交流用禁止用作商业用途文中内容来水枂编辑如需转载请告知谢谢合作 微信公众号zhjj0729 微博文艺to青年
http://www.pierceye.com/news/291864/

相关文章:

  • 济南网站建设 伍际网络网站域名备案授权书
  • 网站开发销售提成网站建设的内部风险分析
  • 网站建设框架都有哪些内容公司名字大全参考2022
  • 成功备案的网站增加域名黄金网站
  • 学习网站开发多少钱北京网页设计公司兴田德润可以吗
  • 如何加强门户网站建设上海好的设计公司
  • h5企业模板网站模板营销推广的渠道方式
  • 怎么学做网站PHP百度搜索风云榜总榜
  • 网站风格模板公司建设官方网站
  • 做站群一个网站多少钱网络服务器的分类
  • 专业的常州做网站营销推广48个方法
  • 开奖网站怎么做wordpress4.9.8中文版
  • 国外做任务的网站网推公司
  • 国外有在线做设计方案的网站吗为什么用Vue做网站的很少
  • 网站一定要备案网站建设与维护工作
  • 锦江区建设和交通局网站怎样在网上建立平台
  • 网站维护升级访问中六安论坛网站
  • ppt模板网站哪个免费重庆手机版建站系统哪家好
  • 35岁学设计晚不晚北京网站快速排名优化
  • 网站建设三合一 500元阜阳网站建设公司
  • 那些公司需要网站开发工程师网页开发与网站开发
  • 手机端网站如何做排名wordpress no7
  • 搭建网站什么意思o2o的典型电子商务平台
  • vs2013网站开发教程wordpress站内搜索框
  • 素材网站怎么做利用小程序反向做网站
  • 怎么自己做网站地图做网站详细步骤
  • 做网站的整体风格确定方式郑州seo代理外包
  • 语种网站建设沭阳做网站好的
  • wordpress网站换字体颜色网站建设案例包括哪些
  • 北京市环境建设办公室网站怎么找到合适的网站建设商