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.
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.
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...
给主人留下些什么吧!~~
评论热议
0 0
- struct tvec_base_t -- data structures for dynamic timers
- Creating dynamic data structures(from flws)
- Data Structures for Game Programmers
- UESTC Training for Data Structures(总结)
- 【UESTC】2015 UESTC Training for Data Structures
- 2016 UESTC Training for Data Structures
- 2016 UESTC Training for Data Structures
- 2016 UESTC Training for Data Structures (1)
- 2016 UESTC Training for Data Structures(2)
- 2016 UESTC Training for Data Structures(3)
- dynamic timers 的list
- Data Structures
- data structures
- Data Structures
- data structures
- Data Structures
- Data Structures
- Data Structures - Immutable Data Structures
- 【if版解题】守望者的逃离
- Mips cache lock
- 【题解】8.7夏令营last_test
- 宏定义中的##操作符和... and _ _VA_ARGS_ _
- 【转载】线性筛法求素数(和普通不同,初中可以不用)
- struct tvec_base_t -- data structures for dynamic timers
- 【题解】新学期第一课!题目!
- C中如何调用C++函数?
- LintCode(easy)合并排序数组
- 【动归经典】最长公共子串
- 【题解】2015.10.17题目
- 【转载】FloodFill算法的优化
- 轻松实现RecycleView的下拉刷新、加载更多
- 【转载】SPFA最短路算法解析
原创粉丝点击
热门IT博客
热门问题
老师的惩罚
人脸识别
我在镇武司摸鱼那些年
重生之率土为王
我在大康的咸鱼生活
盘龙之生命进化
天生仙种
凡人之先天五行
春回大明朝
姑娘不必设防,我是瞎子
齐齐哈尔到海拉尔
海拉尔邮编
海拉尔站
闪烁之光海拉
满洲里到海拉尔
海拉尔到哈尔滨火车时刻表
海拉尔一日游必去景点
海拉尔到大雁列车时刻表
海拉尔到哈尔滨
海拉尔到北京飞机票
哈尔滨到海拉尔火车
海拉五
海拉6
海拉6透镜
海拉五透镜
海拉2透镜怎么样
改灯海拉5坏处
海拉5透镜
改海拉5透镜多少钱
百折不挠具海拉
海拉尔到齐齐哈尔火车时刻表
海拉尔到北京
哈尔滨海拉尔
哈尔滨到海拉尔
北京到海拉尔
海拉尔机场
海拉尔北京
海拉尔气温
海拉尔到呼伦贝尔
海拉尔是哪个省的
海拉尔是哪里
大雁到海拉尔列车时刻表
齐齐哈尔到海拉尔火车时刻表
长春到海拉尔火车时刻表
海拉尔到长春火车时刻表
满洲里到海拉尔火车
海拉尔到海南飞机票
拍客
91青草拍客
拍客行动
神马拍客