RE: interrupts

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

 



Hi,


>-----Original Message-----
>From: raja [mailto:vnagaraju@xxxxxxxxxxxx]
>Sent: Tuesday, September 20, 2005 5:26 PM
>To: kernel; fawadlateef@xxxxxxxxx
>Subject: Re: interrupts
>
>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.
>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 couldn't get the usage of char device in your code.
See if this sample code helps you. Here I have:
~~~~~~~~~~~

struct timer_list tick_timer;
void timer_func(unsigned int data)
{
	/*
	Do all the processing here
	Print pid of the currently running task.
	*/
	mod_timer(&tick_timer, jiffies + 1);
}

static int __init start_timer(void)
{
	init_timer(&tick_timer);
	tick_timer.expires = jiffies + 1;
	tick_timer.function=timer_func;
	add_timer(&tick_timer);
	return 0;
}

Static void __exit exit_timer(void)
{
	del_timer(&my_timer);
}
module_init(start_timer);
module_exit(exit_timer);
~~~~~~~~~~~~~~~~~~~~~~~~
	
Sanjay




>
>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_NAM
E,&d
>evNo);
>	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