delay attempt 2

This commit is contained in:
Ciro Santilli
2017-05-15 08:18:51 +01:00
parent c82378c7de
commit 9370512176
4 changed files with 13 additions and 2 deletions

View File

@@ -31,6 +31,10 @@ When your kernel starts crashing, get the full trace with:
./run -n ./run -n
See also: <https://unix.stackexchange.com/questions/208260/how-to-scroll-up-after-a-kernel-panic>
Then if you want your terminal back, hit `Ctrl + C, A` and type `quit`. See also: <http://stackoverflow.com/questions/14165158/how-to-switch-to-qemu-monitor-console-when-running-with-curses>
1. [Introduction](introduction.md) 1. [Introduction](introduction.md)
1. [Build](build.md) 1. [Build](build.md)
1. [kmod](kmod.md) 1. [kmod](kmod.md)

View File

@@ -7,8 +7,6 @@ Usage:
dmesg prints an integer every second until rmmod. dmesg prints an integer every second until rmmod.
Since insmod returns, this Illustrates how the work queues are asynchronous. Since insmod returns, this Illustrates how the work queues are asynchronous.
TODO: insmod not returning...
*/ */
#include <linux/delay.h> #include <linux/delay.h>
@@ -43,6 +41,9 @@ int init_module(void)
void cleanup_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); cancel_work_sync(&work);
destroy_workqueue(queue); destroy_workqueue(queue);
} }

View File

@@ -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: 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 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 <linux/kernel.h> #include <linux/kernel.h>

2
run
View File

@@ -33,7 +33,9 @@ qemu-system-x86_64 \
-append "root=/dev/vda $extra_append" \ -append "root=/dev/vda $extra_append" \
-drive file=output/images/rootfs.ext2,if=virtio,format=raw \ -drive file=output/images/rootfs.ext2,if=virtio,format=raw \
-kernel output/images/bzImage \ -kernel output/images/bzImage \
-m 128M \
-net nic,model=virtio \ -net nic,model=virtio \
-net user \ -net user \
-smp 1 \
$extra_flags \ $extra_flags \
; ;