sched.c 638 B

123456789101112131415161718192021222324252627282930313233
  1. /*
  2. * sched.c
  3. */
  4. #include <linux/init.h>
  5. #include <linux/module.h>
  6. #include <linux/workqueue.h>
  7. static struct workqueue_struct *queue = NULL;
  8. static struct work_struct work;
  9. static void work_handler(struct work_struct *data)
  10. {
  11. pr_info("work handler function.\n");
  12. }
  13. static int __init sched_init(void)
  14. {
  15. queue = alloc_workqueue("HELLOWORLD", WQ_UNBOUND, 1);
  16. INIT_WORK(&work, work_handler);
  17. queue_work(queue, &work);
  18. return 0;
  19. }
  20. static void __exit sched_exit(void)
  21. {
  22. destroy_workqueue(queue);
  23. }
  24. module_init(sched_init);
  25. module_exit(sched_exit);
  26. MODULE_LICENSE("GPL");
  27. MODULE_DESCRIPTION("Workqueue example");