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

全部博文(61)

文章存档

2011年(5)

2010年(21)

2009年(3)

2008年(4)

2007年(28)

我的朋友

分类: BSD

2007-05-15 16:00:43

系统启动时,调用start_softintr()登记两个重要的软件中断,软时钟中断和VM软中断。当情况需要时,内核将调用swi_sched()来调度软件中断的运行。

代码:

/*
* Start standard software interrupt threads
*/

static void
start_softintr(void *dummy)
{
  struct proc *p;

  if (swi_add(&clk_ithd, "clock", softclock, NULL, SWI_CLOCK,
    INTR_MPSAFE, &softclock_ih) ||
    swi_add(NULL, "vm", swi_vm, NULL, SWI_VM, INTR_MPSAFE, &vm_ih))
    panic("died while creating standard software ithreads");

  p = clk_ithd->it_td->td_proc;
  PROC_LOCK(p);
  p->p_flag |= P_NOLOAD;
  PROC_UNLOCK(p);
}

int
swi_add(struct ithd **ithdp, const char *name, driver_intr_t handler,
    void *arg, int pri, enum intr_type flags, void **cookiep)
{
  struct ithd *ithd;
  int error;

  if (flags & (INTR_FAST | INTR_ENTROPY))
    return (EINVAL);

  ithd = (ithdp != NULL) ? *ithdp : NULL;

  if (ithd != NULL) {
    if ((ithd->it_flags & IT_SOFT) == 0)
      return(EINVAL);
  } else {
    error = ithread_create(&ithd, pri, IT_SOFT, NULL, NULL,
      "swi%d:", pri);
    if (error)
      return (error);

    if (ithdp != NULL)
      *ithdp = ithd;
  }
  return (ithread_add_handler(ithd, name, handler, arg,
      (pri * RQ_PPQ) + PI_SOFT, flags, cookiep));
}

阅读(1409) | 评论(0) | 转发(0) |
0

上一篇:3 软件中断swi

下一篇:3.2调度

给主人留下些什么吧!~~