Kernel Monitor?

Ashwin Chandra ashcs at ucla.edu
Mon Feb 14 00:28:45 PST 2005


Hi everyone,
Im having issues with the following code running as a kernel thread. when i do the prinft (which i traced with kgdb) it crashes...but those two variables that i print out, are fine if i do comparisons or store them into variables...only printing them causes a panic. anyone have any ideas in what im doing wrong?






static void     kernmon(void);
static void     kernmon_thread(void);
static void     kern_print(void);

static struct kproc_desc kernmon_kp = {
        "kernmon",
        kernmon_thread,
        NULL
};

SYSINIT(kernmon, SI_SUB_KERN_MON, SI_ORDER_FIRST, kproc_start, &kernmon_kp)

static void
kernmon(void)
{
  kern_print();
}

static void
kernmon_thread(void)
{
  int nowake = 0;
  for (;;) {
    kernmon();
    tsleep(&nowake, curthread->td_priority, "-", 7*hz);

  }
}

static void
kern_print(void)
{
  struct proc *p;

  FOREACH_PROC_IN_SYSTEM(p) {
    mtx_lock(&Giant);
    PROC_LOCK(p);
    printf("%d %d\n", (int)p->p_stats->p_ru.ru_isrss, (int)p->p_stats->p_ru.ru_idrss);
    PROC_UNLOCK(p);
    mtx_unlock(&Giant);
  }


}


More information about the freebsd-hackers mailing list