Let's take it for a spin! Take a look at the following screenshot:
Figure 5.12 – Our workq_simple.ko LKM with the work queue function execution highlighted
Let's take a look at this code in more detail:
- Via our lkm helper script, we build and then insmod(8) the kernel module; that is, workq_simple.ko.
- The kernel log is displayed via dmesg(1):
- Here, the workqueue and kernel timer are initialized and armed within the init method.
- The timer expires (in approximately 420 ms); you can see its printks (showing timed out... and the value of our data variable).
- It invokes the schedule_work() API, causing our workqueue function to run.
- As highlighted in the preceding screenshot, our work queue function, work_func(), indeed runs; it displays the data variable's current value, proving that it correctly gained access to our "context" or private...