From 937051217618df77c202b367696a657354aa8a78 Mon Sep 17 00:00:00 2001 From: Ciro Santilli Date: Mon, 15 May 2017 08:18:51 +0100 Subject: [PATCH] delay attempt 2 --- README.md | 4 ++++ kernel_module/delay.c | 5 +++-- kernel_module/workqueue_cheat.c | 4 ++++ run | 2 ++ 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 6b559fab..d6033e83 100644 --- a/README.md +++ b/README.md @@ -31,6 +31,10 @@ When your kernel starts crashing, get the full trace with: ./run -n +See also: + +Then if you want your terminal back, hit `Ctrl + C, A` and type `quit`. See also: + 1. [Introduction](introduction.md) 1. [Build](build.md) 1. [kmod](kmod.md) diff --git a/kernel_module/delay.c b/kernel_module/delay.c index ebf58897..90ac0f44 100644 --- a/kernel_module/delay.c +++ b/kernel_module/delay.c @@ -7,8 +7,6 @@ Usage: dmesg prints an integer every second until rmmod. Since insmod returns, this Illustrates how the work queues are asynchronous. - -TODO: insmod not returning... */ #include @@ -43,6 +41,9 @@ int init_module(void) void cleanup_module(void) { + /* This waits for the work to finish. From docstring: */ + /* > Cancel @work and wait for its execution to finish. */ cancel_work_sync(&work); + destroy_workqueue(queue); } diff --git a/kernel_module/workqueue_cheat.c b/kernel_module/workqueue_cheat.c index 39553f60..36e20748 100644 --- a/kernel_module/workqueue_cheat.c +++ b/kernel_module/workqueue_cheat.c @@ -9,6 +9,10 @@ Creates a separate thread. So init_module can return, but some work will still g Can't call this just workqueue.c because there is already a built-in with that name: https://unix.stackexchange.com/questions/364956/how-can-insmod-fail-with-kernel-module-is-already-loaded-even-is-lsmod-does-not + +Bibliography: + +- https://www.ibm.com/developerworks/library/l-tasklets/ */ #include diff --git a/run b/run index dbc2b1fb..f447666b 100755 --- a/run +++ b/run @@ -33,7 +33,9 @@ qemu-system-x86_64 \ -append "root=/dev/vda $extra_append" \ -drive file=output/images/rootfs.ext2,if=virtio,format=raw \ -kernel output/images/bzImage \ + -m 128M \ -net nic,model=virtio \ -net user \ + -smp 1 \ $extra_flags \ ;