Taskqueue : Periodic ========================== .. 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:`Complete program : taskqueue.c ` * :ref:`Makefile ` * :ref:`Compile Program ` * :ref:`Load the module ` * :ref:`Check if the module is loaded successfully ` * :ref:`Check what happened on module load ` * :ref:`Unload the module ` * :ref:`Check if the module is unloaded successfully ` * :ref:`Check what happened on module unload ` .. _FreebsdDeviceDriver_basic_fdd_taskqueue_periodic_1: .. tab-set:: .. tab-item:: Version Info =============================== ======================================= # Version =============================== ======================================= Freebsd 14.1.0 =============================== ======================================= .. _FreebsdDeviceDriver_basic_fdd_taskqueue_periodic_2: .. 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 schedule the taskqueue ? .. _FreebsdDeviceDriver_basic_fdd_taskqueue_periodic_3: .. tab-set:: .. tab-item:: taskqueue.c .. literalinclude:: taskqueue_periodic/taskqueue.c :language: c :linenos: .. _FreebsdDeviceDriver_basic_fdd_taskqueue_periodic_4: .. tab-set:: .. tab-item:: Makefile .. literalinclude:: taskqueue_periodic/Makefile :language: c :linenos: .. _FreebsdDeviceDriver_basic_fdd_taskqueue_periodic_5: .. tab-set:: .. tab-item:: Compile Program .. code-block:: c :linenos: :emphasize-lines: 1, 5, 9 $ pwd basic_device_drivers/taskqueue_periodic $ ls taskqueue.c Makefile $ make $ ls .depend.taskqueue.o export_syms machine taskqueue.c taskqueue_module.ko Makefile i386 opt_global.h taskqueue.o x86 .. _FreebsdDeviceDriver_basic_fdd_taskqueue_periodic_6: .. tab-set:: .. tab-item:: Load the module * Load the module using kldload .. code-block:: c :linenos: :emphasize-lines: 1 $ kldload -v ./taskqueue_module.ko Loaded ./taskqueue_module.ko, id=8 .. _FreebsdDeviceDriver_basic_fdd_taskqueue_periodic_7: .. tab-set:: .. tab-item:: Check if the module is loaded successfully * Run kldstat command to check the loaded modules .. code-block:: c :linenos: :emphasize-lines: 1 $ kldstat Id Refs Address Size Name 1 29 0xffffffff80200000 1f6c698 kernel 2 1 0xffffffff8216e000 772c70 zfs.ko 3 1 0xffffffff828e1000 7850 cryptodev.ko 4 1 0xffffffff83218000 3220 intpm.ko 5 1 0xffffffff8321c000 2178 smbus.ko 6 1 0xffffffff8321f000 3360 uhid.ko 7 1 0xffffffff83223000 3360 wmt.ko 8 1 0xffffffff83227000 20b8 taskqueue_module.ko .. _FreebsdDeviceDriver_basic_fdd_taskqueue_periodic_8: .. tab-set:: .. tab-item:: Check what happened on module load * Run dmesg command to check the kernel logs .. code-block:: c :linenos: :emphasize-lines: 1 $ dmesg Module loaded Repeated taskqueue Taskqueue excuted: counter : 1, pending : 1 Repeated taskqueue Taskqueue excuted: counter : 2, pending : 1 Repeated taskqueue Taskqueue excuted: counter : 3, pending : 1 Repeated taskqueue Taskqueue excuted: counter : 4, pending : 1 Repeated taskqueue Taskqueue excuted: counter : 5, pending : 1 .. _FreebsdDeviceDriver_basic_fdd_taskqueue_periodic_9: .. tab-set:: .. tab-item:: Unload the module * Unload the module using kldunload .. code-block:: c :linenos: :emphasize-lines: 1 $ kldunload -v ./taskqueue_module.ko Unloading taskqueue_module.ko, id=8 .. _FreebsdDeviceDriver_basic_fdd_taskqueue_periodic_10: .. tab-set:: .. tab-item:: Check if the module is unloaded successfully * Run kldstat command to check the loaded modules .. code-block:: c :linenos: :emphasize-lines: 1 $ kldstat Id Refs Address Size Name 1 27 0xffffffff80200000 1f6c698 kernel 2 1 0xffffffff8216e000 772c70 zfs.ko 3 1 0xffffffff828e1000 7850 cryptodev.ko 4 1 0xffffffff83218000 3220 intpm.ko 5 1 0xffffffff8321c000 2178 smbus.ko 6 1 0xffffffff8321f000 3360 uhid.ko 7 1 0xffffffff83223000 3360 wmt.ko .. _FreebsdDeviceDriver_basic_fdd_taskqueue_periodic_11: .. tab-set:: .. tab-item:: Check what happened on module unload * Run dmesg command to check the kernel logs .. code-block:: c :linenos: :emphasize-lines: 1 $ dmesg Module loaded Repeated taskqueue Taskqueue excuted: counter : 1, pending : 1 Repeated taskqueue Taskqueue excuted: counter : 2, pending : 1 Repeated taskqueue Taskqueue excuted: counter : 3, pending : 1 Repeated taskqueue Taskqueue excuted: counter : 4, pending : 1 Repeated taskqueue Taskqueue excuted: counter : 5, pending : 1 Repeated taskqueue Taskqueue excuted: counter : 6, pending : 1 Repeated taskqueue Taskqueue excuted: counter : 7, pending : 1 Repeated taskqueue Taskqueue excuted: counter : 8, pending : 1 Repeated taskqueue Taskqueue excuted: counter : 9, pending : 1 Module unloaded