初探linux子系统集之timer子系统(一)
来源:互联网 发布:桃源网络硬盘 编辑:程序博客网 时间:2024/05/15 03:47
一般来说要让整个linux系统跑起来,那么一个必须的就是linux的时钟,也就是时间子系统了,这里正好工作需要,那么就研究下linux下的时间子系统了。
linux内核必须完成两种主要的定时测量。一个是计时,保存当前的时间和日期,以便能通过time(),gettimeofday()等系统调用,返回给用户程序,另一个是定时,这种机制主要是告诉内核或者应用程序,某一时间间隔已经过去了,触发回调函数,然后做一些事情。
对于硬件主要有实时时钟RTC和CPU本地Timer,其中RTC是cpu外部的其他芯片,或者内部的模块,不过都是需要外部单独提供类似纽扣电池供电。Linux只用RTC来获取时间和日期,关于RTC以后在rtc子系统里面再详细介绍。CPU本地Timer其实就是用的CPU内部的Timer模块,一般是CPU的Timer模块可以计数,当然这个是通过晶振再加上倍频分频等给主芯片的,然后主芯片内部根据跑的不同主频来实现计数,这个计数只能递增或者递减,然后溢出后会有中断,一般是可以设置这个溢出的值的。嵌入式系统要跑起来,都需要时钟,具体的移植代码主要在arch下,根据不同的体系做不通的移植。
linux具有Dynamic Ticks和High Resolution Timer, 详细可以参考kernel/time/Kconfig下。
config TICK_ONESHOTboolconfig NO_HZbool "Tickless System (Dynamic Ticks)"depends on !ARCH_USES_GETTIMEOFFSET && GENERIC_CLOCKEVENTSselect TICK_ONESHOThelp This option enables a tickless system: timer interrupts will only trigger on an as-needed basis both when the system is busy and when the system is idle.config HIGH_RES_TIMERSbool "High Resolution Timer Support"depends on !ARCH_USES_GETTIMEOFFSET && GENERIC_CLOCKEVENTSselect TICK_ONESHOThelp This option enables high resolution timer support. If your hardware is not capable then this option only increases the size of the kernel image.
其中CONFIG_NO_HZ用来控制Dynamic Ticks,CONFIG_HIGH_REST_TIMERS控制High Resolution Timer。
若是没有选择上述的高精度timer和动态tick的话,那么就用linux系统的低精度timer了,简单地介绍了下基础知识,那么接下去再来学习吧!
- 初探linux子系统集之timer子系统(一)
- 初探linux子系统集之timer子系统(二)
- 初探linux子系统集之timer子系统(三)
- 初探linux子系统集之led子系统(一)
- 初探linux子系统集之i2c子系统(一)
- 初探linux子系统集之led子系统(二)
- 初探linux子系统集之led子系统(三)
- 初探linux子系统集之i2c子系统(二)
- 初探linux子系统集之写在前言
- 【Linux内核】timer子系统
- Linux时间子系统之(六):POSIX timer
- Linux UBI子系统设计初探
- linux设备驱动之led子系统<一>
- Linux驱动子系统之I2C(一)
- linux 驱动之led子系统(一)
- linux设备驱动之led子系统<一>
- linux input子系统(一)
- Linux usb子系统(一):子系统架构
- 推荐看的 电视。
- 自定义view--打折标签view
- USACO 4.4.2 Pollutant Control 最小边割集
- 改变某个单独UITableViewCell分割线的样式
- Eclipse 修改jsp、XML、 java、 HTML 每行显示的字数
- 初探linux子系统集之timer子系统(一)
- 原生 NSURL 网络请求 GET POST
- oracle sql 时间比较
- 孙子兵法
- Android - Bitmap-内存分析
- springMVC动态生成验证码过程
- unity3d事件函数整理,事件,回调函数,消息处理
- Activity 启动过程
- .NET网站运行,无效的DateTime错误