Chinaunix首页 | 论坛 | 博客
  • 博客访问: 941815
  • 博文数量: 192
  • 博客积分: 3070
  • 博客等级: 中校
  • 技术积分: 1861
  • 用 户 组: 普通用户
  • 注册时间: 2007-06-27 23:44
个人简介

Start Linux Leave Linux a while Back to Linux

文章分类

全部博文(192)

文章存档

2023年(18)

2022年(11)

2021年(8)

2020年(14)

2019年(7)

2018年(13)

2017年(16)

2016年(4)

2012年(2)

2011年(13)

2010年(26)

2009年(13)

2008年(27)

2007年(20)

我的朋友

分类: LINUX

2010-04-22 18:47:55

如何在Linux 内核中使用 timer_list(相当于QT中的 timer 功能)。
 
#include
#include
static struct timer_list test_unit_timer;
 
 
static void test_unit_timerout(unsigned long data)
{
   printk("test_unit_timerout.\n\n");
}
 
static int __init fsg_init(void)
{
 
 init_timer(&test_unit_timer);
 test_unit_timer.function = test_unit_timerout;
 test_unit_timer.data = NULL;
 test_unit_timer.expires = jiffies + 2*HZ;   // HZ = 1 sec
 add_timer(&test_unit_timer); 
}
 
static void __exit fsg_cleanup(void)
{
 del_timer(&test_unit_timer); 
}
 
 
 
阅读(1409) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~