Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <sys/types.h>
- #include <sys/module.h>
- #include <sys/systm.h>
- #include <sys/errno.h>
- #include <sys/param.h>
- #include <sys/kernel.h>
- #include <sys/queue.h>
- #include <sys/taskqueue.h>
- #include <sys/malloc.h>
- void static repeater_proc(void *, int);
- void init_repeater(void);
- struct taskqueue;
- struct taskq {
- struct taskqueue *tq_queue;
- };
- struct controller {
- struct task fail_req_task;
- };
- static void
- repeater_proc(void *arg, int npending) {
- char *str = arg;
- printf("Received message %s\n", str);
- }
- void
- init_repeater()
- {
- struct taskq *tq;
- struct controller *ctrl;
- struct task *setroot_task;
- setroot_task = malloc(sizeof(struct task), M_TEMP, M_NOWAIT);
- tq = malloc(sizeof(struct taskq), M_TEMP, M_WAITOK);
- ctrl = malloc(sizeof(struct controller), M_TEMP, M_WAITOK);
- tq->tq_queue = taskqueue_create("farhan", M_NOWAIT | M_ZERO,
- taskqueue_thread_enqueue, &tq->tq_queue);
- taskqueue_start_threads(&tq->tq_queue, 1, PI_DISK, "%s Test456", "Test123");
- TASK_INIT(&ctrl->fail_req_task, 0, repeater_proc, "Test");
- }
- static int
- repeater_loader(struct module *m, int what, void *arg)
- {
- int err = 0;
- printf("Within the loader\n");
- switch (what) {
- case MOD_LOAD:
- init_repeater();
- uprintf("Repeater KLD loaded.\n");
- break;
- case MOD_UNLOAD:
- uprintf("Repeater KLD unloaded.\n");
- break;
- }
- return(err);
- }
- static moduledata_t repeater_mod = {
- "repeater",
- repeater_loader,
- NULL
- };
- DECLARE_MODULE(repeater, repeater_mod, SI_SUB_KLD, SI_ORDER_ANY);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement