nhmk/examples/sched.c
Jim Huang 10c7a9433a Apply editorial changes
This patch makes source listing shorter and more compact, that helps
when browsing.
2021-08-08 01:24:59 +08:00

35 lines
635 B
C

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