(Fwd) about timer in linux kernel.

From: Ulrich Windl (Ulrich.Windl@rz.uni-regensburg.de)
Date: Mon May 21 2001 - 06:51:38 EST


Maybe one of the people having written the code want to explain...

Thanks, Ulrich
------- Forwarded message follows -------
From: "meng-ju" <mengju@research.att.com>
To: <Ulrich.Windl@rz.uni-regensburg.de>
Subject: about timer in linux kernel.
Date sent: Fri, 18 May 2001 16:58:55 -0700

Hi! Mr. Ulrich Windl,
 
I want to know how timer works in kernel.
When we call add_timer(), it will call add_timer_internal to add it to its list.
Now I am confused how the system checks if it is expired or not?
In run_timer_list(),
Why it uses tv1.vec + tv1.index to find out the expiration point while in add_timer_internal(), the expiration timer minus timer_jiffies?
I don't understand what roles jiffies, timer_jiffies and tv1.index play.
Thanks for your patient and answering.
 
static inline void run_timer_list(void)
{
         spin_lock_irq(&timerlist_lock);
         while ((long)(jiffies - timer_jiffies) >= 0) {
                 struct list_head *head, *curr;
                 if (!tv1.index) {
                         int n= 1;
                         do {
                                cascade_timers(tvecs[n]);
                         } while (tvecs[n]->index == 1 && ++n < NOOF_TVECS);
                 }
repeat:
                head = tv1.vec + tv1.index;
                curr = head->next;
                if (curr != head) {
                        struct timer_list *timer;
                        void (*fn)(unsigned long);
                        unsigned long data;

                        timer = list_entry(curr, struct timer_list, list);
                        fn = timer->function;
                        data= timer->data;

                        detach_timer(timer);
                        timer->list.next = timer->list.prev = NULL;
                        timer_enter(timer);
                        spin_unlock_irq(&timerlist_lock);
                        fn(data);
                        spin_lock_irq(&timerlist_lock);
                        timer_exit();
                        goto repeat;
                }
                ++timer_jiffies;
           tv1.index = (tv1.index + 1) & TVR_MASK;
        }
........

Meng-Ju

------- End of forwarded message -------
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Wed May 23 2001 - 21:00:41 EST