Re: Reg: problem in using High resolution Timer(hrtimer)
- From: bsahai <bhagwan.sahai@xxxxxxxxx>
- Date: Wed, 31 Oct 2007 13:20:42 -0000
On Oct 31, 12:24 pm, Tim Roberts <t...@xxxxxxxxx> wrote:
bsahai <bhagwan.sa...@xxxxxxxxx> wrote:
I have written and compiled a kernel module on Linux Kernel
version 2.6.22.8. The kernel module uses high precision timer to print
after 2 sec continuosly , but as soon as I insert my module using
modprobe ,the kernel goes in panic state.
...
struct hrtimer *timer;
static int __init init_timer(void)
{
ktime_t kt;
clockid_t which_clock=CLOCK_MONOTONIC; //CLOCK_REALTIME
printk(KERN_ALERT "HRTTIMER inserted\n");
kt=ktime_set(secs,nanosecs);
timer = (struct hrtimer *)kmalloc(sizeof(struct hrtimer),GFP_KERNEL);
hrtimer_init(timer,which_clock,HRTIMER_MODE_ABS);
timer->function = &callback; // callback
hrtimer_start(timer, kt,HRTIMER_MODE_ABS);
printk(KERN_ALERT "HRTTIMER STARTED\n");
return 0;
}
Maybe I'm misunderstanding this, but I would have guessed that you wanted
HRTIMER_MODE_REL. By using CLOCK_MONOTONIC with an absolute time of 2
seconds, you're asking for the timer to fire 2 seconds after the last boot,
which has already expired.
--
Tim Roberts, t...@xxxxxxxxx
Providenza & Boekelheide, Inc.- Hide quoted text -
- Show quoted text -
Yes you right it should be HRTTIMER_MOD_REL instead of
HRTIMER_MOD_ABS ,but even after changing this the same problem is
repeating ..I am again pasting the code and log (when run over UML
kernel).
PS: I am using Linux kernel 2.6.22.8 (i386)
/
********************************code***************************************************
#include<linux/hrtimer.h>
#include<linux/ktime.h>
#include<linux/module.h>
struct hrtimer *timer1;
enum hrtimer_restart callback(struct hrtimer *); // return enum
hrtimer_restart
enum hrtimer_restart callback(struct hrtimer *timer)
{
printk(KERN_ALERT "\nTIME INTERRUPTED\n");
return HRTIMER_RESTART;
}
const long secs=2;
const long nanosecs=50;
static int init_timer(void)
{
ktime_t kt;
clockid_t which_clock=CLOCK_MONOTONIC; //CLOCK_REALTIME
timer1=(struct hrtimer *)kmalloc(sizeof(struct hrtimer),GFP_ATOMIC);
printk(KERN_ALERT "\ntimer:after malloc\n");
kt=ktime_set(secs,nanosecs);
printk(KERN_ALERT "\nBefore timer_init\n");
hrtimer_init(timer1,which_clock,HRTIMER_MODE_REL);
printk(KERN_ALERT "\nAfter Timer init\n");
timer1->function = &callback;
hrtimer_start(timer1, kt,HRTIMER_MODE_REL);
printk(KERN_ALERT "\nAfter timer start\n");
return 0;
}
static void exit_timer(void)
{
//hrtimer_cancel(timer);
return;
}
MODULE_LICENSE("GPL");
/*********Code ends here
***************************************************************
/*************************Log
begins*************************************************************
[root@localhost 2.6.22.8]# modprobe -f timer
timer: no version magic, tainting kernel.
EIP: 0073:[<080a1890>] CPU: 0 Tainted: GF ESP: 007b:0ad6aefc
EFLAGS: 000102
46
Tainted: GF
EAX: 00000000 EBX: 0b807480 ECX: 0b807480 EDX: 00000001
ESI: 0805e0e8 EDI: 00000001 EBP: 0ad6af0c DS: 007b ES: 007b
081eabbc: [<08068098>] show_regs+0xb4/0xb9
081eabe8: [<08058807>] segv+0x12d/0x272
081eac8c: [<080586d5>] segv_handler+0x55/0x5a
081eacac: [<08065cb8>] sig_handler_common_skas+0xd4/0xfc
081eacd4: [<08062d1c>] sig_handler+0x34/0x44
081eacec: [<08062eac>] handle_signal+0x4a/0x7a
081ead0c: [<08064a7f>] hard_handler+0xf/0x14
081ead1c: [<00bdd420>] 0xbdd420
Kernel panic - not syncing: Kernel mode fault at addr 0x1, ip
0x80a1890
EIP: 0073:[<400eee2e>] CPU: 0 Tainted: GF ESP: 007b:bf5ec9c0
EFLAGS: 000002
46
Tainted: GF
EAX: ffffffda EBX: 08066a88 ECX: 00005323 EDX: 0805e0e8
ESI: 0805e0e8 EDI: 0805e0e8 EBP: bf5eca48 DS: 007b ES: 007b
081eab24: [<08068098>] show_regs+0xb4/0xb9
081eab50: [<08058b90>] panic_exit+0x25/0x3f
081eab64: [<08077a08>] notifier_call_chain+0x21/0x46
081eab84: [<08077aa3>] __atomic_notifier_call_chain+0x17/0x19
081eaba0: [<08077aba>] atomic_notifier_call_chain+0x15/0x17
081eabbc: [<0806c976>] panic+0x52/0xdd
I?l?I?#?Jp??K`@?Lpk|M`"?NpM\O`?Pp/
<Q`?uRpS`?UTp??T`?5V??V??X???X???Y? Z???[???\?
d`/
GepZ?e`'gp<?g`?ip?i`??j?:?k???l?vm? n??Uo p??5q??or??s?yOtp??t`?8vp??v`x xp??
x`Z?yp??z`<?{pg~|`?}pI^~`????????????????n_skas+0xd4/0xfc
081eacd4: [<08062d1c>] sig_handler+0x34/EDTESTEWTEPTI
Program terminated with signal SIGSEGV, Segmentation fault.
The program no longer exists.handler+0xf/0x14
(gdb) 1c: [<00bdd420>] 0xbdd420
(gdb)
/*************************log
ends**************************************************************
regards
Bhagwan Sahai
.
- References:
- Reg: problem in using High resolution Timer(hrtimer)
- From: bsahai
- Re: Reg: problem in using High resolution Timer(hrtimer)
- From: Tim Roberts
- Reg: problem in using High resolution Timer(hrtimer)
- Prev by Date: Re: do_fork() in linux
- Next by Date: Re: running Linux with no swap space (but lots of RAM)
- Previous by thread: Re: Reg: problem in using High resolution Timer(hrtimer)
- Next by thread: LD_LIBRARY_PATH
- Index(es):
Relevant Pages
|
|