lkml.org 
[lkml]   [2013]   [Mar]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: Workqueue behaviour - Synchronization within submitted work.
On Mar 20 Vijay wrote:
> In the new workqueue architecture, I have a question regarding
> synchronization between different "work" submitted to the same
> workqueue. For example:
>
> * I submit two "works" A and B to a common driver specific workqueue (W).
> * Each A and B, meddle with a certain shared data SD.
> * Am I guaranteed serialized execution of A and B, or should I play
> safe and use a semaphore (acquire/release) with A and B ?

The works A and B may be (and more or less likely will be) executed in
parallel --- except if you create the workqueue with parameters @flags |=
WQ_UNBOUND and @max_active = 1. alloc_ordered_workqueue() is a shorthand
for creation of such a workqueue.

Some more thoughts:
- If you go for an ordered workqueue and no other means of serialization
of accesses to your data, check carefully that these data are indeed
never accessed in other contexts besides the workers.
- For serialization in non-atomic context, a struct mutex is usually
preferred over a struct semaphore. The foremost advantage of mutexes
over counting semaphores is that code using the former can be debugged
much easier.
--
Stefan Richter
-=====-===-= --== ==---
http://arcgraph.de/sr/


\
 
 \ /
  Last update: 2013-03-24 17:21    [W:0.037 / U:0.008 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site