Now, let's try it out (ch5/kthread_simple)! We can perform module insertion via insmod(8); the module gets inserted into the kernel as planned. The kernel log shown in the following screenshot, as well as a quick ps, proves that our brand new kernel thread has indeed been created. Also, as you can see from the code (ch5/kthread_simple/kthread_simple.c), our kthread puts itself to sleep (by setting its state to TASK_INTERRUPTIBLE and then calling schedule()):
Figure 5.5 – A partial screenshot showing that our kernel thread is born, alive – and, well, asleep
Quickly running ps(1) grep for our kernel thread by name shows that our kthread is alive and well (and asleep):
$ ps -e |grep kt_simple
11372 ? 00:00:00 llkd/kt_simple
$
Let's shake things up a bit and send the SIGQUIT signal to our kthread. This has it wake up (since we've set its signal mask to allow the...