Re: timer interrupt

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 9/18/05, raja <vnagaraju@xxxxxxxxxxxx> wrote:
> Hi,
>   I am writing a module that prints a message when ever a timer issues
> an interrupt.Any way system timer issues an interrupt after 'tick rate'
> and then kernel handles the interrupt handler.But it is not working in
> my module.
> Will you please tell me wht is wrong with it?

For getting an timer interrupt, you can/have to use timer
functionality in the kernel .... When you register your timer, you
will mention a fucntion to be called backed when the timer expires and
that function will be called by the kernel in the timer (soft) irq
context !!!!!!

> My code is as follows
> 
> 
> 
> #define DEVICE_NAME "timer_interrupt"
> #define TIMER_INTERRUPT 8
> static int __init init_timer_interrupt(void);
> static void __exit exit_timer_interrupt(void);
> 
> static irqreturn_t timer_interrupt_handler(unsigned int,void *, struct pt_regs *);
> 
> int devNo;
> struct file_operations fops = {};
> 
> static irqreturn_t timer_interrupt_handler(unsigned int irq,void *data, struct pt_regs *regs)
> {
>        printk("Timer Interrup Occured\n");
>        return 0;
> }
> 
> static int __init init_timer_interrupt()
> {
>        printk("Entered Into init_timer\n");
>        devNo = register_chrdev(0,DEVICE_NAME,&fops);
>        request_irq(TIMER_INTERRUPT,timer_interrupt_handler,SA_SHIRQ,DEVICE_NAME,&devNo);
>        printk("Exited From init_timer\n");
>        return 0;
> }
> 
> static void __exit exit_timer_interrupt()
> {
>        printk("Entered Into exit_timer\n");
>        unregister_chrdev(devNo,DEVICE_NAME);
>        free_irq(TIMER_INTERRUPT,&devNo);
>        printk("Exited From exit_timer\n");
> }
> 
> module_init(init_timer_interrupt);
> module_exit(exit_timer_interrupt);
> 

What you are trying to do in this code ? I don't know why you are
registering your interrupt handler with irq number 8 !!! is this a
timer interrupt ??? if yes then it have to call your function and if
not irq number 8 is a timer interrupt then your function won't be
called as irq 8 might not be used by the kernel or no interrupt
occuring on that irq number !!! (CMIIW)


-- 
Fawad Lateef

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/



[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux