系统城装机大师 - 固镇县祥瑞电脑科技销售部宣传站!

当前位置:首页 > 系统教程 > Linux教程 > 详细页面

Linux 内核学习笔记(六)——定时器及时间管理 Timer and time management

时间:2020-08-31来源:www.pcxitongcheng.com作者:电脑系统城

timers and time management

时间有相对、绝对时间之分。一个process在5s之后运行时相对时间,current time of day(也就是wall-time)是绝对时间,绝对时间一般是与用户交互时用到。

The system timer goes off (often called hitting or popping) at a preprogrammed frequency, called the tick rate.

越高的tick rate频率会使得定时器中断有更高的分辨率,同时时间驱动的时间的精确性也提升。然而过高的tick rate频率就会使得定时器中断被频繁启动,就需要花费更多的时间来处理timer interrupt handler,这也是更高的负载负担。

全局变量jiffies里面保存系统自启动以来tick数值。然而Converting from ticks to seconds is typically reserved for communicating with user-space, as the kernel itself rarely cares about any sort of absolute time.
jiffies总是unsigned long类型的变量。hitectures.With a tick rate of 100, a 32-bit jiffies variable would overflow in about 497 days.With HZ increased to 1000, however, that overflow now occurs in just 49.7 days! If jiffies were stored in a 64-bit variable on all architectures, then for any reasonable HZ value the jiffies variable would never overflow in anyone's lifetime. 和其他变量类似,溢出之后自动归零。另外kernel内部还有一些处理机制,类似于我过去BMS中计时器程序处理的巧妙办法。 kernel也会利用jiffies进行一些小的延时,loop,waiting等等,不过还不如将等待的时间scheduling去做其他的工作。

RTC时钟提供一个掉电之后仍能储存系统时间的设备。在电脑中这个RTC数值可以在BIOS界面进行修改。系统开机后,读取保存在RTC的数值作为system time。

timer本身的使用是非常简单的,不过timer因为是异步的,也会产生同步竞争等问题,需要注意。

参考文献

  1. Robert Love. "Linux Kernel Development." (2008).
分享到:

相关信息

  • linux 文件权限怎么解析

    常用权限linux系统内有档案有三种身份 u:拥有者 g:群组 o:其他人这些身份对于文档常用的有下面权限:r:读权限,用户可以读取文档的内容,如用cat,more查看w:写权限,用户可以编辑文档x...

    2024-07-07

  • 如何使用WPSeku找出 WordPress 安全问题?

    然而,如果我们遵循通常的 WordPress 最佳实践,这些安全问题可以避免。在本篇中,我们会向你展示如何使用 WPSeku,一个 Linux 中的 WordPress 漏洞扫描器,它可以被用来找出你安装...

    2024-07-03

系统教程栏目

栏目热门教程

人气教程排行

站长推荐

热门系统下载