定时器相关的一些结构体
来源:互联网 发布:德拉蒙德格林数据 编辑:程序博客网 时间:2024/04/30 11:50
content:
struct timer_list
init_timer
timer_pending
add_timer
del_timer
del_timer_sync
-------------------------------------------------------------------------------------------------------------------------------------------------------------
struct timer_list
The timer_list structure specifies a timer object in Linux kernel.
struct timer_list {
struct list_head list;
unsigned long expires;
unsigned long data;
void (*function)(unsigned long param);
};
Members
list A struct list_head object. It is used to queue timer_list together.
expires Specifies the timeout value in jiffies format.
data User-defined variable. This field enables user of a common timeout function for several timeouts. You can use this field to distinguish between the difference invocations.
function User defined callback function.
Headers
Defined timer.h.
Comments
User should allocate timer_list object in resident storage because timer will be triggered in interrupt context.
-------------------------------------------------------------------------------------------------------------------------------------------------------------
init_timer Function
Initialize a timer_list object.
Syntax
void
init_timer(
struct timer_list* timer
);
Parameters
timer Pointer to caller-supplied, resident storage for a timer object.
Return Value
None
Remarks
Because timer_list structure has several other fields, you can't call add_timer to add a timer directly. Once you call init_timer to initialize a timer_list object, you should fill other fields manually. For example, the callback function pointer function should be filled because Linux kernel notifies user using this field. Field expires in timer_list should be set to the time in jiffies format. See struct timer_object for more information about internal fields.
Headers
Declared in timer.h, which located in $KERNEL_ROOT/include/linux.
-------------------------------------------------------------------------------------------------------------------------------------------------------------
timer_pending Function
Checks the timer state.
Syntax
int
timer_pending(
const struct timer_list * timer
);
Parameters
timer the timer object that you want to get state from
Return Value
Returns 0 if the timer has expired or doesn't insert to kernel timer list. Non-0 value otherwise.
Remarks
You could test the timer state using this function.
Headers
Declared in timer.h.
-------------------------------------------------------------------------------------------------------------------------------------------------------------
add_timer Function
Add a new timer to kernel.
Syntax
void
add_timer(
struct timer_list *timer
);
Parameters
timer Pointer to timer_list object that has been initialized using init_timer.
Return Value
None
Remarks
This function can be called in interrupt and non-interrupt context safely. The kernel keeps up a sorted timer list and polled more or less 100 times per second. Before you try to add timer to kernel, you should initialize all fields in timer_list structure.
Headers
Declared in timer.h.
-------------------------------------------------------------------------------------------------------------------------------------------------------------
del_timer Function
If a timer needs to be removed from kernel before it expires, del_timer should be called. When a timer expires, it is automatically removed also.
Syntax
int
del_timer(
struct timer_list* timer_list
);
Parameters
timer The timer that should be removed.
Return Value
If the timer is removed successfully before expiration, the return value is 1. Returns 0 if the timer has already expired.
Remarks
When 1 is returned, the timer is removed successfully and it will not be run. In contrast, when 0 is returned, you should take care of race condition because it's possible that the timer callback function is running.
Headers
Declared in timer.h.
-------------------------------------------------------------------------------------------------------------------------------------------------------------
del_timer_sync Function
If a timer needs to be removed from kernel before it expires, del_timer should be called. When a timer expires, it is automatically removed also.
Syntax
int
del_timer_sync(
struct timer_list* timer_list
);
Parameters
timer The timer that should be removed.
Return Value
If the timer is removed successfully before expiration, the return value is 1. Returns 0 if the timer has already expired.
Remarks
Like del_timer, but this function makes sure that the deleting timer doesn't run in other CPUs. So when this function returns, the timer is either removed remove kernel or finished its timeout function.
Headers
Declared in timer.h.
-------------------------------------------------------------------------------------------------------------------------------------------------------------
struct timer_list
init_timer
timer_pending
add_timer
del_timer
del_timer_sync
-------------------------------------------------------------------------------------------------------------------------------------------------------------
struct timer_list
The timer_list structure specifies a timer object in Linux kernel.
struct timer_list {
struct list_head list;
unsigned long expires;
unsigned long data;
void (*function)(unsigned long param);
};
Members
list A struct list_head object. It is used to queue timer_list together.
expires Specifies the timeout value in jiffies format.
data User-defined variable. This field enables user of a common timeout function for several timeouts. You can use this field to distinguish between the difference invocations.
function User defined callback function.
Headers
Defined timer.h.
Comments
User should allocate timer_list object in resident storage because timer will be triggered in interrupt context.
-------------------------------------------------------------------------------------------------------------------------------------------------------------
init_timer Function
Initialize a timer_list object.
Syntax
void
init_timer(
struct timer_list* timer
);
Parameters
timer Pointer to caller-supplied, resident storage for a timer object.
Return Value
None
Remarks
Because timer_list structure has several other fields, you can't call add_timer to add a timer directly. Once you call init_timer to initialize a timer_list object, you should fill other fields manually. For example, the callback function pointer function should be filled because Linux kernel notifies user using this field. Field expires in timer_list should be set to the time in jiffies format. See struct timer_object for more information about internal fields.
Headers
Declared in timer.h, which located in $KERNEL_ROOT/include/linux.
-------------------------------------------------------------------------------------------------------------------------------------------------------------
timer_pending Function
Checks the timer state.
Syntax
int
timer_pending(
const struct timer_list * timer
);
Parameters
timer the timer object that you want to get state from
Return Value
Returns 0 if the timer has expired or doesn't insert to kernel timer list. Non-0 value otherwise.
Remarks
You could test the timer state using this function.
Headers
Declared in timer.h.
-------------------------------------------------------------------------------------------------------------------------------------------------------------
add_timer Function
Add a new timer to kernel.
Syntax
void
add_timer(
struct timer_list *timer
);
Parameters
timer Pointer to timer_list object that has been initialized using init_timer.
Return Value
None
Remarks
This function can be called in interrupt and non-interrupt context safely. The kernel keeps up a sorted timer list and polled more or less 100 times per second. Before you try to add timer to kernel, you should initialize all fields in timer_list structure.
Headers
Declared in timer.h.
-------------------------------------------------------------------------------------------------------------------------------------------------------------
del_timer Function
If a timer needs to be removed from kernel before it expires, del_timer should be called. When a timer expires, it is automatically removed also.
Syntax
int
del_timer(
struct timer_list* timer_list
);
Parameters
timer The timer that should be removed.
Return Value
If the timer is removed successfully before expiration, the return value is 1. Returns 0 if the timer has already expired.
Remarks
When 1 is returned, the timer is removed successfully and it will not be run. In contrast, when 0 is returned, you should take care of race condition because it's possible that the timer callback function is running.
Headers
Declared in timer.h.
-------------------------------------------------------------------------------------------------------------------------------------------------------------
del_timer_sync Function
If a timer needs to be removed from kernel before it expires, del_timer should be called. When a timer expires, it is automatically removed also.
Syntax
int
del_timer_sync(
struct timer_list* timer_list
);
Parameters
timer The timer that should be removed.
Return Value
If the timer is removed successfully before expiration, the return value is 1. Returns 0 if the timer has already expired.
Remarks
Like del_timer, but this function makes sure that the deleting timer doesn't run in other CPUs. So when this function returns, the timer is either removed remove kernel or finished its timeout function.
Headers
Declared in timer.h.
-------------------------------------------------------------------------------------------------------------------------------------------------------------
- 定时器相关的一些结构体
- 内核定时器的使用及相关结构体介绍
- PE文件结构的一些相关定义
- 定时器相关的类
- Oracle查询表结构的一些相关语句
- linux内核中 校验相关的一些结构
- Oracle查询表结构的一些相关语句
- Oracle查询表结构的一些相关语句
- 结构体的相关概念
- fb的相关结构体
- 单片机 定时器计数器的相关
- STC89C52RC定时器的相关设置
- JavaScript定时器的相关操作
- 结构体的一些学习心得
- QT定时器的一些注意
- VC中结构体的相关问题
- C++结构体复制的相关问题
- 结构体(含位域)的sizeof 对齐相关
- VMWare-tools安装过程
- 18、Bootloader(2)--Bootloader与内核的交互,或者说传参
- Windows下QT开发环境的搭建
- 《Java程序员的推荐阅读书籍》
- main 之前与之后
- 定时器相关的一些结构体
- 19、Bootloader(3) -- U-Boot第一阶段代码start.S分析
- iPad和iPhone的app图标尺寸、用途、设置方法
- WEBQQ2.0协议分析(qqweb.app.groupsystemmsg.js)
- poj4015之邮箱验证
- 解决:android TextView上响应部分文字的事件
- HTTP Response Splitting 攻击
- typedef和define的详细区别(转载)
- 20、Bootloader(4) -- U-Boot第二阶段分析