sched.c 554 B

12345678910111213141516171819202122232425262728293031
  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. int init_module()
  14. {
  15. queue = alloc_workqueue("HELLOWORLD", WQ_UNBOUND, 1);
  16. INIT_WORK(&work, work_handler);
  17. schedule_work(&work);
  18. return 0;
  19. }
  20. void cleanup_module()
  21. {
  22. destroy_workqueue(queue);
  23. }
  24. MODULE_LICENSE("GPL");
  25. MODULE_DESCRIPTION("Workqueue example");