struct tvec_base_t -- data structures for dynamic timers

来源:互联网 发布:淘宝怎么直播呀 编辑:程序博客网 时间:2024/05/29 16:20
struct tvec_base_t -- data structures for dynamic timers

    Stringing together all timers in a single list would degrade system performance, because scanning a long list of timers at every tick is costly. On the other hand, maintaining a sorted list would not be much more efficient, because the insertion and deletion operations would also be costly.
   
    The adopted solution is based on a clever date structure that partitions the expires values into blocks of ticks and allows dynamic timers of percolate efficiently from lists with larger expires values to lists with smaller ones. Moreover, in multiprocessor systems the set of active dynamic timers is split among the various CPUs.

    The main data structure for dynamic timers is a per-CPU variable named tvec_bases: it includes NR_CPUS elements, one for each CPU in the system. Each element is a tvec_base_t structure, which include all data needed to handle the dynamic timers bound to the corresponding CPU:

struct tvec_t_base_s {
    spinlock_t        lock;
    struct timer_list *running_timer;
    unsigned long     timer_jiffies;
    tvec_root_t       tv1;
    tvec_t            tv2;
    tvec_t            tv3;
    tvec_t            tv4;
    tvec_t            tv5;
} ____cacheline_aligned_in_smp;

typedef struct tvec_t_base_s tvec_base_t;

    The tv1 field is a structure of type tvec_root_t, which includes a vec array of 256 list_head elements -- that is, lists of dynamic timers. It contains all dynamic timers, if any, that will decay within the next 2^8-1 = 255 ticks.

typedef struct tvec_root_s {
    struct list_head vec[TVR_SIZE];
} tvec_root_t;

     tv1
|----------|
|          |       timer_list        timer_list        timer_list
|----------|      |----------|      |----------|      |----------|
| -vec[i] -|<---->|entry     |<---->|entry     |<---->|entry     |
|----------|      |expires   |      |expires   |      |expires   |
|          |      |function()|      |function()|      |function()|
|          |      |data      |      |data      |      |data      |
|          |      |*base     |      |*base     |      |*base     |
|          |      |----------|      |----------|      |----------|
|          |
|          |       timer_list        timer_list
|----------|      |----------|      |----------|
| -vec[j] -|<---->|entry     |<---->|entry     |
|----------|      |expires   |      |expires   |
|          |      |function()|      |function()|
|          |      |data      |      |data      |
|          |      |*base     |      |*base     |
|          |      |----------|      |----------|
|----------|
struct tvec_root_t

    The tv2, tv3, and tv4 fields are structure of type tvec_t consisting of a vec array of 64 list_head elements. These lists contain all dynamic timers that will decay within the next 2^14-1 = 16383, 2^20-1 = 1048575, and 2^26-1 = 67108863 ticks, respectively.

typedef struct tvec_s {
    struct list_head vec[TVN_SIZE];
} tvec_t;


    The tv5 field is identical to the previous ones, except that the last entry of the vec array is a list that includes dynamic timers with extremely large expires fields. It never needs to be replenished from another array.

    The timer_jiffies field represents the earlist expiration time of the dynamic timers yet to be checked: if it coincides with the value of jiffies, no backlog of deferrable functions has accumulated; if it is smaller than jiffies, then lists of dynamic timers that refer to previous ticks must be dealt with. The field is set to jiffies ay system startup and is increased only by the run_timer_softirq() function. Notice that the timer_jiffies field might drop a long way bebind jiffies when the deferrable functions that handle dynamic timers are not executed for a long time -- for instance because these functions have been disabled or because a large number of interrupt handlers have been executed.

    In multiprocessor systems, the running_timer field points to the timer_list structure of the dynamic timer that is currently handled by the local CPU.
<script>window._bd_share_config={"common":{"bdSnsKey":{},"bdText":"","bdMini":"2","bdMiniList":false,"bdPic":"","bdStyle":"0","bdSize":"16"},"share":{}};with(document)0[(getElementsByTagName('head')[0]||body).appendChild(createElement('script')).src='http://bdimg.share.baidu.com/static/api/js/share.js?v=89860593.js?cdnversion='+~(-new Date()/36e5)];</script>
阅读(457) | 评论(0) | 转发(0) |
0

上一篇:宏定义中的##操作符和... and _ _VA_ARGS_ _

下一篇: 花样滑冰教程视频

相关热门文章
  • linux 常见服务端口
  • xmanager 2.0 for linux配置
  • 【ROOTFS搭建】busybox的httpd...
  • openwrt中luci学习笔记
  • 什么是shell
  • linux dhcp peizhi roc
  • 关于Unix文件的软链接
  • 求教这个命令什么意思,我是新...
  • sed -e "/grep/d" 是什么意思...
  • 谁能够帮我解决LINUX 2.6 10...
给主人留下些什么吧!~~
原创粉丝点击