- 论坛徽章:
- 0
|
本帖最后由 chen0610 于 2012-08-14 18:01 编辑
代码很简单
static int __init hello_init(void)
{
printk(KERN_EMERG"hello_init jiffies = %ld.\n", jiffies);
return 0;
}
static void __exit hello_exit(void)
{
printk(KERN_EMERG"hello_exit jiffies = %ld.\n", jiffies);
}
linux系统是Red Hat Enterprise Linux 5,内核是2.6.27.62。
1.命令行下[root@localhost hello]# reboot
2.插入模块[root@localhost hello]# insmod hello.ko
[root@localhost hello]#
Message from syslogd@ at Tue Aug 14 09:56:20 2012 ...
localhost kernel: hello_init jiffies = -55129.
3.卸载模块[root@localhost hello]# rmmod hello.ko
[root@localhost hello]#
Message from syslogd@ at Tue Aug 14 09:56:43 2012 ...
localhost kernel: hello_exit jiffies = -49387.
两次打印jiffies的值都为负数,jiffies不是应该从0开始的吗?而且内核里面是extern unsigned long volatile __jiffy_data jiffies;jiffies应该是无符号数啊,怎么会变成负数了呢?求解,@高手大大们 |
|