LWN: Comments on "Driver porting: the workqueue interface." http://lwn.net/Articles/23634/ This is a special feed containing comments posted to the individual LWN article titled "Driver porting: the workqueue interface.". hourly 2 Driver porting: the workqueue interface. http://lwn.net/Articles/296794/rss 2008-09-03T21:43:30+00:00 peetee3000 <div class="FormattedComment"> Note that the workqueue interface has changed slightly in v2.6.20:<br> <p> <a rel="nofollow" href="http://www.linuxhq.com/kernel/v2.6/20/include/linux/workqueue.h">http://www.linuxhq.com/kernel/v2.6/20/include/linux/workq...</a><br> <p> Ie, INIT_WORK now takes only 2 parameters.<br> </div> Driver porting: the workqueue interface. http://lwn.net/Articles/136030/rss 2005-05-16T00:44:39+00:00 Freiberg Could you please tell me more about Work Queue synchronization?<br> Are they cumulative? If I scheduled the same work several times inside<br> one isr handler or different isr handlers will all of them run or not and in which sequence?<br> <p> Thanks,<br> Vlad<br> Driver porting: the workqueue interface. http://lwn.net/Articles/119933/rss 2005-01-20T06:17:39+00:00 amit2030 Hi,<br> <p> I wanted to know whether the workqueue gets scheduled before a kernel thread (created by kthread_run()). I have a function that runs in the thread created by kthread_run(). If I use the workqueue interface, then will it be scheduled before other threads created by kthread_run().<br> <p> Regards,<br> Driver porting: the workqueue interface. http://lwn.net/Articles/102132/rss 2004-09-15T07:05:47+00:00 Albert I ran into the same problem. We ran a stepper motor from the timer interrupt. In 2.6 I used the RTC instead. Here is some code for a minimal module that uses RTC to generate IRQ8 at 1024 Hz and also registers an interrupt handler for IRQ8 (via the RTC module).<br> <p> /* <br> * stepper.c - Stepper motor driver using RTC.<br> */<br> #include &lt;linux/module.h&gt; /* Needed by all modules */<br> #include &lt;linux/kernel.h&gt; /* Needed for KERN_ALERT */<br> #include &lt;linux/init.h&gt; /* Needed for the macros */<br> #include &lt;linux/ioctl.h&gt;<br> <p> #if defined(CONFIG_RTC) || defined(CONFIG_RTC_MODULE)<br> <p> #include &lt;linux/rtc.h&gt;<br> <p> <p> #define DRIVER_AUTHOR "John Doe &lt;some@one&gt;"<br> #define DRIVER_DESC "Stepper motor driver using RTC"<br> <p> static rtc_task_t rtc_task;<br> static atomic_t rtc_inc = ATOMIC_INIT(0);<br> static int stepper_freq = 1024; /* Frequency Hz */<br> <p> <p> static void stepper_interrupt(void *private_data)<br> {<br> int ticks;<br> <p> atomic_inc(&amp;rtc_inc);<br> ticks = atomic_read(&amp;rtc_inc);<br> <p> /* Add some code here to drive the stepper motor */<br> if (ticks % stepper_freq == 0) {<br> printk(KERN_WARNING "stepper_interrupt: %d\n", ticks);<br> }<br> }<br> <p> <p> static int __init stepper_init(void)<br> {<br> int err;<br> printk(KERN_ALERT "stepper_init: registering task\n");<br> <p> rtc_task.func = stepper_interrupt;<br> err = rtc_register(&amp;rtc_task);<br> if (err &lt; 0)<br> return err;<br> rtc_control(&amp;rtc_task, RTC_IRQP_SET, stepper_freq);<br> rtc_control(&amp;rtc_task, RTC_PIE_ON, 0);<br> atomic_set(&amp;rtc_inc, 0);<br> return 0;<br> }<br> <p> <p> static void __exit stepper_exit(void)<br> {<br> rtc_control(&amp;rtc_task, RTC_PIE_OFF, 0);<br> rtc_unregister(&amp;rtc_task);<br> printk(KERN_ALERT "stepper_exit: rtc_task unregistered\n");<br> }<br> <p> <p> module_init(stepper_init);<br> module_exit(stepper_exit);<br> <p> MODULE_LICENSE("GPL");<br> MODULE_AUTHOR(DRIVER_AUTHOR);<br> MODULE_DESCRIPTION(DRIVER_DESC);<br> <p> #endif /* CONFIG_RTC || CONFIG_RTC_MODULE */<br> <p> Driver porting: the workqueue interface. http://lwn.net/Articles/97960/rss 2004-08-16T01:16:47+00:00 baisa How do I schedule work tasks (if indeed this is the object I should be using) to execute every timer tick? In the book, in chap 6 "Flow of Time" it lists at least 3 kernel task queues, one of which was a timer queue that dispatched its tasks each tick. But the entire "linux/tqueue.h" functionality was deleted in 2.6, and now I can't figure out how to dispatch some code every timer tick.<br> <p> Thanks! Brad<br> Correction http://lwn.net/Articles/81721/rss 2004-04-22T16:41:36+00:00 corbet Actually, 2.4 had several task queues, most of which did not run in process context. The scheduler queue, in later 2.4 kernels, runs out of keventd, but it is a single, shared thread. Workqueues have multiple, per-CPU threads which are dedicated to the queue. (When Rusty's patch goes in, single-thread workqueues will also be possible, though each queue will still have its own thread). <p> Workqueues also have nice features like a "flush" operation that can guarantee that your tasks are not running and will not run and a "delayed work" capability. Correction http://lwn.net/Articles/81715/rss 2004-04-22T16:29:39+00:00 proski <blockquote><i> Among other things, each workqueue has one or more dedicated worker threads (one per CPU) associated with it. So all tasks running out of workqueues have a process context, and can thus sleep. </i></blockquote> This incorrectly implies that the task queue in 2.4 kernels is not run in the process context and cannot sleep. It's not true. The task queue is run in the context of the "keventd" process.<p> I believe the only significant difference is that the workqueue is processed in per-CPU threads whereas task queue is processed by a single kernel thread. Driver porting: the workqueue interface. http://lwn.net/Articles/62227/rss 2003-12-09T19:17:09+00:00 bighead Its work_struct, not workqueue_struct (if I get what you are asking).<p>Second you might need the usual, linux/init.h, linux/module.h etc header files. Take a look at http://www.xml.com/ldd/chapter/book/. The book is mainly 2.4 based. You can then see http://lwn.net/Articles/driver-porting/ for differences in 2.4 and 2.6.<p>Cheers!<br>Archit Driver porting: the workqueue interface. http://lwn.net/Articles/36687/rss 2003-06-17T21:45:46+00:00 btl I'm trying to playing with workqueues... i've trouble on compiling<br>a little kernel module.<p>What include files do i need beside linux/workqueue.h?<p>I can't find where struct workqueue_struct is defined ;(<br>