More simple kthread experiments, failed wait queue experiment

This commit is contained in:
Ciro Santilli
2017-05-25 08:18:03 +01:00
parent 3eaac95c0f
commit 36f48aa9c7
5 changed files with 161 additions and 2 deletions

View File

@@ -0,0 +1,38 @@
/*
Let's block the entire kernel! Yay!
Also try after dmesg -n 1 to become convinced of the full blockage.
*/
#include <linux/kernel.h>
#include <linux/kthread.h>
#include <linux/module.h>
MODULE_LICENSE("GPL");
static struct task_struct *kthread;
static int work_func(void *data)
{
set_current_state(TASK_UNINTERRUPTIBLE);
int i = 0;
while (!kthread_should_stop()) {
printk(KERN_INFO "%d\n", i);
i++;
if (i == 10)
i = 0;
}
return 0;
}
int init_module(void)
{
kthread = kthread_create(work_func, NULL, "mykthread");
wake_up_process(kthread);
return 0;
}
void cleanup_module(void)
{
kthread_stop(kthread);
}