Friday, 1 November 2013

Timer Interrupt in Linux Kernel


Hello,

So, all the stuff starts with this function,

Now, all the setup is to be done in this function. First in this function, a timer is initialized by:


Here exp_timer is a variable of struct timer_list structure. This structure all the necessary information about the timer. And we are going to use the following information in our application.
If you feel confused, dont worry. Here's the explanation. The first line contains a variable named jiffies. This variable is incremented by kernel every at a definite interval given HZ. Normally HZ is 100Hz, so jiffies is incremented every 10ms. So let's I want delay of 5mins. Then just give that value to variable delay, and give that time to the structure. Now, when the timer is expired, we want a function to be called. This so we need to provide the name of function to the structure. Here, the function being do_something.

Here is a link for sample program.

EDIT : Here is a full term project based on this. :)

Hope it helped. Thanks for reading.
Hardik Madhu

No comments:

Post a Comment