# Linux Kernel Module Cheat
The perfect emulation setup to study and develop the <<linux-kernel>> v5.9.2, kernel modules, <<qemu-buildroot-setup,QEMU>>, <<gem5-buildroot-setup,gem5>> and x86_64, ARMv7 and ARMv8 <<userland-assembly,userland>> and <<baremetal-setup,baremetal>> assembly, <<c,ANSI C>>, <<cpp,C++>> and <<posix,POSIX>>. <<gdb>> and <<kgdb>> just work. Powered by <<about-the-qemu-buildroot-setup,Buildroot>> and <<about-the-baremetal-setup,crosstool-NG>>. Highly automated. Thoroughly documented. Automated <<test-this-repo,tests>>.

#### 17.9.2. sleep

Count to dmesg every one second from `0` up to `n - 1`:

    insmod sleep.ko n=5

Source: kernel_modules/sleep.c

The sleep is done with a call to `usleep_range` directly inside `module_init` for simplicity.

Bibliography:

- https://stackoverflow.com/questions/15994603/how-to-sleep-in-the-linux-kernel/44153288#44153288

- https://github.com/torvalds/linux/blob/v4.17/Documentation/timers/timers-howto.txt