Re: Work queue questions
From: Deepawali Verma
Date: Mon Sep 24 2012 - 03:25:46 EST
Hi Tejun,
Here are some code snippets from my device driver:
#defind NUMBER_OF_SUBTASKS 3
struct my_driver_object
{
struct workqueue_struct *sub_task_wq;
struct work_struct sub_task_work;
char my_obj_wq_name[80];
int task_id;
};
struct my_driver_object obj[3];
void my_driver_init(void)
{
int i =0;
memset(my_obj_wq_name,0,80);
--------------------------------------
for (i =0; i<3; i++)
{
snprintf(obj[i].my_obj_wq_name,80, "Task-wq:%d",i);
obj.sub_task_wq = alloc_workqueue(obj[i].my_obj_wq_name,WQ_UNBOUND,1);
INIT_WORK(&obj[i].sub_task_work, sub_task_work_handler);
}
--------------------------------------
}
void start_sub_tasks()
{
int i =0;
for (i =0; i<3; i++)
{
queue_work(obj[i].sub_task_wq, &obj[i].sub_task_work);
}
}
static void sub_task_work_handler(struct work_struct work)
{
Ftrace marker start;
Ftrace marker end
}
Ideally I was expecting when work is queued to three different work
queues, it should run in parallel but it is not doing as per expected.
Let me know about this.
Regards,
Deepa
On Sat, Sep 22, 2012 at 7:18 AM, Daniel Taylor <Daniel.Taylor@xxxxxxx> wrote:
>
> ...
>
>> >> So on so forth.
>> >> Anyway how can you write chunks of data in parallel when
>> >> already some worker
>> >> thread is writing i.e. the system is busy.
>> >> Analogy: Suppose you are ambidextrous and you are eating.Can
>> >> you eat with
>> >> both of your hands at a time?So worker thread are like your
>> >> hands and keeping
>> >> you fed all the time is the concept of concurrency.
>> >>
>> >> I am not an expert on this but from Tejun's reply I could
>> >> make out this.
>> >> Please correct me If I have wrongly understood the concept
>> >> based on this mail
>> >
>> > I don't know how many cores are in the CPU Deepawali's
>> using, but if I have four,
>> Assuming single core,Is my explanation correct about concurrency?
>
> It is possible for his tasks to complete before scheduling occurs
> again. Consuming all of the CPU and having no blocking action,
> yes, then the tasks will run consecutively.
>
> ...
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/