public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* (Fwd) about timer in linux kernel.
@ 2001-05-21 11:51 Ulrich Windl
  0 siblings, 0 replies; only message in thread
From: Ulrich Windl @ 2001-05-21 11:51 UTC (permalink / raw)
  To: linux-kernel

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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2001-05-21 11:55 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2001-05-21 11:51 (Fwd) about timer in linux kernel Ulrich Windl

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox