How to use Linux Work Queue

后端 未结 3 1025
我在风中等你
我在风中等你 2020-12-24 10:00

Linux work queues are meant to be kernel level threads with process context. I was trying to use it as an alternative to kthread which has no specific process context. But h

3条回答
  •  轮回少年
    2020-12-24 10:41

    It seems like solved, and you have been very helpful to me in order to understand how to use the Work Queues. I give you some code of a simple example in my github, hoping it will be helpful to anyone:

    https://github.com/m0r3n/kernel_modules/blob/master/workQueue.c

    You can compile with the following Makefile:

    KVERSION = $(shell uname -r)
    obj-m = workQueue.o
    
    all:
        make -C /lib/modules/$(KVERSION)/build M=$(PWD) modules
    clean:
        make -C /lib/modules/$(KVERSION)/build M=$(PWD) clean
    

    Insert the module by:

    # sync; insmod workQueue.ko; sync
    

    And see the logs:

    # tailf /var/log/kern.log
    

    EDIT: I just added the delayed version:

    https://github.com/m0r3n/kernel_modules/blob/master/workQueueDelayed.c

提交回复
热议问题