Use single threaded work queue.
[cascardo/kernel/samples/workqueue/.git] / block_wq.c
index ae6d8ab..c05b974 100644 (file)
@@ -29,12 +29,9 @@ MODULE_AUTHOR("Thadeu Lima de Souza Cascardo");
 
 static void work_block(struct work_struct *work)
 {
-       unsigned long tmp = jiffies + 5 * HZ;
        printk(KERN_INFO "Blocking other works in the queue\n");
        printk(KERN_INFO "Executing task in CPU %d\n", smp_processor_id());
-       /* We also kick the CPU high */
-       while (!time_after(jiffies, tmp))
-               cpu_relax();
+       msleep(5);
 }
 
 static void work_print(struct work_struct *work)
@@ -49,7 +46,7 @@ static DECLARE_WORK(print_work, work_print);
 
 static int block_wq_init(void)
 {
-       block_wq = create_workqueue("block_wq");
+       block_wq = create_singlethread_workqueue("block_wq");
        if (!block_wq)
                return -ENOMEM;
        printk(KERN_INFO "Queueing task in CPU %d\n", get_cpu());