Kernel Thread Code example

The below code block provides a sample implementation for kernel threads. the sample implementation only indicates a single operation for the thread. normally the a kernel thread will be performing cleanup operations or other background tasks continuously the output for the kernel thread code is shown below Device drivers – Character device driver example

Kernel Threads

The Linux kernel spawns threads which handle background operation. These kernel threads have a PID and also contain a task structure similar to a process. However, the kernel thread does not have a specific address space where they are mapped to. The kernel threads run exclusively in kernel space and take care of asynchronous events […]

Creating a dedicated workqueue

In the previous articles, we created work and we scheduled the work using default worker threads. If a dedicated workqueue is desired specifically to handle specific work for the kernel module that you are developing, a workqueue can be created using “create_workqueue” API. The code block creates a work queue, assigns initialized work and later […]

Workqueue APIs

The below table lists out the different workqueue APIs that are commonly used in the intialization and usage of a workqueue. For a comprehensive list – refer “workqueue.h” in the linux kernel. Workqueue API Description schedule_work Schedule the work to be performed schedule_delayed_work Put work task in global workqueue after delay create_workqueue Creating a new […]