All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Ulrich Windl" <Ulrich.Windl@rz.uni-regensburg.de>
To: linux-kernel@vger.kernel.org
Subject: (Fwd) about timer in linux kernel.
Date: Mon, 21 May 2001 13:51:38 +0200	[thread overview]
Message-ID: <3B091D6A.238.1417682@localhost> (raw)

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

                 reply	other threads:[~2001-05-21 11:55 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3B091D6A.238.1417682@localhost \
    --to=ulrich.windl@rz.uni-regensburg.de \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.