lkmpg/examples/sched.c

35 lines
635 B
C
Raw Normal View History

/*
* sched.c
*/
2021-07-22 06:35:24 +08:00
#include <linux/init.h>
#include <linux/module.h>
2021-07-22 06:35:24 +08:00
#include <linux/workqueue.h>
static struct workqueue_struct *queue = NULL;
2021-07-22 06:35:24 +08:00
static struct work_struct work;
static void work_handler(struct work_struct *data)
{
pr_info("work handler function.\n");
2021-07-22 06:35:24 +08:00
}
static int __init sched_init(void)
2021-07-22 06:35:24 +08:00
{
queue = alloc_workqueue("HELLOWORLD", WQ_UNBOUND, 1);
INIT_WORK(&work, work_handler);
schedule_work(&work);
return 0;
}
static void __exit sched_exit(void)
2021-07-22 06:35:24 +08:00
{
destroy_workqueue(queue);
}
module_init(sched_init);
module_exit(sched_exit);
2021-07-22 06:35:24 +08:00
MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("Workqueue example");