linux 高性能定时器,Linux下一种高性能定时器池的实现.PDF

Linux下一种高性能定时器池的实现.PDF

计算机技术与应用 Computer Technology and Its Applications

Linux 下一种高性能定时器池的实现*

许 健 , 于 鸿 洋

( 电子科技大学 电子科学技术研究院, 四川 成都 611731)

摘 要: 提 出 Linux 用 户 空 间 下 的 一 种 高性 能 定 时 器 池 的 实 现 方 法 。 主 要 基 于 时 间轮 、 红 黑树 及

Linux 内核 提 供 了 一 种 利 于 管 理 的 定 时 器 句 柄 Timerfd 。 结 合 红 黑树 、位 图 、 时 间轮 等 技 术 ,设 计 一 种 高

性 能 级 定 时 器 池 。 池 中定 时 器 的 粒 度 可 达 到 40 ms ,满 足 用 户 空 间低 延 时 的 应 用 需 求 , 同 时 又 可 以 方

便 地 管 理 一 定 数 量 的 定 时 器 。

关键词: 高性 能 ; 定 时 器 池 ; 定 时 器 ; 时 间轮 ; 红 黑树

中图分类号: TP31 文献标识码: A 文章编号: 0258-7998(2012)12-0114-03

An implement of high performance timer pool under Linux

Xu Jian ,Yu Hongyang

(Research Institute of Electronic Science and Technology, University of Electronic Science and Technology, Chengdu 611731, China )

Abstract: This paper proposes a new implement of an timer pool in the user space, this timer pool mainly basic on the time-

wheel and the red -black tree. The Linux kernel also provide a discriptor to manage the timer, it is Timerfd. Combined with the

red-black tree, bit-map, timing-wheel, design a high performance timer pool. The timer particle size can be 40 millisecond , and

this can meet some of the low delay of the application requirements ,it ′s conveniently manage the number of timers.

Key words: high performance; timer pool; timer; timing round; red-black tree

[1]

定时器(timer) 是 Linux 提供的一种定时服务的机制 。 1 设计原理以及工作流程

在使用定时器时,预先设置一个定时时间 ,并给定时时 1.1 定时器池的结构

间到达时执行预先设定的任务。 目前Linux 系统本身提 本定时器池选用 Timerfd 作为添加和删除定时器的

供了多种用户级定时器接口, 其中精度较低的如 Alarm 接口,使用 Linux 提供的函数 timerfd_settime 来设定定时

函数,精度为秒级,能够满足一些定时精度低的应用场 的间隔时间大小。 本定时器池的时间间隔为一个时间片

合。 但由于同一进程中不能同时调用多个 Alarm 函数,

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值