Re: Sleeping in workqueues

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Arun,

thank you for your answer and the explanation  of completion variables 
and how the workers are used. It clearified those ideas for me and I 
feel safer using them now.

Best regards,

Tobias

On 13.02.2017 11:01, Arun Sudhilal wrote:
> Hello Tobias,
>
> On Sun, Feb 12, 2017 at 7:15 PM, Tobias FItschen
> <tobias.fitschen@xxxxxxxxxxxxxxxxxxx> wrote:
>> Hello people,
>>
>> I have a question regarding workqueues. I know it's possible to sleep in
>> workqueue routines. Does that mean I can use:
> What it means is that you are safe to use any sub routines which may
> sleep or which will sleep.
>
>> 1. "set_current_state(TASK_INTERRUPTIBLE);" get the the task with
>> "current" and pass it to a other task and then call "schedule();" in a
>> workqueue routine and at a different place (perhaps another workqueue
>> routine) use wake_up_process(task)" ?
>>
>> 2. initialize completions in a workqueue routine and call complete() in
>> a different workqueue routine?
>>
>> I tried it in a simple example setup and both worked. I just want to
> completion variables are written to hide the complexity of using
> set_current_state and related functions to make a thread sleep. It
> basically enables driver authors to reuse the same code for
> sleep/wake.
> At the heart of it, its all the same. My recommendation is to use completion.
>
>> make sure that was not just by accident. As I understand it a work item
>> is executed on a worker, which is a unique process, but I also know that
>> there are exceptions, e.g. I can not copy to or from user space in a
>> workqueue routine. Also I don't know if a worker "sticks" with the
>> current work item until it is completed or can execute multiple work
>> items at the "same" time.
> Yes a kworker sticks with current work item until it is completed. If
> a work item currently executed by a worker met with a sleep, another
> kworkers are used to process the other pending work items.
>
> Regards,
> Arun
>
>> 3. In case completions and schedule()/wakeup() work, I would also like
>> to know, which has the better performance.
>>
>> Thanks a lot already!
>>
>> Tobias
>>
>>
>> _______________________________________________
>> Kernelnewbies mailing list
>> Kernelnewbies@xxxxxxxxxxxxxxxxx
>> https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@xxxxxxxxxxxxxxxxx
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies



[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux