mirror of
https://github.com/cirosantilli/linux-kernel-module-cheat.git
synced 2026-01-23 10:15:57 +01:00
fix wait_queue rmmod deadlock, wait_queue2, add insrm.sh that was used to test wait_queue lock, which obsoletes workqueue_cheat.sh
This commit is contained in:
@@ -39,8 +39,6 @@ static int kthread_func1(void *data)
|
||||
wake_up(&queue);
|
||||
i++;
|
||||
}
|
||||
i = !i;
|
||||
wake_up_interruptible(&queue);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -50,7 +48,7 @@ static int kthread_func2(void *data)
|
||||
while (!kthread_should_stop()) {
|
||||
pr_info("2 %u\n", i);
|
||||
i++;
|
||||
wait_event_interruptible(queue, atomic_read(&awake));
|
||||
wait_event(queue, atomic_read(&awake));
|
||||
atomic_set(&awake, 0);
|
||||
schedule();
|
||||
}
|
||||
@@ -69,8 +67,9 @@ static int myinit(void)
|
||||
|
||||
static void myexit(void)
|
||||
{
|
||||
kthread_stop(kthread1);
|
||||
/* 2 must be stopped before, or else we can deadlock. */
|
||||
kthread_stop(kthread2);
|
||||
kthread_stop(kthread1);
|
||||
}
|
||||
|
||||
module_init(myinit)
|
||||
|
||||
@@ -28,8 +28,6 @@ static int kthread_wake_func(void *data)
|
||||
wake_up(&queue);
|
||||
i++;
|
||||
}
|
||||
i = !i;
|
||||
wake_up_interruptible(&queue);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -73,7 +71,7 @@ int init_module(void)
|
||||
|
||||
void cleanup_module(void)
|
||||
{
|
||||
kthread_stop(kthread_wake);
|
||||
kthread_stop(kthread_sleep1);
|
||||
kthread_stop(kthread_sleep2);
|
||||
kthread_stop(kthread_sleep1);
|
||||
kthread_stop(kthread_wake);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user