3.1登记

2009-05-13 08:08:36来源:未知 阅读 ()

新老客户大回馈,云服务器低至5折


系统启动时,调用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));
}


本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u1/38079/showart_302014.html

标签:

版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有

上一篇:3 软件中断swi

下一篇:3.2调度