Hi Vimal,
On Sun, Oct 3, 2010 at 8:59 PM, Vimal <[email protected]> wrote:
> Hi Arun,
>
>> Have a look here,
>> http://lwn.net/Articles/211279/
>
> Thanks a lot for the link. However, I am still confused how one would
> go about doing something like this using workqueues:
>
> performance critical path: (this is like a producer)
> queue(work on a *particular data* D)
>
> worker thread: (this is like a consumer of queued work)
> while(1) {
> wait for work+data D on queue
> perform work on data D
> remove data D from queue
> }
>
> It is unclear how to do the above using workqueues. Are there some
> examples for this new API?
I think what you're asking is how do you have your own private data?
If so, then what you're supposed to do is to create your own structure
which contains a struct work struct and then use container_of inside
your function.
So something like this:
struct my_work_struct
{
struct work_struct work;
int my data here;
....
};
struct my_work_struct my_work
... put whatever you want in my_work...
schedule_work( &my_work );
and then inside the function:
void my_func( struct work_struct *ws )
{
struct my_work_struct *my_ws = container_of( ws, struct
my_work_struct, work );
... access your data from my_ws ...
}
--
Dave Hylands
Shuswap, BC, Canada
http://www.DaveHylands.com/
--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to [email protected]
Please read the FAQ at http://kernelnewbies.org/FAQ