Re: interrupts

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

 



thank you.
But The same procedure i followed for key board interrupt.
When ever a key is pressed on the key board it will print the message.
But why it will not wor for timer interrupt?


thanks in advance


On Tue, 2005-09-20 at 22:10 +0530, Manu Anand wrote:
> 
> 
> On 9/20/05, raja <vnagaraju@xxxxxxxxxxxx> wrote:
>         actually i am writing a module to sense the timer interrupt.
>         Any way for every clock tick the timer updates the system
>         time.I want to
>         find out the process's information that was running at the
>         time the
>         timer interrupt occures.
> 
> 
> Hi Raja:
> 
> Am I write in assuming that u want ur module to sort of hook on to
> timer interrupt? The idea being that ur module should also be invoked
> when the timer interrupt handler is invoked. 
> 
> In that case, the approach you've followed will not work. Timer
> interrupt is not shared.
> 
> When the kernel receives the interrupt, it invokes sequentially each
> reqistered handler on the line. However in your case the call 
> 
> request_irq(TIMER_INTERRUPT,
> timer_interrupt_handler,SA_SHIRQ,DEVICE_NAME,&devNo);
> 
> will fail since the IRQ line is already registered for timer interrupt
> in an exclusive non-shared( specified using SA_INTERRUPT 
> // Check out http://lxr.linux.no/source/arch/i386/mach-default/setup.c#L74
> static struct 
> irqaction irq0  = 
> { timer_interrupt, SA_INTERRUPT, 
> CPU_MASK_NONE, "timer", NULL, NULL};
> 
> Your approach is valid for interrupts specified with SA_SHIRQ flag.
> 
> 
> Manu
> 
>  
> 
>         I have registered my handler that prints simply a message when
>         ever the 
>         timer interrupt occures.But it is not working.It is not
>         printing any
>         message.
>         
>         I am listing my code below.Will you please help me
>         
>         
>         
>         
>         
>         
>         
>         
>         
>         #ifndef __KERNEL__
>                 #define __KERNEL__ 
>         #endif
>         
>         #ifndef MODULE
>                 #define MODULE
>         #endif
>         
>         #include <linux/kernel.h>
>         #include <linux/init.h>
>         #include <linux/module.h>
>         #include <linux/fs.h>
>         #include <linux/interrupt.h> 
>         
>         MODULE_AUTHOR("RAJA");
>         MODULE_DESCRIPTION("TIMER INTERRUPT");
>         MODULE_LICENSE("GPL");
>         
>         #define DEVICE_NAME "timer_interrupt"
>         #define TIMER_INTERRUPT 0
>         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 Interrupt 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);
>         
>         
>         
>         
>         
>         
>         
>         
>         
>         
>         
>         
>         
>         
>         On Tue, 2005-09-20 at 17:02 +0500, Fawad Lateef wrote:
>         > On 9/20/05, raja < vnagaraju@xxxxxxxxxxxx> wrote:
>         > > yaa.
>         > > I have checked /proc/interrupts.
>         > > But there it is given the interrupt numbers.
>         > >
>         > > actually the requirement is i am writing a module that it
>         senses when 
>         > > ever the interrupt occures and prints the interrupt
>         number.
>         > >
>         > > Will you please help me.
>         > >
>         > >
>         >
>         > What sort of module you are writing ?? How you are going to
>         sense 
>         > interrupts when they occurs ?? I think for getting signal
>         through the
>         > call-backed function from the kernel you have to register
>         your
>         > interrupt handlers, so that you can be notified by the
>         kernel ........ 
>         >
>         > Or hack into the kernel, to get notified for each interrupt,
>         but AFAIK
>         > your module can't get every single interrupt until you
>         register them
>         > with the kernel ........
>         >
>         > Correct me if I m wrong !!!! 
>         >
>         >
>         
>         
>         --
>         Kernelnewbies: Help each other learn about the Linux kernel.
>         Archive:       http://mail.nl.linux.org/kernelnewbies/
>         FAQ:           http://kernelnewbies.org/faq/
>         
> 


--
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