#include #include #include #include #include #include #include #include #include static int create_thread(void); static void thread_handler(void *); static void thread_handler(void *arg) { printf("in %s on %d\n", __func__, curcpu); } static int create_thread(void) { struct intr_event *ie; void *ie_cookie; int error; error = swi_add(&ie, "bind_test", thread_handler, NULL, SWI_CLOCK, INTR_MPSAFE, &ie_cookie); if (error) { printf("swi_add failed with %d\n", error); return (error); } error = intr_event_bind(ie, 1); if (error) { printf("intr_event_bind failed with %d\n", error); return (error); } swi_sched(ie_cookie, 0); printf("swi_bind loaded\n"); return (0); } static int swi_bind_modevent(struct module *m, int what, void *arg) { int error; switch (what) { case MOD_LOAD: error = create_thread(); case MOD_UNLOAD: case MOD_SHUTDOWN: default: error = 0; } return (error); } static moduledata_t swi_bind_mod = { "swi_bind", swi_bind_modevent, NULL }; DECLARE_MODULE(swi_bind, swi_bind_mod, SI_SUB_KTHREAD_VM, SI_ORDER_ANY);