How to use Linux Work Queue

后端 未结 3 1045
我在风中等你
我在风中等你 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条回答
  •  萌比男神i
    2020-12-24 10:59

    If you want to pass data to your work queue function, just embed the work_struct structure inside your own data structure and use container_of inside your work function to retrieve it.

    As for a simple example, the kernel is full of it - just git grep work_struct. You can look at drivers/cpufreq/cpufreq.c (handle_update function) for a simple example. The article below also embeds an example at the end, but it does not use container_of and instead relies on the fact that the first member of a structure has the same address as its parent:

    http://www.ibm.com/developerworks/linux/library/l-tasklets/index.html

提交回复
热议问题