Chinaunix首页 | 论坛 | 博客
  • 博客访问: 408634
  • 博文数量: 61
  • 博客积分: 1991
  • 博客等级: 上尉
  • 技术积分: 492
  • 用 户 组: 普通用户
  • 注册时间: 2007-05-08 12:28
文章分类

全部博文(61)

文章存档

2011年(5)

2010年(21)

2009年(3)

2008年(4)

2007年(28)

我的朋友

分类: BSD

2007-05-15 16:02:42

硬件时钟中断,需要处理非紧急时钟事务时,调度softclock,以便在响应完硬件时钟中断后运行softclock。

代码:

/*
* The real-time timer, interrupting hz times per second.
*/

void
hardclock(frame)
  register struct clockframe *frame;
{
  ......

  if (need_softclock)
    swi_sched(softclock_ih, 0);

  ......
}

/*
* Schedule a heavyweight software interrupt process.
*/

void
swi_sched(void *cookie, int flags)
{
  struct intrhand *ih = (struct intrhand *)cookie;
  struct ithd *it = ih->ih_ithread;
  int error;

  atomic_add_int(&cnt.v_intr, 1); /* one more global interrupt */
    
  CTR3(KTR_INTR, "swi_sched pid %d(%s) need=%d",
    it->it_td->td_proc->p_pid, it->it_td->td_proc->p_comm, it->it_need);

  /*
  * Set ih_need for this handler so that if the ithread is already
  * running it will execute this handler on the next pass. Otherwise,
  * it will execute it the next time it runs.
  */

  atomic_store_rel_int(&ih->ih_need, 1);
  if (!(flags & SWI_DELAY)) {
    error = ithread_schedule(it, !cold && !dumping);
    KASSERT(error == 0, ("stray software interrupt"));
  }
}

阅读(1616) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~