2021-07-22 11:25:32 +08:00
|
|
|
/*
|
|
|
|
* sched.c
|
|
|
|
*/
|
2021-07-22 06:35:24 +08:00
|
|
|
#include <linux/init.h>
|
2021-07-22 06:58:13 +08:00
|
|
|
#include <linux/module.h>
|
2021-07-22 06:35:24 +08:00
|
|
|
#include <linux/workqueue.h>
|
|
|
|
|
2021-07-22 06:58:13 +08:00
|
|
|
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)
|
|
|
|
{
|
2021-07-22 06:58:13 +08:00
|
|
|
pr_info("work handler function.\n");
|
2021-07-22 06:35:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
int init_module()
|
|
|
|
{
|
|
|
|
queue = alloc_workqueue("HELLOWORLD", WQ_UNBOUND, 1);
|
|
|
|
INIT_WORK(&work, work_handler);
|
|
|
|
schedule_work(&work);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void cleanup_module()
|
|
|
|
{
|
|
|
|
destroy_workqueue(queue);
|
|
|
|
}
|
|
|
|
|
|
|
|
MODULE_LICENSE("GPL");
|
|
|
|
MODULE_DESCRIPTION("Workqueue example");
|