Re: Ordering / preemption of work in a workqueue preempt?

anish singh <[email protected]>
Newsgroups gmane.linux.newbie,gmane.linux.kernel.kernelnewbies
Message-ID <CAK7N6voHxx702ZZimdv=18Z_Rxgaw9YJMRHC=CqGEKEmrJzEKw@mail.gmail.com>
On Fri, Nov 15, 2013 at 5:01 PM, Rajat Sharma <[email protected]> wrote:
> Hi Rajat,
>
>
> On Fri, Nov 15, 2013 at 7:16 AM, Rajat Jain <[email protected]> wrote:
>>
>> Hi,
>>
>> I have a single work queue, on which I have scheduled a worker function
>> [using queue_work(wq, fn)] in interrupt context.
>>
>> I get the interrupt twice before the work queue gets a chance to run, and
>> hence the same function will get queued twice (with different private
>> context - arguments etc) which is fine and expected.
>>
>> Questions:
>>
>> 1) Is it possible that the instance that was queued by 2nd interrupt, can
>> get to run BEFORE the instance that was queued by 1st interrupt? In other
>> words, is reordering possible?
use alloc_ordered_workqueue: only one workqueue will be active at a time
and it will execute in the queued sequence.
>
>
> It is unlikely as workqueue would have internal queing of tasks.
>
>>
>>
>> 2) Is it possible that one running instance of the function, can get
>> preempted by second instance of the same work queue? I read through
>> http://lwn.net/Articles/511421/ and it talks about same work queue cannot
>> run on different CPU, but I have doubt about single CPU. If If I am writing
>> a worker function, does my code have to be ready that it can be preempted by
>> another instance of the same function?
>>
>
> Do you mean the system has just one CPU, then there would be just one worker
> thread in the workqueue which will pick up requests one by one. Do you see
> multiple threads?
>
>>
>> Please note that I understand that my worker function can preempted by
>> other processes, my doubts are related to the same workqueue.
>>
>> Thanks,
>>
>> Rajat
>>
>>
>
> Rajat
>
>>
>> _______________________________________________
>> Kernelnewbies mailing list
>> [email protected]
>> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>
>
>
> _______________________________________________
> Kernelnewbies mailing list
> [email protected]
> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>
--
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.