We build our current_affair.ko kernel module (we don't show the build output here) and then insert it into kernel space (via insmod(8) as usual). Now let's view the kernel log with dmesg(1), then rmmod(8) it and use dmesg(1) again. The following screenshot shows this:
Figure 6.9 – The output of the current_affairs.ko kernel module
Clearly, as can be seen from the preceding screenshot, the process context – the process (or thread) running the kernel code of current_affairs.ko:current_affairs_init() – is the insmod process (see the output: 'name : insmod'), and the current_affairs.ko:current_affairs_exit() process context executing the cleanup code is the rmmod process!
Notice how the timestamps in the left column ([sec.usec]) in the preceding figure help us understand...