Linux Interrupt Processing clock interrupt (ii)

Source: Internet
Author: User
Tags time interval

The code for the

Internal_add_timer () is as follows:

static void Internal_add_timer (tvec_base_t *base, struct timer_list *timer)
{
//Timer arrival time
UN Signed Long expires = timer->expires;     
//calculation time interval
unsigned long idx = expires-base->timer_jiffies;
struct List_head *vec;          
//According to the time interval, place the timer in the appropriate array location
if (idx < tvr_size) {
int i = expires & Tvr_mask;
VEC = Base->tv1.vec + i;
} else if (IDX < 1 << (tvr_bits + tvn_bits)) {
int i = (expires >> tvr_bits) & Tvn_mask;
Vec = Base->tv2.vec + i;
} else if (IDX < 1 << (tvr_bits + 2 * tvn_bits)) {
int i = (expires >> tvr_bits + tvn_bits)) & Tvn_mask;
Vec = Base->tv3.vec + i;
} else if (IDX < 1 << (tvr_bits + 3 * tvn_bits)) {
int i = (expires >> tvr_bits + 2 * tvn_bits)) & Tvn_mask;
Vec = Base->tv4.vec + i;     
else if (signed long idx < 0) {
/*
* Can happen if you add a timer with expires = = Jif Fies,
* or you are set a timer to go past
*/
//If interval is less than 0
Vec = Base->tv1.vec + (base->timer_jiffies & Tvr_mask);          
} else {
int i;
          /* If The timeout is larger than 0xFFFFFFFF in 64-bit
* Architectures Then we use the maximum timeout:
*/
//time interval is very long, set it to OXFFFFFFFF
if (idx > 0xffffffffUL) {
idx = 0xFF fffffful;
expires = idx + base->timer_jiffies;          
}
i = (expires >> (tvr_bits + 3 * tvn_bits)) & Tvn_mask;
VEC = Base->tv5.vec + i;
}
/*
* timers are FIFO:
*/
//Add to end of list
List_add_tail (&timer->e Ntry, VEC);
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.