Creating Tasklet : Static Method ================================ .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow Topics in this section, * :ref:`Version Info ` * :ref:`Learnings in this section ` * :ref:`Explanation of tasklet APIs ` * :ref:`DECLARE_TASKLET ` * :ref:`tasklet_schedule ` * :ref:`tasklet_kill ` * :ref:`Explanation of miscellaneous APIs ` * :ref:`Module parameter APIs ` * :ref:`Driver entry point APIs ` * :ref:`Example 1: Creating tasklet using DECLARE_TASKLET ` * :ref:`List of headers ` * :ref:`Module Macros ` * :ref:`Declare and Initialize tasklet ` * :ref:`Tasklet Handler Function ` * :ref:`Tasklet Start Function ` * :ref:`Task Init Function ` * :ref:`Tasklet Stop Function ` * :ref:`Task Exit Function ` * :ref:`Driver entry points ` * :ref:`See the full program below ` * :ref:`Makefile ` * :ref:`Compile and load the module ` * :ref:`Example 2: Creating tasklet using DECLARE_TASKLET_OLD ` * :ref:`List of headers ` * :ref:`Module Macros ` * :ref:`Declare and Initialize tasklet ` * :ref:`Tasklet Handler Function ` * :ref:`Tasklet Start Function ` * :ref:`Task Init Function ` * :ref:`Tasklet Stop Function ` * :ref:`Task Exit Function ` * :ref:`Driver entry points ` * :ref:`See the full program below ` * :ref:`Makefile ` * :ref:`Compile and load the module ` * :ref:`Example 3: Creating tasklet using DECLARE_TASKLET_DISABLED ` * :ref:`List of headers ` * :ref:`Module Macros ` * :ref:`Declare and Initialize tasklet ` * :ref:`Tasklet Handler Function ` * :ref:`Tasklet Start Function ` * :ref:`Task Init Function ` * :ref:`Tasklet Stop Function ` * :ref:`Task Exit Function ` * :ref:`Driver entry points ` * :ref:`See the full program below ` * :ref:`Makefile ` * :ref:`Compile and load the module ` .. _p1_taskletstatic_0: .. tab-set:: .. tab-item:: Version Info =============================== ======================================= # Version =============================== ======================================= Ubuntu Ubuntu 22.10 Kernel 6.8.0 =============================== ======================================= .. _p1_taskletstatic_1: .. tab-set:: .. tab-item:: Learnings in this section * In this program, you are going to learn .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow * How to create tasklet in static method ? .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow * What are the different ways to create tasklet ? .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow * How to kill the tasklet ? .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow * How to use tasklet APIs ? * `DECLARE_TASKLET `_ * `tasklet_schedule `_ * `tasklet_kill `_ * `DECLARE_TASKLET_OLD `_ * `DECLARE_TASKLET_DISABLED `_ .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow * How to use below APIs ? * `MODULE_LICENSE `_ * `MODULE_DESCRIPTION `_ * `MODULE_AUTHOR `_ * `module_init `_ * `module_exit `_ .. _p1_taskletstatic_2: .. tab-set:: .. tab-item:: Explanation of tasklet APIs .. _p1_taskletstatic_3: .. tab-set:: .. tab-item:: DECLARE_TASKLET * Here is the function prototype of the API: `DECLARE_TASKLET `_ .. code-block:: c #include #define DECLARE_TASKLET(name, _callback) * Here is an example of how to use the API, .. code-block:: c DECLARE_TASKLET(my_tasklet, (void *)tasklet_handler); .. _p1_taskletstatic_4: .. tab-set:: .. tab-item:: tasklet_schedule * Here is the function prototype of the API: `tasklet_schedule `_ .. code-block:: c #include static inline void tasklet_schedule(struct tasklet_struct *t); * where * `tasklet_schedule `_: Schedules the tasklet. * struct tasklet_struct * t : Parameter of type pointer to struct tasklet_struct, which represents the tasklet that is being scheduled for execution. * Here is an example of how to use the API, .. code-block:: c tasklet_schedule(&my_tasklet); .. _p1_taskletstatic_5: .. tab-set:: .. tab-item:: tasklet_kill * Here is the function prototype of the API: `tasklet_kill `_ .. code-block:: c #include extern void tasklet_kill(struct tasklet_struct *t); * where * `tasklet_kill `_: kills tasklet. * struct tasklet_struct * t : Parameter of type pointer to struct tasklet_struct, representing the tasklet that is to be killed or stopped. * Here is an example of how to use the API, .. code-block:: c tasklet_kill(&my_tasklet); .. _p1_taskletstatic_6: .. tab-set:: .. tab-item:: Explanation of miscellaneous APIs .. _p1_taskletstatic_7: .. tab-set:: .. tab-item:: Module parameter APIs * Here is the prototype of module paramter APIs .. code-block:: c #include #define MODULE_LICENSE(_license) MODULE_FILE MODULE_INFO(license, _license) #define MODULE_AUTHOR(_author) MODULE_INFO(author, _author) #define MODULE_DESCRIPTION(_description) MODULE_INFO(description, _description) * where * `MODULE_LICENSE `_: tells the kernel what license is used by our module. * `MODULE_AUTHOR `_: denotes the author of this kernel module. * `MODULE_DESCRIPTION `_: gives a basic idea about what the kernel module does. * These information can be found when modinfo command is used which lists out all these above mentioned information. * Here is the example of how to use the Module parameter APIs, .. code-block:: c MODULE_LICENSE("GPL"); MODULE_AUTHOR("usr"); MODULE_DESCRIPTION("Tasklet"); .. _p1_taskletstatic_8: .. tab-set:: .. tab-item:: Driver entry point API's * Here is the prototype of the Driver entry point API's .. code-block:: c #include #define module_init(x) __initcall(x); #define module_exit(x) __exitcall(x); * where * `module_init `_: driver initialization entry point which will be called at module insertion time. * `module_exit `_: driver exit entry point which will be called during the removal of module. * x: * function to be run at module insertion for `module_init `_ function. * function to be run when driver is removed for `module_exit `_ function. * Here is an example of how to use the driver entry point API's .. code-block:: c module_init(task_init); module_exit(task_exit); .. _p1_taskletstatic_9: .. tab-set:: .. tab-item:: Example 1: Creating tasklet using DECLARE_TASKLET * In this example let's see how to create tasklet using DECLARE_TASKLET and execute it. .. _p1_taskletstatic_10: .. tab-set:: .. tab-item:: List of headers * Include the follow header files(.h) to refer the API being used for the execution. .. code-block:: c #include #include #include #include #include .. _p1_taskletstatic_11: .. tab-set:: .. tab-item:: Module macros * Add the following module macros to display information about the license, author and description about the module. .. code-block:: c MODULE_LICENSE("GPL"); MODULE_AUTHOR("usr"); MODULE_DESCRIPTION("Tasklet"); .. _p1_taskletstatic_12: .. tab-set:: .. tab-item:: Declare and Initialize tasklet * Declare and initialize the tasklet which we are going to create and use in this example .. code-block:: c DECLARE_TASKLET(my_tasklet, (void *)tasklet_handler); .. _p1_taskletstatic_13: .. tab-set:: .. tab-item:: Tasklet Handler Function * This function executes once the tasklet is scheduled using tasklet_schedule. .. code-block:: c void tasklet_handler(struct tasklet_struct *t) { int *ptr; ptr = (int *) t->data; pr_info("Executing tasklet handler function\n"); pr_info("data addr : %x\n", (unsigned int)t->data); pr_info("*ptr addr : %x\n", (unsigned int)ptr); pr_info("*ptr value : %ld\n", (unsigned long)*ptr); } .. _p1_taskletstatic_14: .. tab-set:: .. tab-item:: Tasklet Start Function * This function schedules a tasklet. .. code-block:: c void tasklet_start(void) { my_tasklet.data = (unsigned long)&a; pr_info("my_tasklet.data : %x\n", (unsigned int)my_tasklet.data); pr_info("&my_tasklet.data : %x\n", (unsigned int)&my_tasklet.data); pr_info("a value : %ld\n", (unsigned long)a); pr_info("a addr : %x\n", (unsigned int)&a); pr_info("Scheduling the tasklet\n"); tasklet_schedule(&my_tasklet); } .. _p1_taskletstatic_15: .. tab-set:: .. tab-item:: Task Init Function * This function calls tasklet_start function, will be executed once the module is loaded into the linux kernel. .. code-block:: c static int __init task_init(void) { pr_info("driver loaded\n"); tasklet_start(); return 0; } .. _p1_taskletstatic_16: .. tab-set:: .. tab-item:: Tasklet Stop Function * This function kills tasklet and stops it's execution. .. code-block:: c void tasklet_stop(void) { tasklet_kill(&my_tasklet); pr_info("tasklet killed\n"); } .. _p1_taskletstatic_17: .. tab-set:: .. tab-item:: Task Exit Function * This function calls tasklet_stop function, will be executed once the module is removed from the linux kernel .. code-block:: c static void __exit task_exit(void) { tasklet_stop(); pr_info("driver unloaded!\n"); } .. _p1_taskletstatic_18: .. tab-set:: .. tab-item:: Driver entry points * Add the driver entry points which will be executed once the module is inserted or removed from the kernel. .. code-block:: c module_init(task_init); module_exit(task_exit); .. _p1_taskletstatic_19: .. tab-set:: .. tab-item:: See the full program below .. tab-set:: .. tab-item:: tasklet.c .. literalinclude:: create_static/tc1/tasklet.c :language: c :linenos: .. _p1_taskletstatic_20: .. tab-set:: .. tab-item:: Makefile .. literalinclude:: create_static/tc1/Makefile :language: c :linenos: .. _p1_taskletstatic_21: .. tab-set:: .. tab-item:: Compile and load the module * Run make to compile the kernel source and generate the .ko image. .. code-block:: shell $ make make -C /lib/modules/6.8.0/build M=/home/test/Desktop/kernel_api/tasklet/create_static/tc1 modules make[1]: Entering directory '/home/test/Desktop/kernel_api/linux-6.8' CC [M] /home/test/Desktop/kernel_api/tasklet/create_static/tc1/tasklet.o MODPOST /home/test/Desktop/kernel_api/tasklet/create_static/tc1/Module.symvers CC [M] /home/test/Desktop/kernel_api/tasklet/create_static/tc1/tasklet.mod.o LD [M] /home/test/Desktop/kernel_api/tasklet/create_static/tc1/tasklet.ko make[1]: Leaving directory '/home/test/Desktop/kernel_api/linux-6.8' * Check if the .ko is generated or not using ls command. .. code-block:: shell $ ls -l total 376 -rw-rw-r-- 1 test test 206 Jun 21 12:17 Makefile -rw-rw-r-- 1 test test 66 Jul 11 16:11 modules.order -rw-rw-r-- 1 test test 0 Jul 11 16:11 Module.symvers -rw-rw-r-- 1 test test 1548 Jul 11 16:07 tasklet.c -rw-rw-r-- 1 test test 178256 Jul 11 16:11 tasklet.ko -rw-rw-r-- 1 test test 66 Jul 11 16:11 tasklet.mod -rw-rw-r-- 1 test test 1039 Jul 11 16:11 tasklet.mod.c -rw-rw-r-- 1 test test 149152 Jul 11 16:11 tasklet.mod.o -rw-rw-r-- 1 test test 30464 Jul 11 16:11 tasklet.o * Run modinfo command to get the information about the kernel module. .. code-block:: shell $ modinfo tasklet.ko filename: /home/test/Desktop/kernel_api/tasklet/create_static/tc1/tasklet.ko description: Tasklet author: usr license: GPL srcversion: A00B74CEDDF5019A762E676 depends: retpoline: Y name: tasklet vermagic: 6.8.0 SMP preempt mod_unload modversions * insert the module using insmod command. .. code-block:: shell $ sudo insmod ./tasklet.ko * check if the module is loaded or not using lsmod command. .. code-block:: shell $ lsmod | grep tasklet tasklet 12288 0 * check for the kernel messages from init function and thread function once the module is loaded and thread is created. .. code-block:: shell $ sudo dmesg [534397.572870] driver loaded [534397.572877] Scheduling the tasklet [534397.573501] Executing asklet handler function [534397.573504] *ptr value : 10 * remove the module from kernel using rmmod command. .. code-block:: shell $ sudo rmmod tasklet * check if the module is still loaded after removing the kernel module using lsmod if it is not displayed in lsmod output it is verified that the module is removed successfully. .. code-block:: shell $ lsmod | grep tasklet * Check for kernel messages from exit function using dmesg command. .. code-block:: shell $ sudo dmesg [534515.467513] tasklet killed [534515.467516] driver unloaded! .. _p1_taskletstatic_22: .. tab-set:: .. tab-item:: Example 2: Creating tasklet using DECLARE_TASKLET_OLD * In this example let's see how to create tasklet using DECLARE_TASKLET_OLD and execute it. .. _p1_taskletstatic_23: .. tab-set:: .. tab-item:: List of headers * Include the follow header files(.h) to refer the API being used for the execution. .. code-block:: c #include #include #include #include #include .. _p1_taskletstatic_24: .. tab-set:: .. tab-item:: Module macros * Add the following module macros to display information about the license, author and description about the module. .. code-block:: c MODULE_LICENSE("GPL"); MODULE_AUTHOR("usr"); MODULE_DESCRIPTION("Tasklet"); .. _p1_taskletstatic_25: .. tab-set:: .. tab-item:: Declare and Initialize tasklet * Declare and initialize the tasklet which we are going to create and use in this example .. code-block:: c DECLARE_TASKLET_OLD(my_tasklet, (void *)my_tasklet_handler); .. _p1_taskletstatic_26: .. tab-set:: .. tab-item:: Tasklet Handler Function * This function executes once the tasklet is scheduled using tasklet_schedule. .. code-block:: c void my_tasklet_handler(unsigned long data) { int *ptr; ptr = (int *) data; pr_info("Executing tasklet function\n"); pr_info("*ptr : %ld\n", (unsigned long)*ptr); } .. _p1_taskletstatic_27: .. tab-set:: .. tab-item:: Tasklet Start Function * This function schedules a tasklet. .. code-block:: c void tasklet_start(void) { my_tasklet.data = (unsigned long)&a; pr_info("my_tasklet.data : %x\n", (unsigned int)my_tasklet.data); pr_info("&my_tasklet.data : %x\n", &my_tasklet.data); pr_info("a value : %ld\n", a); pr_info("a addr : %x\n", &a); pr_info("Scheduling tasklet\n"); tasklet_schedule(&my_tasklet); pr_info("tasklet scheduled\n"); } .. _p1_taskletstatic_28: .. tab-set:: .. tab-item:: Task Init Function * This function calls tasklet_start function, will be executed once the module is loaded into the linux kernel. .. code-block:: c static int __init task_init(void) { pr_info("driver loaded\n"); tasklet_start(); return 0; } .. _p1_taskletstatic_29: .. tab-set:: .. tab-item:: Tasklet Stop Function * This function kills tasklet and stops it's execution. .. code-block:: c void tasklet_stop(void) { tasklet_kill(&my_tasklet); } .. _p1_taskletstatic_30: .. tab-set:: .. tab-item:: Task Exit Function * This function calls tasklet_stop function, will be executed once the module is removed from the linux kernel .. code-block:: c static void __exit task_exit(void) { pr_info("driver unloaded\n"); tasklet_stop(); } .. _p1_taskletstatic_31: .. tab-set:: .. tab-item:: Driver entry points * Add the driver entry points which will be executed once the module is inserted or removed from the kernel. .. code-block:: c module_init(task_init); module_exit(task_exit); .. _p1_taskletstatic_32: .. tab-set:: .. tab-item:: See the full program below .. tab-set:: .. tab-item:: tasklet.c .. literalinclude:: create_static/tc2/tasklet.c :language: c :linenos: .. _p1_taskletstatic_33: .. tab-set:: .. tab-item:: Makefile .. literalinclude:: create_static/tc2/Makefile :language: c :linenos: .. _p1_taskletstatic_34: .. tab-set:: .. tab-item:: Compile and load the module * Run make to compile the kernel source and generate the .ko image. .. code-block:: shell $ make make -C /lib/modules/6.8.0/build M=/home/test/Desktop/kernel_api/tasklet/create_static/tc2 modules make[1]: Entering directory '/home/test/Desktop/kernel_api/linux-6.8' CC [M] /home/test/Desktop/kernel_api/tasklet/create_static/tc2/tasklet.o MODPOST /home/test/Desktop/kernel_api/tasklet/create_static/tc2/Module.symvers CC [M] /home/test/Desktop/kernel_api/tasklet/create_static/tc2/tasklet.mod.o LD [M] /home/test/Desktop/kernel_api/tasklet/create_static/tc2/tasklet.ko make[1]: Leaving directory '/home/test/Desktop/kernel_api/linux-6.8' * Check if the .ko is generated or not using ls command. .. code-block:: shell $ ls -l total 376 -rw-rw-r-- 1 arun arun 206 Jun 21 12:17 Makefile -rw-rw-r-- 1 arun arun 66 Jul 11 16:19 modules.order -rw-rw-r-- 1 arun arun 0 Jul 11 16:19 Module.symvers -rw-rw-r-- 1 arun arun 1541 Jul 11 16:19 tasklet.c -rw-rw-r-- 1 arun arun 178192 Jul 11 16:19 tasklet.ko -rw-rw-r-- 1 arun arun 66 Jul 11 16:19 tasklet.mod -rw-rw-r-- 1 arun arun 1039 Jul 11 16:19 tasklet.mod.c -rw-rw-r-- 1 arun arun 149152 Jul 11 16:19 tasklet.mod.o -rw-rw-r-- 1 arun arun 30440 Jul 11 16:19 tasklet.o * Run modinfo command to get the information about the kernel module. .. code-block:: shell $ modinfo tasklet.ko filename: /home/arun/Desktop/kernel_api/tasklet/create_static/tc2/tasklet.ko description: Tasklet author: Linux_usr license: GPL srcversion: 8D4858F7AB5C64157D5CF0D depends: retpoline: Y name: tasklet vermagic: 6.8.0 SMP preempt mod_unload modversions * insert the module using insmod command. .. code-block:: shell $ sudo insmod ./tasklet.ko * check if the module is loaded or not using lsmod command. .. code-block:: shell $ lsmod | grep tasklet tasklet 12288 0 * check for the kernel messages from init function and thread function once the module is loaded and thread is created. .. code-block:: shell $ sudo dmesg [534724.012807] driver loaded [534724.012811] Scheduling tasklet [534724.012815] tasklet scheduled [534724.012841] Executing tasklet function [534724.012842] * ptr : 10 * remove the module from kernel using rmmod command. .. code-block:: shell $ sudo rmmod tasklet * check if the module is still loaded after removing the kernel module using lsmod if it is not displayed in lsmod output it is verified that the module is removed successfully. .. code-block:: shell $ lsmod | grep tasklet * Check for kernel messages from exit function using dmesg command. .. code-block:: shell $ sudo dmesg [534742.482383] driver unloaded .. _p1_taskletstatic_35: .. tab-set:: .. tab-item:: Example 3: Creating tasklet using DECLARE_TASKLET_DISABLED * In this example let's see how to create tasklet using DECLARE_TASKLET_DISABLED and execute it. .. _p1_taskletstatic_36: .. tab-set:: .. tab-item:: List of headers * Include the follow header files(.h) to refer the API being used for the execution. .. code-block:: c #include #include #include #include #include .. _p1_taskletstatic_37: .. tab-set:: .. tab-item:: Module macros * Add the following module macros to display information about the license, author and description about the module. .. code-block:: c MODULE_LICENSE("GPL"); MODULE_AUTHOR("usr"); MODULE_DESCRIPTION("Tasklet"); .. _p1_taskletstatic_38: .. tab-set:: .. tab-item:: Declare and Initialize tasklet * Declare and initialize the tasklet which we are going to create and use in this example. * The tasklet can be declared and set at a disabled state, which means that the tasklet can be scheduled, but will not run until the tasklet is specifically enabled. We need to use tasklet_enable to enable. .. code-block:: c DECLARE_TASKLET_DISABLED(my_tasklet, (void *)my_tasklet_handler); .. _p1_taskletstatic_39: .. tab-set:: .. tab-item:: Tasklet Handler Function * This function executes once the tasklet is scheduled using tasklet_schedule. .. code-block:: c void my_tasklet_handler(struct tasklet_struct *t) { int *ptr; ptr = (int *) t->data; pr_info("Executing asklet handler function\n"); pr_info("data addr : %x\n", (unsigned int)t->data); pr_info("*ptr addr : %x\n", (unsigned int)ptr); pr_info("*ptr value : %ld\n", (unsigned long)*ptr); } .. _p1_taskletstatic_40: .. tab-set:: .. tab-item:: Tasklet Start Function * This function schedules a tasklet, but will not run until the tasklet is specifically enabled. .. code-block:: c void tasklet_start(void) { my_tasklet.data = (unsigned long)&a; pr_info("my_tasklet.data : %x\n", (unsigned int)my_tasklet.data); pr_info("&my_tasklet.data : %x\n", (unsigned int)&my_tasklet.data); pr_info("a value : %ld\n", (unsigned long)a); pr_info("a addr : %x\n", (unsigned int)&a); pr_info("Enabling tasklet\n"); tasklet_enable(&my_tasklet); pr_info("Tasklet enabled\n"); pr_info("Scheduling tasklet\n"); tasklet_schedule(&my_tasklet); pr_info("tasklet scheduled\n"); } .. _p1_taskletstatic_41: .. tab-set:: .. tab-item:: Task Init Function * This function calls tasklet_start function, will be executed once the module is loaded into the linux kernel. .. code-block:: c static int __init task_init(void) { pr_info("driver loaded\n"); tasklet_start(); return 0; } .. _p1_taskletstatic_42: .. tab-set:: .. tab-item:: Tasklet Stop Function * This function kills tasklet and stops it's execution. .. code-block:: c void tasklet_stop(void) { tasklet_kill(&my_tasklet); } .. _p1_taskletstatic_43: .. tab-set:: .. tab-item:: Task Exit Function * This function calls tasklet_stop function, will be executed once the module is removed from the linux kernel .. code-block:: c static void __exit task_exit(void) { pr_info("driver unloaded\n"); tasklet_stop(); } .. _p1_taskletstatic_44: .. tab-set:: .. tab-item:: Driver entry points * Add the driver entry points which will be executed once the module is inserted or removed from the kernel. .. code-block:: c module_init(task_init); module_exit(task_exit); .. _p1_taskletstatic_45: .. tab-set:: .. tab-item:: See the full program below .. tab-set:: .. tab-item:: tasklet.c .. literalinclude:: create_static/tc3/tasklet.c :language: c :linenos: .. _p1_taskletstatic_46: .. tab-set:: .. tab-item:: Makefile .. literalinclude:: create_static/tc3/Makefile :language: c :linenos: .. _p1_taskletstatic_47: .. tab-set:: .. tab-item:: Compile and load the module * Run make to compile the kernel source and generate the .ko image. .. code-block:: shell $ make make -C /lib/modules/6.8.0/build M=/home/arun/Desktop/kernel_api/tasklet/create_static/tc3 modules make[1]: Entering directory '/home/arun/Desktop/kernel_api/linux-6.8' CC [M] /home/arun/Desktop/kernel_api/tasklet/create_static/tc3/tasklet.o MODPOST /home/arun/Desktop/kernel_api/tasklet/create_static/tc3/Module.symvers CC [M] /home/arun/Desktop/kernel_api/tasklet/create_static/tc3/tasklet.mod.o LD [M] /home/arun/Desktop/kernel_api/tasklet/create_static/tc3/tasklet.ko make[1]: Leaving directory '/home/arun/Desktop/kernel_api/linux-6.8' * Check if the .ko is generated or not using ls command. .. code-block:: shell $ ls -l total 376 -rw-rw-r-- 1 arun arun 206 Jun 21 12:12 Makefile -rw-rw-r-- 1 arun arun 66 Jul 11 16:23 modules.order -rw-rw-r-- 1 arun arun 0 Jul 11 16:23 Module.symvers -rw-rw-r-- 1 arun arun 1810 Jul 11 16:23 tasklet.c -rw-rw-r-- 1 arun arun 180128 Jul 11 16:23 tasklet.ko -rw-rw-r-- 1 arun arun 66 Jul 11 16:23 tasklet.mod -rw-rw-r-- 1 arun arun 1039 Jul 11 16:23 tasklet.mod.c -rw-rw-r-- 1 arun arun 149152 Jul 11 16:23 tasklet.mod.o -rw-rw-r-- 1 arun arun 32352 Jul 11 16:23 tasklet.o * Run modinfo command to get the information about the kernel module. .. code-block:: shell $ modinfo tasklet.ko filename: /home/arun/Desktop/kernel_api/tasklet/create_static/tc3/tasklet.ko description: Tasklet author: Linux_usr license: GPL srcversion: 816E2EE14D9027FFBC8E642 depends: retpoline: Y name: tasklet vermagic: 6.8.0 SMP preempt mod_unload modversions * insert the module using insmod command. .. code-block:: shell $ sudo insmod ./tasklet.ko * check if the module is loaded or not using lsmod command. .. code-block:: shell $ lsmod | grep tasklet tasklet 12288 0 * check for the kernel messages from init function and thread function once the module is loaded and thread is created. .. code-block:: shell $ sudo dmesg [534914.651150] driver loaded [534914.651160] Enabling tasklet [534914.651162] Tasklet enabled [534914.651164] Scheduling tasklet [534914.651177] tasklet scheduled [534914.651195] Executing asklet handler function [534914.651197] * ptr value : 10 * remove the module from kernel using rmmod command. .. code-block:: shell $ sudo rmmod tasklet * check if the module is still loaded after removing the kernel module using lsmod if it is not displayed in lsmod output it is verified that the module is removed successfully. .. code-block:: shell $ lsmod | grep tasklet * Check for kernel messages from exit function using dmesg command. .. code-block:: shell $ sudo dmesg [534946.455200] driver unloaded