- 论坛徽章:
- 16
|
本帖最后由 embeddedlwp 于 2011-12-04 19:20 编辑
当进程在它的时间片到期的时候可以被抢占。此时,当前进程的thread_info结构中的TIF_NEED_RESCHED标志被置位,以便时钟中断处理程序终止时调度程序被调用。
但是在时钟中断的bh,run_timer_softirq函数中我并没有找到检查TIF_NEED_RESCHED标志是否被置位,并调用调度程序的地方啊!
求指点!
下边是2.6.11中的代码:- 434static inline void __run_timers(tvec_base_t *base)
- 435{
- 436 struct timer_list *timer;
- 437
- 438 spin_lock_irq(&base->lock);
- 439 while (time_after_eq(jiffies, base->timer_jiffies)) {
- 440 struct list_head work_list = LIST_HEAD_INIT(work_list);
- 441 struct list_head *head = &work_list;
- 442 int index = base->timer_jiffies & TVR_MASK;
- 443
- 444 /*
- 445 * Cascade timers:
- 446 */
- 447 if (!index &&
- 448 (!cascade(base, &base->tv2, INDEX(0))) &&
- 449 (!cascade(base, &base->tv3, INDEX(1))) &&
- 450 !cascade(base, &base->tv4, INDEX(2)))
- 451 cascade(base, &base->tv5, INDEX(3));
- 452 ++base->timer_jiffies;
- 453 list_splice_init(base->tv1.vec + index, &work_list);
- 454repeat:
- 455 if (!list_empty(head)) {
- 456 void (*fn)(unsigned long);
- 457 unsigned long data;
- 458
- 459 timer = list_entry(head->next,struct timer_list,entry);
- 460 fn = timer->function;
- 461 data = timer->data;
- 462
- 463 list_del(&timer->entry);
- 464 set_running_timer(base, timer);
- 465 smp_wmb();
- 466 timer->base = NULL;
- 467 spin_unlock_irq(&base->lock);
- 468 {
- 469 u32 preempt_count = preempt_count();
- 470 fn(data);
- 471 if (preempt_count != preempt_count()) {
- 472 printk("huh, entered %p with %08x, exited with %08x?\n", fn, preempt_count, preempt_count());
- 473 BUG();
- 474 }
- 475 }
- 476 spin_lock_irq(&base->lock);
- 477 goto repeat;
- 478 }
- 479 }
- 480 set_running_timer(base, NULL);
- 481 spin_unlock_irq(&base->lock);
- 482}
复制代码 |
|